DeepSeek MCP服务器
MCP服务器实现,使用DeepSeek API提供代码生成和完成功能,并支持工具链接和成本优化。
特性
- 具有特定语言支持的代码生成
- 具有上下文感知的代码补全
- 多目标代码优化
- 用于复杂操作的工具链
- 内置缓存以优化成本
- 具有完全类型安全的TypeScript实现
工具
1.生成代码
使用具有特定语言支持的DeepSeek API生成代码。
{
"name": "generate_code",
"params": {
"prompt": "Write a function that sorts an array",
"language": "typescript",
"temperature": 0.7
}
}2.完整代码
基于现有上下文获取智能代码补全。
{
"name": "complete_code",
"params": {
"code": "function processData(data) {",
"prompt": "Add input validation and error handling",
"temperature": 0.7
}
}3.优化代码
优化现有代码的性能、内存使用或可读性。
{
"name": "optimize_code",
"params": {
"code": "your code here",
"target": "performance"
}
}4.执行链
按顺序执行一系列工具,并在步骤之间传递上下文。
{
"name": "execute_chain",
"params": {
"steps": [
{
"toolName": "generate_code",
"params": {
"prompt": "Create a REST API endpoint",
"language": "typescript"
}
},
{
"toolName": "optimize_code",
"params": {
"target": "performance"
}
}
]
}
}安装
- 克隆存储库
- 安装依赖项:
npm install- 构建项目:
npm run build- 在MCP设置文件中配置DeepSeek API密钥:
{
"mcpServers": {
"deepseek": {
"command": "node",
"args": ["/path/to/deepseek-mcp/build/index.js"],
"env": {
"DEEPSEEK_API_KEY": "your-api-key"
}
}
}
}用法
该服务器可以与任何兼容MCP的客户端一起使用。以下是一个使用MCP CLI的示例:
mcp use deepseek generate_code --params '{"prompt": "Write a hello world program", "language": "python"}'工具链
工具链允许您将多个操作组合到一个工作流中。链中的每个工具都可以通过链上下文访问以前工具的结果。
示例链:
- 生成初始代码
- 完成带有错误处理的代码
- 优化最终结果
{
"steps": [
{
"toolName": "generate_code",
"params": {
"prompt": "Create a user authentication function",
"language": "typescript"
}
},
{
"toolName": "complete_code",
"params": {
"prompt": "Add input validation and error handling"
}
},
{
"toolName": "optimize_code",
"params": {
"target": "security"
}
}
]
}成本优化
服务器采用多种策略来优化API成本:
- 使用TTL请求缓存
- 链式结果缓存
- 智能快速施工
- 用于使用分析的元数据跟踪
发展
开始开发:
npm run dev清理和重建:
npm run rebuild需求
- Node.js>=18.0.0
- DeepSeek API密钥
- MCP兼容客户端
许可证
国际协调委员会
