一款生产级别的MCP服务器,集成DeepSeek的API,具备高级代码审查功能、高效的文件管理和API账户管理。
# 克隆并构建
git clone https://github.com/your-username/DeepseekMCP
cd DeepseekMCP
go build -o bin/mcp-deepseek
# 使用环境变量启动服务器
export DEEPSEEK_API_KEY=your_api_key
export DEEPSEEK_MODEL=deepseek-chat
./bin/mcp-deepseek
{
"mcpServers": {
"deepseek": {
"command": "/Your/project/path/bin/mcp-deepseek",
"env": {
"DEEPSEEK_API_KEY": "YOUR_API_KEY",
"DEEPSEEK_MODEL": "deepseek-chat"
}
}
}
}
| 变量 | 描述 | 默认值 |
|---|---|---|
DEEPSEEK_API_KEY | DeepSeek API密钥 | 必填 |
DEEPSEEK_MODEL | 可用模型中的模型ID | deepseek-chat |
DEEPSEEK_SYSTEM_PROMPT | 代码审查的系统提示 | 默认代码审查提示 |
DEEPSEEK_SYSTEM_PROMPT_FILE | 包含系统提示的文件路径 | 空 |
DEEPSEEK_MAX_FILE_SIZE | 最大上传大小(字节) | 10485760(10MB) |
DEEPSEEK_ALLOWED_FILE_TYPES | 逗号分隔的MIME类型 | [常见的文本/代码类型] |
DEEPSEEK_TIMEOUT | API超时时间(秒) | 90 |
DEEPSEEK_MAX_RETRIES | 最大API重试次数 | 2 |
DEEPSEEK_INITIAL_BACKOFF | 初始退避时间(秒) | 1 |
DEEPSEEK_MAX_BACKOFF | 最大退避时间(秒) | 10 |
DEEPSEEK_TEMPERATURE | 模型温度(0.0-1.0) | 0.4 |
示例 .env 文件:
DEEPSEEK_API_KEY=your_api_key
DEEPSEEK_MODEL=deepseek-chat
DEEPSEEK_SYSTEM_PROMPT="您的自定义代码审查提示"
# 或者:从文件加载系统提示
# DEEPSEEK_SYSTEM_PROMPT_FILE=/path/to/prompt.txt
DEEPSEEK_MAX_FILE_SIZE=5242880 # 5MB
DEEPSEEK_ALLOWED_FILE_TYPES=text/x-go,text/markdown
DEEPSEEK_TEMPERATURE=0.7
当前,服务器提供以下工具:
用于代码分析、审查和一般查询,可选包含文件路径。
{
"name": "deepseek_ask",
"arguments": {
"query": "审查这段Go代码中的并发问题...",
"model": "deepseek-chat",
"systemPrompt": "可选的自定义审查指令",
"file_paths": ["main.go", "config.go"],
"json_mode": false
}
}
列出所有可用的DeepSeek模型及其能力。
{
"name": "deepseek_models",
"arguments": {}
}
检查您的DeepSeek API账户余额和可用状态。
{
"name": "deepseek_balance",
"arguments": {}
}
估计文本或文件的token数量,帮助管理配额。
{
"name": "deepseek_token_estimate",
"arguments": {
"text": "要估计的文本...",
"file_path": "path/to/your/file.go"
}
}
默认情况下,支持以下DeepSeek模型:
| 模型ID | 描述 |
|---|---|
deepseek-chat | 平衡性能和效率的一般用途聊天模型 |
deepseek-coder | 专门用于编码和技术任务的模型 |
deepseek-reasoner | 优化用于推理和解决问题任务的模型 |
注意:实际可用的模型可能因您的API访问级别而异。服务器会自动发现并通过DeepSeek API为您提供所有可访问的模型。
| 扩展名 | MIME类型 |
|---|---|
| .go | text/x-go |
| .py | text/x-python |
| .js | text/javascript |
| .md | text/markdown |
| .java | text/x-java |
| .c/.h | text/x-c |
| .cpp/.hpp | text/x-c++ |
| 25+更多 | (参见getMimeTypeFromPath在deepseek.go中) |
服务器通过deepseek_ask工具直接处理文件:
file_paths数组参数中指定本地文件路径这种直接文件处理方法消除了需要单独文件上传/管理端点的需求。
对于需要结构化数据输出的集成,服务器支持JSON模式:
json_mode: trueJSON模式示例:
{
"name": "deepseek_ask",
"arguments": {
"query": "分析此代码并返回一个JSON对象,包含:issues_found(字符串数组),complexity_score(1-10的数字),和recommendations(字符串数组)",
"model": "deepseek-chat",
"json_mode": true,
"file_paths": ["main.go", "config.go"]
}
}
这将返回一个可以由应用程序直接解析的格式良好的JSON响应。
服务器支持这些命令行选项来覆盖环境变量:
# 覆盖使用的DeepSeek模型
./bin/mcp-deepseek -deepseek-model=deepseek-coder
# 覆盖系统提示
./bin/mcp-deepseek -deepseek-system-prompt="您的自定义提示"
# 覆盖温度设置(0.0-1.0)
./bin/mcp-deepseek -deepseek-temperature=0.8
运行测试:
go test -v ./...
golangci-lint run
gofmt -w .
欢迎贡献!请随意提交Pull Request。
git checkout -b feature/amazing-feature)git commit -m '添加一些惊人的功能')git push origin feature/amazing-feature)