The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Deepseek MCP Server listing page.
MCP server for DeepSeek V4 (v4-flash and v4-pro, 1M context) with multi-turn sessions, function calling, thinking mode, and cost tracking.
Compatible with Claude Code, Gemini CLI, Cursor, Windsurf, and any MCP-compatible client.
Officially listed on the MCP Registry, Smithery, Glama, LobeHub, and Fronteir AI.
v2.0.0 runs on DeepSeek V4. Two models,
deepseek-v4-flash(fast and economical) anddeepseek-v4-pro(top capability), both with a 1M-token context window and optional chain-of-thought thinking. Existingdeepseek-chatanddeepseek-reasonersetups keep working through deprecated aliases, so upgrading is drop-in, but new setups should use the V4 names.
Use the hosted endpoint directly — no npm install, no Node.js required. Bring your own DeepSeek API key:
Claude Code:
Cursor / Windsurf / VS Code:
Claude Code:
Gemini CLI:
Scope options (Claude Code):
-s user: Available in all your projects (recommended)-s local: Only in current project (default)-s project: Project-specific .mcp.json fileGet your API key: https://platform.deepseek.com
deepseek-v4-flash and deepseek-v4-pro, both with 1M context and optional chain-of-thought thinking modesession_id parameterdeepseek://models, deepseek://config, deepseek://usage — query model info, config, and usage statsthinking: {type: "enabled"}json_mode: trueresponse_schema and the server validates the output against it, with bounded repair retries and a ReDoS guard on schema patternsdeepseek_fim tooldeepseek_sessions toolENABLE_MULTIMODAL=true)deepseek-mcp.tahirl.com/mcp — BYOK (Bring Your Own Key), no install neededTRANSPORT=httpIf you prefer to install manually:
Once configured, your MCP client will have access to deepseek_chat, deepseek_fim, and deepseek_sessions tools, plus 3 MCP resources.
Example prompts:
Your MCP client will automatically call the deepseek_chat tool.
If your MCP client doesn't support the add command, manually add to your config file:
Config file locations:
~/.claude.json (add to projects["your-project-path"].mcpServers section)deepseek_chatChat with DeepSeek AI models with automatic cost tracking and function calling support.
Parameters:
messages (required): Array of conversation messages
role: "system" | "user" | "assistant" | "tool"content: Message texttool_call_id (optional): Required for tool role messagesmodel (optional): "deepseek-v4-flash" (default) or "deepseek-v4-pro". The deprecated "deepseek-chat" and "deepseek-reasoner" aliases are still accepted and resolve to v4-flash (non-thinking / thinking); prefer the V4 names.temperature (optional): 0-2, controls randomness (default: 1.0). Ignored when thinking mode is enabled.max_tokens (optional): Maximum tokens to generate (V4 models support up to 384000)stream (optional): Enable streaming mode (default: false)tools (optional): Array of tool definitions for function calling (max 128)tool_choice (optional): "auto" | "none" | "required" | {type: "function", function: {name: "..."}}thinking (optional): Toggle thinking mode, {type: "enabled"} to reason or {type: "disabled"} for a fast answer (non-thinking is the default)reasoning_effort (optional): "high" (default) or "max", applies only while thinking mode is activejson_mode (optional): Enable JSON output mode (supported by both models)response_schema (optional): A JSON Schema to validate the model output against. Implies JSON output. The server validates the parsed result and, on failure, issues up to RESPONSE_SCHEMA_MAX_RETRIES repair retries (default 2, set 0 to disable) that feed the validation error back to the model. Schema regex patterns are screened for ReDoS and an unsafe pattern is rejected up front.session_id (optional): Session ID for multi-turn conversations. Previous context is automatically prepended.Response includes:
structuredContent.request: a self-contained per-request usage and cost summary (token counts, cache hit/miss, cost_usd), aggregated across any repair retriesstructuredContent.effective and fallback: what was actually sent after alias/thinking resolution, and any silent model fallback that firedstructuredContent.schema: when response_schema is used, {valid, attempts, error?}; json_parse_error when JSON output could not be recoveredExample:
Reasoning Example (v4-flash with thinking enabled):
Thinking mode returns the chain-of-thought in <thinking> tags followed by the final answer.
DeepSeek V4 Pro Example (hardest tasks):
Function Calling Example:
When the model decides to call a function, the response includes tool_calls with the function name and arguments. You can then send the result back using a tool role message with the matching tool_call_id.
Thinking Mode Example:
When thinking mode is enabled, temperature and top_p are automatically ignored.
JSON Output Mode Example:
JSON mode ensures the model outputs valid JSON. Include the word "json" in your prompt for best results. Supported by all models.
Schema-Validated JSON Example:
The server validates the parsed output against the schema. If it does not match, it retries up to RESPONSE_SCHEMA_MAX_RETRIES times (default 2), feeding the validation error back to the model, and returns the first schema-valid object. A persistent mismatch is surfaced as structuredContent.schema.valid = false rather than a silently coerced answer. Regex patterns in the schema are screened for catastrophic backtracking (ReDoS); an unsafe pattern is rejected up front as an invalid schema.
Multi-Turn Session Example:
Use the same session_id across requests to maintain conversation context. Messages are stored in memory and prepended automatically. In HTTP transport each connected MCP session has its own isolated session store — a session_id created by one HTTP client is not visible to another (see HTTP Transport below).
deepseek_fimFill-in-the-Middle completion. You give a prompt (the prefix) and an optional suffix, and the model completes the text in between. It is built for code completion and content infilling rather than conversation. FIM runs on DeepSeek's Beta endpoint in non-thinking mode, and the API caps output at 4096 tokens.
Parameters:
prompt (required): The prefix text before the gap. For code completion, this is the code up to the cursor.suffix (optional): The text after the gap. The model fills the space between prompt and suffix.model (optional): "deepseek-v4-flash" (default) or "deepseek-v4-pro". The deprecated "deepseek-chat" and "deepseek-reasoner" aliases are still accepted and resolve to v4-flash (FIM has no thinking mode).max_tokens (optional): Maximum tokens to generate, up to 4096.temperature (optional): 0-2, controls randomness (default: 1.0).stop (optional): A stop string or an array of up to 16 stop strings.Response includes:
text, usage, finish_reason, and cost_usd fieldsExample (code completion):
The model returns the missing middle, e.g. fib(n-1) + fib(n-2), using both the prefix and the suffix as context. Available on both the npm/stdio server and the hosted worker endpoint.
deepseek_sessionsManage conversation sessions.
Parameters:
action (required): "list" | "clear" | "delete"session_id (optional): Required when action is "delete"Examples:
MCP Resources provide read-only data about the server:
| Resource URI | Description |
|---|---|
deepseek://models | Available models with capabilities, context limits, and pricing |
deepseek://config | Current server configuration (API key masked) |
deepseek://usage | Real-time usage statistics (requests, tokens, costs, sessions) |
When a model fails with a retryable error (429, 503, timeout), the server automatically falls back to the other model:
deepseek-v4-flash fails → tries deepseek-v4-prodeepseek-v4-pro fails → tries deepseek-v4-flashThe deprecated aliases (which resolve to v4-flash) fall back to deepseek-v4-pro.
The circuit breaker protects against cascading failures:
CIRCUIT_BREAKER_THRESHOLD consecutive failures (default: 5), the circuit opens (fast-fail mode)CIRCUIT_BREAKER_RESET_TIMEOUT ms (default: 30000), it enters half-open state and sends a probe requestFallback can be disabled with FALLBACK_ENABLED=false.
Prompt templates (12 total):
Each prompt is optimized for thinking mode (v4-flash with thinking: {type: "enabled"}) to provide detailed reasoning.
Both V4 models have a 1M-token context window, up to 384K output tokens, and support function calling, JSON mode, and optional chain-of-thought thinking. They are non-thinking by default here for fast responses; enable reasoning with thinking: {type: "enabled"}.
deepseek-chat and deepseek-reasoner are deprecated. They are still accepted and resolve to deepseek-v4-flash (chat = non-thinking, reasoner = thinking), so existing configs keep working, but they will be removed in the next major release. The DeepSeek API itself retired those two names on 2026-07-24; this server keeps translating them to V4 for you in the meantime. New setups should use deepseek-v4-flash or deepseek-v4-pro directly.
The server is configured via environment variables. All settings except DEEPSEEK_API_KEY are optional.
| Variable | Default | Description |
|---|---|---|
DEEPSEEK_API_KEY | (required) | Your DeepSeek API key |
DEEPSEEK_BASE_URL | https://api.deepseek.com | Custom API endpoint |
DEFAULT_MODEL | deepseek-v4-flash | Default model for requests |
SHOW_COST_INFO | true | Show cost info in responses |
REQUEST_TIMEOUT | 60000 | Request timeout in milliseconds |
MAX_RETRIES | 2 | Maximum retry count for failed requests |
SKIP_CONNECTION_TEST | false | Skip startup API connection test |
MAX_MESSAGE_LENGTH | 100000 | Maximum message content length (characters) |
SESSION_TTL_MINUTES | 30 | Session time-to-live in minutes |
MAX_SESSIONS | 100 | Maximum number of concurrent sessions |
FALLBACK_ENABLED | true | Enable automatic model fallback on errors |
CIRCUIT_BREAKER_THRESHOLD | 5 | Consecutive failures before circuit opens |
CIRCUIT_BREAKER_RESET_TIMEOUT | 30000 | Milliseconds before circuit half-opens |
MAX_SESSION_MESSAGES | 200 | Max messages per session (sliding window) |
RESPONSE_SCHEMA_MAX_RETRIES | 2 | Repair retries when a response_schema validation fails (0 disables) |
ENABLE_MULTIMODAL | false | Enable multimodal (image) input support |
TRANSPORT | stdio | Transport mode: stdio or http |
HTTP_PORT | 3000 | HTTP server port (when TRANSPORT=http) |
HTTP_HOST | 127.0.0.1 | Bind address for HTTP transport. Loopback by default so a fresh run is not exposed. Set to 0.0.0.0 to accept remote connections (do this only with auth or a proxy in front) |
HTTP_AUTH_TOKEN | (unset) | When set, POST /mcp requires Authorization: Bearer <token>. /health stays open. Strongly recommended whenever the port is reachable beyond localhost |
HTTP_ALLOWED_HOSTS | (unset) | Comma-separated list of allowed Host headers for DNS rebinding protection when binding to 0.0.0.0 (e.g. mcp.example.com,localhost). The Docker image defaults it to localhost,127.0.0.1,[::1] |
HTTP_ALLOW_UNPROTECTED_BIND | false | Set to true to bind 0.0.0.0 with neither HTTP_ALLOWED_HOSTS nor HTTP_AUTH_TOKEN. The server otherwise refuses to start in that combination |
Example with custom config:
The server will start and wait for MCP client connections via stdio.
A hosted BYOK (Bring Your Own Key) endpoint is available at:
Send your DeepSeek API key as Authorization: Bearer <key>. No server-side API key stored — your key is used directly per request. Powered by Cloudflare Workers (global edge, zero cold start).
Note: Thinking mode may take over 30 seconds for complex queries. Some MCP clients (e.g. Claude Code) have built-in tool call timeouts that may interrupt long-running requests. When latency matters, the default non-thinking mode is recommended.
Run your own HTTP endpoint:
Test the health endpoint:
The MCP endpoint is available at POST /mcp (Streamable HTTP protocol).
Securing the endpoint (read before exposing it). In self-hosted HTTP mode the
server holds your DEEPSEEK_API_KEY and uses it for every deepseek_chat call.
Anyone who can reach POST /mcp can invoke tools and spend that key, so the
endpoint must not sit open on a public interface. The defaults are built around
this:
HTTP_HOST defaults to 127.0.0.1, so a plain run only listens on loopback and the SDK's DNS rebinding protection is active. Nothing off the machine can reach it.HTTP_HOST=0.0.0.0 and either HTTP_AUTH_TOKEN (so /mcp requires Authorization: Bearer <token>) or HTTP_ALLOWED_HOSTS. Binding 0.0.0.0 with neither turns the SDK's Host-header check off entirely, which leaves /mcp open to DNS rebinding from any web page you visit, so the server refuses to start rather than warn. HTTP_ALLOW_UNPROTECTED_BIND=true overrides the refusal if you really want an open endpoint.HTTP_ALLOWED_HOSTS to your real hostname(s).HTTP_AUTH_TOKEN is a static gateway token for the self-hosted endpoint and is
unrelated to your DeepSeek key. It is separate from the hosted BYOK endpoint
above, where clients pass their own DeepSeek key as the bearer.
Session isolation (1.7.0+): In HTTP transport each connected MCP session
gets its own McpServer instance and its own SessionStore. Conversation
history, session listings, and deletions are scoped to the MCP session that
created them, so one client cannot read, enumerate, or wipe another client's
sessions. STDIO transport is single-tenant by nature and unaffected.
The image runs HTTP transport on port 3000 with a health check. Inside the
container it binds 0.0.0.0 (required for the port mapping to work), so control
exposure at the publish layer: the example above and the bundled
docker-compose.yml publish to 127.0.0.1 only.
Publishing on loopback is not on its own enough, because DNS rebinding targets
the loopback address your own browser can already reach. The image therefore
ships HTTP_ALLOWED_HOSTS=localhost,127.0.0.1,[::1], which keeps the Host
check installed. Publishing under a real hostname? Add it to that list, or every
request carrying it gets a 403. Publishing on a public interface? Set
HTTP_AUTH_TOKEN as well.
Option 1: Use the correct installation command
Option 2: Manually edit the config file
If you already installed without the API key, edit your config file:
~/.claude.json (Windows: C:\Users\USERNAME\.claude.json)"mcpServers" section under your project pathenv field with your API key:dist/index.js is correctnpm run buildMake the file executable:
To share this MCP server with others:
npm loginnpm publish --access publicUsers can then install with:
Contributions are welcome! Please read our Contributing Guidelines before submitting PRs.
Found a bug or have a feature request? Please open an issue using our templates.
See CHANGELOG.md for version history and updates.
MIT License - see LICENSE file for details
Made by @arikusi
An independent, community-maintained MCP server for the DeepSeek API.