Labsco
chew-z logo

DeepSeek MCP Server

โ˜… 2

from chew-z

An MCP server for the DeepSeek API, providing code review, file management, and account management.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredNeeds API keys

DeepSeek MCP Server

A production-grade MCP server integrating with DeepSeek's API, featuring advanced code review capabilities, efficient file management, and API account management.

Features

  • Multi-Model Support: Choose from various DeepSeek models including DeepSeek Chat and DeepSeek Coder
  • Code Review Focus: Built-in system prompt for detailed code analysis with markdown output
  • Automatic File Handling: Built-in file management with direct path integration
  • API Account Management: Check balance and estimate token usage
  • JSON Mode Support: Request structured JSON responses for easy parsing
  • Advanced Error Handling: Graceful degradation with structured error logging
  • Improved Retry Logic: Automatic retries with configurable exponential backoff for API calls
  • Security: Configurable file type restrictions and size limits
  • Performance Monitoring: Built-in metrics collection for request latency and throughput

Core API Tools

Currently, the server provides the following tools:

deepseek_ask

Used for code analysis, review, and general queries with optional file path inclusion.

{
  "name": "deepseek_ask",
  "arguments": {
    "query": "Review this Go code for concurrency issues...",
    "model": "deepseek-chat",
    "systemPrompt": "Optional custom review instructions",
    "file_paths": ["main.go", "config.go"],
    "json_mode": false
  }
}

deepseek_models

Lists all available DeepSeek models with their capabilities.

{
  "name": "deepseek_models",
  "arguments": {}
}

deepseek_balance

Checks your DeepSeek API account balance and availability status.

{
  "name": "deepseek_balance",
  "arguments": {}
}

deepseek_token_estimate

Estimates the token count for text or a file to help with quota management.

{
  "name": "deepseek_token_estimate",
  "arguments": {
    "text": "Your text to estimate...",
    "file_path": "path/to/your/file.go"
  }
}

Supported Models

The following DeepSeek models are supported by default:

Model IDDescription
deepseek-chatGeneral-purpose chat model balancing performance and efficiency
deepseek-coderSpecialized model for coding and technical tasks
deepseek-reasonerModel optimized for reasoning and problem-solving tasks

Note: The actual available models may vary based on your API access level. The server will automatically discover and make available all models you have access to through the DeepSeek API.

Supported File Types

ExtensionMIME Type
.gotext/x-go
.pytext/x-python
.jstext/javascript
.mdtext/markdown
.javatext/x-java
.c/.htext/x-c
.cpp/.hpptext/x-c++
25+ more(See getMimeTypeFromPath in deepseek.go)

Operational Notes

  • Degraded Mode: Automatically enters safe mode on initialization errors
  • Audit Logging: All operations logged with timestamps and metadata
  • Security: File content validated by MIME type and size before processing

File Handling

The server handles files directly through the deepseek_ask tool:

  1. Specify local file paths in the file_paths array parameter
  2. The server automatically:
    • Reads the files from the provided paths
    • Determines the correct MIME type based on file extension
    • Uploads the file content to the DeepSeek API
    • Uses the files as context for the query

This direct file handling approach eliminates the need for separate file upload/management endpoints.

JSON Mode Support

For integrations that require structured data output, the server supports JSON mode:

  • Structured Responses: Request properly formatted JSON responses from DeepSeek models
  • Parser-Friendly: Ideal for CI/CD pipelines and automation systems
  • Easy Integration: Simply set json_mode: true in your request

Example with JSON mode:

{
  "name": "deepseek_ask",
  "arguments": {
    "query": "Analyze this code and return a JSON object with: issues_found (array of strings), complexity_score (number 1-10), and recommendations (array of strings)",
    "model": "deepseek-chat",
    "json_mode": true,
    "file_paths": ["main.go", "config.go"]
  }
}

This returns a well-formed JSON response that can be parsed directly by your application.

Development

Command-line Options

The server supports these command-line options to override environment variables:

# Override the DeepSeek model to use
./bin/mcp-deepseek -deepseek-model=deepseek-coder

# Override the system prompt
./bin/mcp-deepseek -deepseek-system-prompt="Your custom prompt here"

# Override the temperature setting (0.0-1.0)
./bin/mcp-deepseek -deepseek-temperature=0.8

Running Tests

To run tests:

go test -v ./...

Running Linter

golangci-lint run

Formatting Code

gofmt -w .