Joe1sn's Cabin

【AI】本地部署DeepSeek并使用MCP

主要是一些配置,同时算是备忘手册

本地部署DeepSeek

首先是部署DeepSeek R3

我是使用的是LM Studio,下载链接:https://lmstudio.ai/

下载完成后需要按照如下逻辑结构创建文件夹:

image-20250405150022259

image-20250405150116645

然后下载DeepSeek的模型,国内可以通过魔塔社区等下载,会快很多。

我的显卡是GTX1650 MaxQ显存只有4G。使用:DeepSeek-R1-Distill-Qwen-7B-GGUF

AI相关最重要的就是显卡的显存,关于显卡参数可以在 任务管理器 -> 性能 中看到,如果只有一个intel的集显,那么得下载对应的显卡驱动。

image-20250405150342161

  • deepseek 1.5b:几乎没有显卡要求
  • deepseek 7b: 至少4G显存
  • deepseek 8b: 至少6G显存
  • deepseek 14b: 12G显存
  • deepseek 32b:至少24G显存

如果配置正确就可以在LM Studio中看到了

image-20250405151008485

一般配置如下

image-20250405151041947

建议开启 闪电注意力(Fast attention),同时如果需要使用MCP建议将上下文长度改为至少 8192

等待模型加载后即可使用。 使用完成后记得弹出!

image-20250405151234629

MCP使用

这里讲最简单的使用:下载一个 5ire

image-20250405151425961

在这里设置相关参数,如:使用Deepseek的官方API

image-20250405151500341

如果使用本地的AI,需要设置下LM Studio

image-20250405151547866

然后在5ire中设置如下:

image-20250405151619366

这里的模型应该在连接成功后即可使用选择,并且在LM Studio中能看到API请求如下

image-20250405151713767

工具->工具市场中可以看到许多MCP Server,这里已Web举例,这个MCP的功能是访问网页

image-20250405151809886

安装完成后需要在工具中启用

image-20250405151913412

之后点击 新对话 就可以使用了,如:

image-20250405152327299

image-20250405152338926

然后是本地的效果,反应的速度取决显卡,一般来说巨卡。因为本地模型是小参数,要笨很多,所以promote要详细些

image-20250405152450640

image-20250405152642932

安装MCP

在工具中新建即可,这里用ida-pro-mcp这个举例

官方的json配置格式如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
"mcpServers": {
"github.com/mrexodia/ida-pro-mcp": {
"command": "uv",
"args": [
"--directory",
"c:\\MCP\\ida-pro-mcp",
"run",
"server.py",
"--install-plugin"
],
"timeout": 1800,
"disabled": false,
"autoApprove": [
"check_connection",
"get_metadata",
"get_function_by_name",
"get_function_by_address",
"get_current_address",
"get_current_function",
"convert_number",
"list_functions",
"list_strings",
"search_strings",
"decompile_function",
"disassemble_function",
"get_xrefs_to",
"get_entry_points",
"set_comment",
"rename_local_variable",
"rename_global_variable",
"set_global_variable_type",
"rename_function",
"set_function_prototype",
"declare_c_type",
"set_local_variable_type"
],
"alwaysAllow": [
"check_connection",
"get_metadata",
"get_function_by_name",
"get_function_by_address",
"get_current_address",
"get_current_function",
"convert_number",
"list_functions",
"list_strings",
"search_strings",
"decompile_function",
"disassemble_function",
"get_xrefs_to",
"get_entry_points",
"set_comment",
"rename_local_variable",
"rename_global_variable",
"set_global_variable_type",
"rename_function",
"set_function_prototype",
"declare_c_type",
"set_local_variable_type"
]
}
}
}

在5ire中如下,他会自动完善其他参数

image-20250405152815121

关于MCP管理

这里说了5ire,也可以使用其他的,个人认为比较初略的框架可以试试mcp-bridge,因为他只做了中间服务,连ui都没有,方便二次开发

image-20250405153747247