@arikusi/deepseek-mcp-server 1.8.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -2
- package/README.md +86 -35
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +7 -5
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +15 -10
- package/dist/cost.js.map +1 -1
- package/dist/deepseek-client.d.ts +30 -1
- package/dist/deepseek-client.d.ts.map +1 -1
- package/dist/deepseek-client.js +169 -35
- package/dist/deepseek-client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/prompts/advanced.js +3 -3
- package/dist/prompts/advanced.js.map +1 -1
- package/dist/resources/models.d.ts.map +1 -1
- package/dist/resources/models.js +29 -20
- package/dist/resources/models.js.map +1 -1
- package/dist/schemas.d.ts +39 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +28 -8
- package/dist/schemas.js.map +1 -1
- package/dist/tools/deepseek-chat.d.ts.map +1 -1
- package/dist/tools/deepseek-chat.js +31 -20
- package/dist/tools/deepseek-chat.js.map +1 -1
- package/dist/tools/deepseek-fim.d.ts +13 -0
- package/dist/tools/deepseek-fim.d.ts.map +1 -0
- package/dist/tools/deepseek-fim.js +153 -0
- package/dist/tools/deepseek-fim.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/types.d.ts +58 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.1.0] - 2026-07-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **`deepseek_fim` tool: Fill-in-the-Middle completion.** Provide a `prompt` (prefix) and an optional `suffix`; the model completes the text in between. Built for code completion and content infilling. Runs against DeepSeek's Beta completions endpoint in non-thinking mode, with output capped at 4096 tokens. Supports `model`, `max_tokens`, `temperature`, and `stop`, with the same cache-aware cost tracking as `deepseek_chat`. On the npm/stdio server it also reuses the circuit breaker and model fallback (v4-flash <-> v4-pro). The `deepseek-chat` / `deepseek-reasoner` aliases resolve to v4-flash since FIM has no thinking mode.
|
|
14
|
+
- `deepseek_fim` is available on both the npm/stdio server and the hosted worker endpoint (`deepseek-mcp.tahirl.com`), which was bumped to 2.1.0 in step.
|
|
15
|
+
- `fim` capability listed on both models in the `deepseek://models` resource.
|
|
16
|
+
|
|
17
|
+
## [2.0.0] - 2026-06-22
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- **DeepSeek V4 migration.** `deepseek-v4-flash` (new default) and `deepseek-v4-pro` are now the primary models, both with 1M context and up to 384K output tokens. `deepseek-chat` and `deepseek-reasoner` are kept as backward-compatible aliases that resolve to `deepseek-v4-flash` (chat maps to non-thinking, reasoner to thinking). The DeepSeek API retires those two names on 2026-07-24, so the server translates them before sending the request.
|
|
21
|
+
- **Default model is now `deepseek-v4-flash`** (was `deepseek-chat`). Direct v4 calls default to non-thinking for fast responses; enable reasoning with `thinking: {type: "enabled"}` or the `deepseek-reasoner` alias. The V4 API defaults thinking to enabled, so the server now always sends an explicit thinking flag.
|
|
22
|
+
- V4 pricing per 1M tokens: v4-flash `$0.0028` cache hit / `$0.14` cache miss / `$0.28` output; v4-pro `$0.003625` / `$0.435` / `$0.87`.
|
|
23
|
+
- `max_tokens` upper bound raised to 384000.
|
|
24
|
+
- Model fallback now pairs `deepseek-v4-flash` with `deepseek-v4-pro`.
|
|
25
|
+
- The hosted worker endpoint (`deepseek-mcp.tahirl.com`) was migrated to V4 as well.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- `reasoning_effort` parameter (`high` / `max`) for thinking mode.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- Declared `cost_usd` and `routed_from` in the `deepseek_chat` output schema. Strict MCP clients rejected every response under the SDK 1.29 structured-content validation because these fields were returned but not declared.
|
|
32
|
+
|
|
33
|
+
### Removed
|
|
34
|
+
- Stopped sending `frequency_penalty` / `presence_penalty`, which the V4 API deprecated and ignores.
|
|
35
|
+
|
|
10
36
|
## [1.8.0] - 2026-06-14
|
|
11
37
|
|
|
12
38
|
### Security
|
|
13
|
-
- **Missing authentication on the self-hosted HTTP endpoint.** In HTTP transport mode the server holds your `DEEPSEEK_API_KEY` and uses it for every `deepseek_chat` call, yet `POST /mcp` had no authentication and the server bound to `0.0.0.0`, so any client that could reach the port could initialize a session, enumerate tools, and invoke them. The defaults now bind to loopback and an optional bearer token guards the endpoint. Reported independently
|
|
39
|
+
- **Missing authentication on the self-hosted HTTP endpoint.** In HTTP transport mode the server holds your `DEEPSEEK_API_KEY` and uses it for every `deepseek_chat` call, yet `POST /mcp` had no authentication and the server bound to `0.0.0.0`, so any client that could reach the port could initialize a session, enumerate tools, and invoke them. The defaults now bind to loopback and an optional bearer token guards the endpoint. Reported independently. Tracked as CVE-2026-55605 (GHSA-72f3-6w86-7rv3).
|
|
14
40
|
|
|
15
41
|
### Changed
|
|
16
42
|
- HTTP transport now binds to `127.0.0.1` by default (configurable via `HTTP_HOST`). The SDK's DNS rebinding protection is active on loopback. Binding to `0.0.0.0` without a token prints a startup security warning.
|
|
@@ -29,7 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
29
55
|
## [1.7.0] - 2026-04-22
|
|
30
56
|
|
|
31
57
|
### Security
|
|
32
|
-
- **Cross-session data exposure in HTTP transport (high severity).** The `SessionStore` was a process-wide singleton shared across all connected HTTP clients. In HTTP transport mode, any client that provided another client's `session_id` to `deepseek_chat` would read that client's conversation history. The `deepseek_sessions` tool compounded this by letting any client enumerate all active session IDs (`list`), delete any session (`delete`), or wipe every tenant's sessions at once (`clear`). STDIO transport was unaffected because each STDIO client runs its own server process.
|
|
58
|
+
- **Cross-session data exposure in HTTP transport (high severity).** The `SessionStore` was a process-wide singleton shared across all connected HTTP clients. In HTTP transport mode, any client that provided another client's `session_id` to `deepseek_chat` would read that client's conversation history. The `deepseek_sessions` tool compounded this by letting any client enumerate all active session IDs (`list`), delete any session (`delete`), or wipe every tenant's sessions at once (`clear`). STDIO transport was unaffected because each STDIO client runs its own server process. Tracked as CVE-2026-55604 (GHSA-fh3r-g96v-f578).
|
|
33
59
|
|
|
34
60
|
### Changed
|
|
35
61
|
- **BREAKING (HTTP transport only).** Each HTTP session now gets an isolated `SessionStore` instance. Conversation history, session listings, and session deletion are scoped to the HTTP session that created them. Clients on the same server no longer share session state.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<h1 align="center">DeepSeek MCP Server</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
MCP server for DeepSeek
|
|
8
|
+
MCP server for DeepSeek V4 (v4-flash and v4-pro, 1M context) with multi-turn sessions, function calling, thinking mode, and cost tracking.
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
<a href="https://www.npmjs.com/package/@arikusi/deepseek-mcp-server"><img src="https://img.shields.io/npm/dm/@arikusi/deepseek-mcp-server.svg" alt="npm downloads" /></a>
|
|
14
14
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
|
|
15
15
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/@arikusi/deepseek-mcp-server.svg" alt="Node.js Version" /></a>
|
|
16
|
-
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-
|
|
16
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-6.0-blue.svg" alt="TypeScript" /></a>
|
|
17
|
+
<a href="https://api-docs.deepseek.com"><img src="https://img.shields.io/badge/DeepSeek-V4-7c3aed.svg" alt="DeepSeek V4" /></a>
|
|
17
18
|
<a href="https://github.com/arikusi/deepseek-mcp-server/actions"><img src="https://github.com/arikusi/deepseek-mcp-server/workflows/CI/badge.svg" alt="Build Status" /></a>
|
|
18
19
|
</p>
|
|
19
20
|
|
|
@@ -34,6 +35,8 @@
|
|
|
34
35
|
</a>
|
|
35
36
|
</p>
|
|
36
37
|
|
|
38
|
+
> **v2.0.0 runs on DeepSeek V4.** Two models, `deepseek-v4-flash` (fast and economical) and `deepseek-v4-pro` (top capability), both with a 1M-token context window and optional chain-of-thought thinking. Existing `deepseek-chat` and `deepseek-reasoner` setups keep working as aliases, so upgrading is drop-in.
|
|
39
|
+
|
|
37
40
|
## Quick Start
|
|
38
41
|
|
|
39
42
|
### Remote (No Install)
|
|
@@ -84,13 +87,14 @@ gemini mcp add deepseek npx @arikusi/deepseek-mcp-server -e DEEPSEEK_API_KEY=you
|
|
|
84
87
|
|
|
85
88
|
## Features
|
|
86
89
|
|
|
87
|
-
- **DeepSeek
|
|
90
|
+
- **DeepSeek V4**: `deepseek-v4-flash` and `deepseek-v4-pro`, both with 1M context and optional chain-of-thought thinking mode
|
|
88
91
|
- **Multi-Turn Sessions**: Conversation context preserved across requests via `session_id` parameter
|
|
89
92
|
- **Model Fallback & Circuit Breaker**: Automatic fallback between models with circuit breaker protection against cascading failures
|
|
90
93
|
- **MCP Resources**: `deepseek://models`, `deepseek://config`, `deepseek://usage` — query model info, config, and usage stats
|
|
91
94
|
- **Thinking Mode**: Enable thinking on deepseek-chat with `thinking: {type: "enabled"}`
|
|
92
95
|
- **JSON Output Mode**: Structured JSON responses with `json_mode: true`
|
|
93
96
|
- **Function Calling**: OpenAI-compatible tool use with up to 128 tool definitions
|
|
97
|
+
- **Fill-in-the-Middle (FIM)**: Code and content completion between a prefix and suffix via the `deepseek_fim` tool
|
|
94
98
|
- **Cache-Aware Cost Tracking**: Automatic cost calculation with cache hit/miss breakdown
|
|
95
99
|
- **Session Management Tool**: List, delete, and clear sessions via `deepseek_sessions` tool
|
|
96
100
|
- **Configurable**: Environment-based configuration with validation
|
|
@@ -100,7 +104,7 @@ gemini mcp add deepseek npx @arikusi/deepseek-mcp-server -e DEEPSEEK_API_KEY=you
|
|
|
100
104
|
- **Remote Endpoint**: Hosted at `deepseek-mcp.tahirl.com/mcp` — BYOK (Bring Your Own Key), no install needed
|
|
101
105
|
- **HTTP Transport**: Self-hosted remote access via Streamable HTTP with `TRANSPORT=http`
|
|
102
106
|
- **Docker Ready**: Multi-stage Dockerfile with health checks for containerized deployment
|
|
103
|
-
- **Tested**:
|
|
107
|
+
- **Tested**: 280 tests, ~89% line coverage
|
|
104
108
|
- **Type-Safe**: Full TypeScript implementation
|
|
105
109
|
- **MCP Compatible**: Works with any MCP-compatible CLI (Claude Code, Gemini CLI, etc.)
|
|
106
110
|
|
|
@@ -108,7 +112,7 @@ gemini mcp add deepseek npx @arikusi/deepseek-mcp-server -e DEEPSEEK_API_KEY=you
|
|
|
108
112
|
|
|
109
113
|
### Prerequisites
|
|
110
114
|
|
|
111
|
-
- Node.js
|
|
115
|
+
- Node.js 20+
|
|
112
116
|
- A DeepSeek API key (get one at [https://platform.deepseek.com](https://platform.deepseek.com))
|
|
113
117
|
|
|
114
118
|
### Manual Installation
|
|
@@ -142,7 +146,7 @@ npm run build
|
|
|
142
146
|
|
|
143
147
|
## Usage
|
|
144
148
|
|
|
145
|
-
Once configured, your MCP client will have access to `deepseek_chat` and `deepseek_sessions` tools, plus 3 MCP resources.
|
|
149
|
+
Once configured, your MCP client will have access to `deepseek_chat`, `deepseek_fim`, and `deepseek_sessions` tools, plus 3 MCP resources.
|
|
146
150
|
|
|
147
151
|
**Example prompts:**
|
|
148
152
|
```
|
|
@@ -186,13 +190,14 @@ Chat with DeepSeek AI models with automatic cost tracking and function calling s
|
|
|
186
190
|
- `role`: "system" | "user" | "assistant" | "tool"
|
|
187
191
|
- `content`: Message text
|
|
188
192
|
- `tool_call_id` (optional): Required for tool role messages
|
|
189
|
-
- `model` (optional): "deepseek-
|
|
193
|
+
- `model` (optional): "deepseek-v4-flash" (default) or "deepseek-v4-pro". "deepseek-chat" and "deepseek-reasoner" are accepted as aliases that resolve to v4-flash (non-thinking / thinking).
|
|
190
194
|
- `temperature` (optional): 0-2, controls randomness (default: 1.0). Ignored when thinking mode is enabled.
|
|
191
|
-
- `max_tokens` (optional): Maximum tokens to generate (
|
|
195
|
+
- `max_tokens` (optional): Maximum tokens to generate (V4 models support up to 384000)
|
|
192
196
|
- `stream` (optional): Enable streaming mode (default: false)
|
|
193
197
|
- `tools` (optional): Array of tool definitions for function calling (max 128)
|
|
194
198
|
- `tool_choice` (optional): "auto" | "none" | "required" | `{type: "function", function: {name: "..."}}`
|
|
195
|
-
- `thinking` (optional):
|
|
199
|
+
- `thinking` (optional): Toggle thinking mode, `{type: "enabled"}` to reason or `{type: "disabled"}` for a fast answer (non-thinking is the default)
|
|
200
|
+
- `reasoning_effort` (optional): "high" (default) or "max", applies only while thinking mode is active
|
|
196
201
|
- `json_mode` (optional): Enable JSON output mode (supported by both models)
|
|
197
202
|
- `session_id` (optional): Session ID for multi-turn conversations. Previous context is automatically prepended.
|
|
198
203
|
|
|
@@ -212,13 +217,13 @@ Chat with DeepSeek AI models with automatic cost tracking and function calling s
|
|
|
212
217
|
"content": "Explain the theory of relativity in simple terms"
|
|
213
218
|
}
|
|
214
219
|
],
|
|
215
|
-
"model": "deepseek-
|
|
220
|
+
"model": "deepseek-v4-flash",
|
|
216
221
|
"temperature": 0.7,
|
|
217
222
|
"max_tokens": 1000
|
|
218
223
|
}
|
|
219
224
|
```
|
|
220
225
|
|
|
221
|
-
**
|
|
226
|
+
**Reasoning Example (`deepseek-reasoner` alias, routes to v4-flash + thinking):**
|
|
222
227
|
|
|
223
228
|
```json
|
|
224
229
|
{
|
|
@@ -232,7 +237,22 @@ Chat with DeepSeek AI models with automatic cost tracking and function calling s
|
|
|
232
237
|
}
|
|
233
238
|
```
|
|
234
239
|
|
|
235
|
-
|
|
240
|
+
Thinking mode returns the chain-of-thought in `<thinking>` tags followed by the final answer.
|
|
241
|
+
|
|
242
|
+
**DeepSeek V4 Pro Example (hardest tasks):**
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"messages": [
|
|
247
|
+
{
|
|
248
|
+
"role": "user",
|
|
249
|
+
"content": "Prove that the square root of 2 is irrational."
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"model": "deepseek-v4-pro",
|
|
253
|
+
"thinking": { "type": "enabled" }
|
|
254
|
+
}
|
|
255
|
+
```
|
|
236
256
|
|
|
237
257
|
**Function Calling Example:**
|
|
238
258
|
|
|
@@ -279,12 +299,12 @@ When the model decides to call a function, the response includes `tool_calls` wi
|
|
|
279
299
|
"content": "Analyze the time complexity of quicksort"
|
|
280
300
|
}
|
|
281
301
|
],
|
|
282
|
-
"model": "deepseek-
|
|
302
|
+
"model": "deepseek-v4-flash",
|
|
283
303
|
"thinking": { "type": "enabled" }
|
|
284
304
|
}
|
|
285
305
|
```
|
|
286
306
|
|
|
287
|
-
When thinking mode is enabled, `temperature
|
|
307
|
+
When thinking mode is enabled, `temperature` and `top_p` are automatically ignored.
|
|
288
308
|
|
|
289
309
|
**JSON Output Mode Example:**
|
|
290
310
|
|
|
@@ -296,12 +316,12 @@ When thinking mode is enabled, `temperature`, `top_p`, `frequency_penalty`, and
|
|
|
296
316
|
"content": "Return a json object with name, age, and city fields for a sample user"
|
|
297
317
|
}
|
|
298
318
|
],
|
|
299
|
-
"model": "deepseek-
|
|
319
|
+
"model": "deepseek-v4-flash",
|
|
300
320
|
"json_mode": true
|
|
301
321
|
}
|
|
302
322
|
```
|
|
303
323
|
|
|
304
|
-
JSON mode ensures the model outputs valid JSON. Include the word "json" in your prompt for best results. Supported by
|
|
324
|
+
JSON mode ensures the model outputs valid JSON. Include the word "json" in your prompt for best results. Supported by all models.
|
|
305
325
|
|
|
306
326
|
**Multi-Turn Session Example:**
|
|
307
327
|
|
|
@@ -319,6 +339,37 @@ JSON mode ensures the model outputs valid JSON. Include the word "json" in your
|
|
|
319
339
|
|
|
320
340
|
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).
|
|
321
341
|
|
|
342
|
+
### `deepseek_fim`
|
|
343
|
+
|
|
344
|
+
Fill-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.
|
|
345
|
+
|
|
346
|
+
**Parameters:**
|
|
347
|
+
|
|
348
|
+
- `prompt` (required): The prefix text before the gap. For code completion, this is the code up to the cursor.
|
|
349
|
+
- `suffix` (optional): The text after the gap. The model fills the space between `prompt` and `suffix`.
|
|
350
|
+
- `model` (optional): "deepseek-v4-flash" (default) or "deepseek-v4-pro". The "deepseek-chat" and "deepseek-reasoner" aliases resolve to v4-flash (FIM has no thinking mode).
|
|
351
|
+
- `max_tokens` (optional): Maximum tokens to generate, up to 4096.
|
|
352
|
+
- `temperature` (optional): 0-2, controls randomness (default: 1.0).
|
|
353
|
+
- `stop` (optional): A stop string or an array of up to 16 stop strings.
|
|
354
|
+
|
|
355
|
+
**Response includes:**
|
|
356
|
+
- The completion text
|
|
357
|
+
- Request information (tokens, model, cost in USD)
|
|
358
|
+
- Structured data with `text`, `usage`, `finish_reason`, and `cost_usd` fields
|
|
359
|
+
|
|
360
|
+
**Example (code completion):**
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"prompt": "def fib(n):\n if n < 2:\n return n\n return ",
|
|
365
|
+
"suffix": "\n\nprint(fib(10))",
|
|
366
|
+
"model": "deepseek-v4-flash",
|
|
367
|
+
"max_tokens": 64
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
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.
|
|
372
|
+
|
|
322
373
|
### `deepseek_sessions`
|
|
323
374
|
|
|
324
375
|
Manage conversation sessions.
|
|
@@ -383,28 +434,27 @@ Each prompt is optimized for the DeepSeek Reasoner model to provide detailed rea
|
|
|
383
434
|
|
|
384
435
|
## Models
|
|
385
436
|
|
|
386
|
-
Both models
|
|
437
|
+
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"}` (or the `deepseek-reasoner` alias).
|
|
438
|
+
|
|
439
|
+
### deepseek-v4-flash (default)
|
|
440
|
+
|
|
441
|
+
- **Best for**: General conversations, coding, content generation, agent loops
|
|
442
|
+
- **Speed**: Fast and economical
|
|
443
|
+
- **Context**: 1M tokens
|
|
444
|
+
- **Max Output**: 384K tokens
|
|
445
|
+
- **Pricing**: $0.0028/1M cache hit, $0.14/1M cache miss, $0.28/1M output
|
|
387
446
|
|
|
388
|
-
### deepseek-
|
|
447
|
+
### deepseek-v4-pro
|
|
389
448
|
|
|
390
|
-
- **Best for**:
|
|
391
|
-
- **Speed**:
|
|
392
|
-
- **Context**:
|
|
393
|
-
- **Max Output**:
|
|
394
|
-
- **
|
|
395
|
-
- **Features**: Thinking mode, JSON mode, function calling, FIM completion
|
|
396
|
-
- **Pricing**: $0.028/1M cache hit, $0.28/1M cache miss, $0.42/1M output
|
|
449
|
+
- **Best for**: Complex reasoning, math, hard multi-step tasks, top-quality output
|
|
450
|
+
- **Speed**: Slower than flash, highest capability
|
|
451
|
+
- **Context**: 1M tokens
|
|
452
|
+
- **Max Output**: 384K tokens
|
|
453
|
+
- **Pricing**: $0.003625/1M cache hit, $0.435/1M cache miss, $0.87/1M output
|
|
397
454
|
|
|
398
|
-
###
|
|
455
|
+
### Compatibility aliases
|
|
399
456
|
|
|
400
|
-
-
|
|
401
|
-
- **Speed**: Slower (shows thinking process)
|
|
402
|
-
- **Context**: 128K tokens
|
|
403
|
-
- **Max Output**: 64K tokens (default 32K)
|
|
404
|
-
- **Mode**: Thinking (always active, chain-of-thought reasoning)
|
|
405
|
-
- **Features**: JSON mode, function calling
|
|
406
|
-
- **Output**: Both reasoning process and final answer
|
|
407
|
-
- **Pricing**: $0.028/1M cache hit, $0.28/1M cache miss, $0.42/1M output
|
|
457
|
+
`deepseek-chat` and `deepseek-reasoner` are still accepted and resolve to `deepseek-v4-flash` (chat = non-thinking, reasoner = thinking), so existing configs keep working. The DeepSeek API retires those two names on **2026-07-24**; this server translates them to V4 for you.
|
|
408
458
|
|
|
409
459
|
## Configuration
|
|
410
460
|
|
|
@@ -414,7 +464,7 @@ The server is configured via environment variables. All settings except `DEEPSEE
|
|
|
414
464
|
|----------|---------|-------------|
|
|
415
465
|
| `DEEPSEEK_API_KEY` | (required) | Your DeepSeek API key |
|
|
416
466
|
| `DEEPSEEK_BASE_URL` | `https://api.deepseek.com` | Custom API endpoint |
|
|
417
|
-
| `DEFAULT_MODEL` | `deepseek-
|
|
467
|
+
| `DEFAULT_MODEL` | `deepseek-v4-flash` | Default model for requests |
|
|
418
468
|
| `SHOW_COST_INFO` | `true` | Show cost info in responses |
|
|
419
469
|
| `REQUEST_TIMEOUT` | `60000` | Request timeout in milliseconds |
|
|
420
470
|
| `MAX_RETRIES` | `2` | Maximum retry count for failed requests |
|
|
@@ -466,6 +516,7 @@ deepseek-mcp-server/
|
|
|
466
516
|
│ ├── transport-http.ts # Streamable HTTP transport (Express)
|
|
467
517
|
│ ├── tools/
|
|
468
518
|
│ │ ├── deepseek-chat.ts # deepseek_chat tool (sessions + fallback)
|
|
519
|
+
│ │ ├── deepseek-fim.ts # deepseek_fim tool (fill-in-the-middle)
|
|
469
520
|
│ │ ├── deepseek-sessions.ts # deepseek_sessions tool
|
|
470
521
|
│ │ └── index.ts # Tool registration aggregator
|
|
471
522
|
│ ├── resources/
|
package/dist/config.js
CHANGED
|
@@ -15,7 +15,7 @@ const ConfigSchema = z.object({
|
|
|
15
15
|
sessionTtlMinutes: z.number().positive().default(30),
|
|
16
16
|
maxSessions: z.number().positive().default(100),
|
|
17
17
|
fallbackEnabled: z.boolean().default(true),
|
|
18
|
-
defaultModel: z.string().default('deepseek-
|
|
18
|
+
defaultModel: z.string().default('deepseek-v4-flash'),
|
|
19
19
|
circuitBreakerThreshold: z.number().positive().default(5),
|
|
20
20
|
circuitBreakerResetTimeout: z.number().positive().default(30000),
|
|
21
21
|
maxSessionMessages: z.number().positive().default(200),
|
|
@@ -54,7 +54,7 @@ export function loadConfig() {
|
|
|
54
54
|
? parseInt(process.env.MAX_SESSIONS, 10)
|
|
55
55
|
: 100,
|
|
56
56
|
fallbackEnabled: process.env.FALLBACK_ENABLED !== 'false',
|
|
57
|
-
defaultModel: process.env.DEFAULT_MODEL || 'deepseek-
|
|
57
|
+
defaultModel: process.env.DEFAULT_MODEL || 'deepseek-v4-flash',
|
|
58
58
|
circuitBreakerThreshold: process.env.CIRCUIT_BREAKER_THRESHOLD
|
|
59
59
|
? parseInt(process.env.CIRCUIT_BREAKER_THRESHOLD, 10)
|
|
60
60
|
: 5,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC;IACzD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,C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;IACzB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
package/dist/cost.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Cost Calculation Module
|
|
3
3
|
* Handles pricing and cost formatting for DeepSeek API requests
|
|
4
4
|
*
|
|
5
|
-
* Model-aware pricing per 1M tokens (USD):
|
|
6
|
-
* - deepseek-
|
|
7
|
-
* -
|
|
5
|
+
* Model-aware pricing per 1M tokens (USD), from the DeepSeek V4 pricing page:
|
|
6
|
+
* - deepseek-v4-flash: cache hit $0.0028, cache miss $0.14, output $0.28
|
|
7
|
+
* - deepseek-v4-pro: cache hit $0.003625, cache miss $0.435, output $0.87
|
|
8
|
+
* The deepseek-chat / deepseek-reasoner aliases resolve to deepseek-v4-flash,
|
|
9
|
+
* so they carry v4-flash pricing. New models can be added to MODEL_PRICING.
|
|
8
10
|
*/
|
|
9
11
|
/**
|
|
10
12
|
* Pricing structure for a model
|
|
@@ -14,7 +16,7 @@ export interface ModelPricing {
|
|
|
14
16
|
cache_miss: number;
|
|
15
17
|
output: number;
|
|
16
18
|
}
|
|
17
|
-
/**
|
|
19
|
+
/** v4-flash pricing — also the default for unknown models (cheapest, most common) */
|
|
18
20
|
export declare const DEFAULT_PRICING: ModelPricing;
|
|
19
21
|
/** Backward-compatible alias */
|
|
20
22
|
export declare const PRICING: ModelPricing;
|
|
@@ -36,7 +38,7 @@ export interface CostBreakdown {
|
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Calculate cost for a request based on token usage.
|
|
39
|
-
* Supports
|
|
41
|
+
* Supports cache hit/miss pricing. If cache fields are absent,
|
|
40
42
|
* treats all input tokens as cache miss (backward compatible).
|
|
41
43
|
*/
|
|
42
44
|
export declare function calculateCost(usage: {
|
package/dist/cost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../src/cost.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../src/cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qFAAqF;AACrF,eAAO,MAAM,eAAe,EAAE,YAI7B,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,OAAO,cAAkB,CAAC;AAEvC,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAMtD,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAKvD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CA8ChC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAqB3D"}
|
package/dist/cost.js
CHANGED
|
@@ -2,22 +2,27 @@
|
|
|
2
2
|
* Cost Calculation Module
|
|
3
3
|
* Handles pricing and cost formatting for DeepSeek API requests
|
|
4
4
|
*
|
|
5
|
-
* Model-aware pricing per 1M tokens (USD):
|
|
6
|
-
* - deepseek-
|
|
7
|
-
* -
|
|
5
|
+
* Model-aware pricing per 1M tokens (USD), from the DeepSeek V4 pricing page:
|
|
6
|
+
* - deepseek-v4-flash: cache hit $0.0028, cache miss $0.14, output $0.28
|
|
7
|
+
* - deepseek-v4-pro: cache hit $0.003625, cache miss $0.435, output $0.87
|
|
8
|
+
* The deepseek-chat / deepseek-reasoner aliases resolve to deepseek-v4-flash,
|
|
9
|
+
* so they carry v4-flash pricing. New models can be added to MODEL_PRICING.
|
|
8
10
|
*/
|
|
9
|
-
/**
|
|
11
|
+
/** v4-flash pricing — also the default for unknown models (cheapest, most common) */
|
|
10
12
|
export const DEFAULT_PRICING = {
|
|
11
|
-
cache_hit: 0.
|
|
12
|
-
cache_miss: 0.
|
|
13
|
-
output: 0.
|
|
13
|
+
cache_hit: 0.0028,
|
|
14
|
+
cache_miss: 0.14,
|
|
15
|
+
output: 0.28,
|
|
14
16
|
};
|
|
15
17
|
/** Backward-compatible alias */
|
|
16
18
|
export const PRICING = DEFAULT_PRICING;
|
|
17
19
|
/** Per-model pricing map. Add new models here as they become available. */
|
|
18
20
|
export const MODEL_PRICING = {
|
|
19
|
-
'deepseek-
|
|
20
|
-
'deepseek-
|
|
21
|
+
'deepseek-v4-flash': { cache_hit: 0.0028, cache_miss: 0.14, output: 0.28 },
|
|
22
|
+
'deepseek-v4-pro': { cache_hit: 0.003625, cache_miss: 0.435, output: 0.87 },
|
|
23
|
+
// Compatibility aliases (resolve to v4-flash on the wire)
|
|
24
|
+
'deepseek-chat': { cache_hit: 0.0028, cache_miss: 0.14, output: 0.28 },
|
|
25
|
+
'deepseek-reasoner': { cache_hit: 0.0028, cache_miss: 0.14, output: 0.28 },
|
|
21
26
|
};
|
|
22
27
|
/**
|
|
23
28
|
* Get pricing for a specific model. Falls back to DEFAULT_PRICING for unknown models.
|
|
@@ -30,7 +35,7 @@ export function getPricing(model) {
|
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Calculate cost for a request based on token usage.
|
|
33
|
-
* Supports
|
|
38
|
+
* Supports cache hit/miss pricing. If cache fields are absent,
|
|
34
39
|
* treats all input tokens as cache miss (backward compatible).
|
|
35
40
|
*/
|
|
36
41
|
export function calculateCost(usage, model) {
|
package/dist/cost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../src/cost.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../src/cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,qFAAqF;AACrF,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,gCAAgC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAiC;IACzD,mBAAmB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1E,iBAAiB,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;IAC3E,0DAA0D;IAC1D,eAAe,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACtE,mBAAmB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;CAC3E,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,IAAI,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,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AAiB,CAAC;IAEtB,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;QAChB,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,CAAC;IAED,IACE,SAAS,CAAC,aAAa,KAAK,SAAS;QACrC,SAAS,CAAC,aAAa,GAAG,CAAC;QAC3B,SAAS,CAAC,YAAY,KAAK,SAAS;QACpC,SAAS,CAAC,YAAY,GAAG,CAAC,EAC1B,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC;QACtD,SAAS,IAAI,gBAAgB,GAAG,cAAc,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACrF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -3,17 +3,27 @@
|
|
|
3
3
|
* Wrapper around OpenAI SDK for DeepSeek API
|
|
4
4
|
* Features: circuit breaker protection, automatic model fallback
|
|
5
5
|
*/
|
|
6
|
-
import type { ChatCompletionParams, ChatCompletionResponse, CircuitBreakerStatus, FallbackInfo } from './types.js';
|
|
6
|
+
import type { ChatCompletionParams, ChatCompletionResponse, CircuitBreakerStatus, FallbackInfo, FimCompletionParams, FimCompletionResponse } from './types.js';
|
|
7
7
|
/** Extended response with optional fallback info */
|
|
8
8
|
export interface ChatCompletionResponseWithFallback extends ChatCompletionResponse {
|
|
9
9
|
fallback?: FallbackInfo;
|
|
10
10
|
}
|
|
11
11
|
export declare class DeepSeekClient {
|
|
12
12
|
private client;
|
|
13
|
+
private betaClient;
|
|
14
|
+
private betaBaseUrl;
|
|
15
|
+
private apiKey;
|
|
16
|
+
private requestTimeout;
|
|
17
|
+
private maxRetries;
|
|
13
18
|
private circuitBreakers;
|
|
14
19
|
private cbThreshold;
|
|
15
20
|
private cbResetTimeout;
|
|
16
21
|
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Lazily build the Beta-endpoint client. Only FIM needs it, so most
|
|
24
|
+
* sessions never pay for a second client instance.
|
|
25
|
+
*/
|
|
26
|
+
private getBetaClient;
|
|
17
27
|
/**
|
|
18
28
|
* Get or create a circuit breaker for a specific model
|
|
19
29
|
*/
|
|
@@ -34,6 +44,25 @@ export declare class DeepSeekClient {
|
|
|
34
44
|
* Parse raw API response into ChatCompletionResponse
|
|
35
45
|
*/
|
|
36
46
|
private parseResponse;
|
|
47
|
+
/**
|
|
48
|
+
* Parse a raw Beta /completions response into FimCompletionResponse.
|
|
49
|
+
*/
|
|
50
|
+
private parseCompletionResponse;
|
|
51
|
+
/**
|
|
52
|
+
* Build the wire params for a FIM request.
|
|
53
|
+
*/
|
|
54
|
+
private buildFimRequestParams;
|
|
55
|
+
/**
|
|
56
|
+
* Perform a single FIM call against the Beta endpoint.
|
|
57
|
+
*/
|
|
58
|
+
private fimInternal;
|
|
59
|
+
/**
|
|
60
|
+
* Create a FIM (Fill-in-the-Middle) completion with circuit breaker and
|
|
61
|
+
* automatic model fallback, mirroring the chat-completion resilience path.
|
|
62
|
+
*/
|
|
63
|
+
createFimCompletion(params: FimCompletionParams): Promise<FimCompletionResponse & {
|
|
64
|
+
fallback?: FallbackInfo;
|
|
65
|
+
}>;
|
|
37
66
|
/**
|
|
38
67
|
* Create a chat completion (non-streaming) with circuit breaker and fallback
|
|
39
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-client.d.ts","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"deepseek-client.d.ts","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;;GA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