@arikusi/deepseek-mcp-server 1.1.1 → 1.2.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 +20 -1
- package/README.md +56 -11
- package/dist/cost.d.ts +30 -13
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +58 -19
- package/dist/cost.js.map +1 -1
- package/dist/deepseek-client.d.ts.map +1 -1
- package/dist/deepseek-client.js +44 -5
- package/dist/deepseek-client.js.map +1 -1
- package/dist/schemas.d.ts +59 -20
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +9 -2
- package/dist/schemas.js.map +1 -1
- package/dist/tools/deepseek-chat.d.ts +1 -1
- package/dist/tools/deepseek-chat.d.ts.map +1 -1
- package/dist/tools/deepseek-chat.js +52 -30
- package/dist/tools/deepseek-chat.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
16
|
### Fixed
|
|
17
17
|
- Nothing yet
|
|
18
18
|
|
|
19
|
+
## [1.2.0] - 2026-02-26
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **Thinking Mode**: Enable enhanced reasoning on deepseek-chat with `thinking: {type: "enabled"}` parameter. Automatically filters incompatible params (temperature, top_p, etc.) with logged warnings.
|
|
23
|
+
- **JSON Output Mode**: Structured JSON responses with `json_mode: true`. Supported by both models. Warns if "json" word missing from prompt.
|
|
24
|
+
- **Cache-Aware Cost Tracking**: V3.2 API returns `prompt_cache_hit_tokens` and `prompt_cache_miss_tokens`. Cost display now shows cache hit ratio and savings.
|
|
25
|
+
- **CostBreakdown Interface**: `calculateCost()` returns structured `{inputCost, outputCost, totalCost, cacheHitRatio?, cacheSavings?}` instead of flat number.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- **DeepSeek V3.2 Pricing**: Unified pricing for both models — cache hit $0.028/1M, cache miss $0.28/1M, output $0.42/1M (replaces old per-model pricing).
|
|
29
|
+
- **max_tokens Limit**: Updated from 32768 to 65536 (reasoner max). Model-specific warnings: deepseek-chat warns above 8192, deepseek-reasoner warns above 65536.
|
|
30
|
+
- **Tool Description**: Updated to mention V3.2, thinking mode, JSON mode, and cache-aware cost tracking.
|
|
31
|
+
- **150 Tests**: Up from 126, covering thinking mode, JSON mode, cache tokens, and cost breakdown.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- **Incorrect Cost Reports**: Old flat pricing ($0.14/$0.28 chat, $0.55/$2.19 reasoner) replaced with accurate V3.2 unified pricing.
|
|
35
|
+
|
|
19
36
|
## [1.1.1] - 2026-02-11
|
|
20
37
|
|
|
21
38
|
### Added
|
|
@@ -154,6 +171,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
154
171
|
|
|
155
172
|
## Version History
|
|
156
173
|
|
|
174
|
+
- **1.2.0** (2026-02-26): DeepSeek V3.2 support — thinking mode, JSON mode, cache-aware pricing, 150 tests
|
|
157
175
|
- **1.1.1** (2026-02-11): Modular architecture, type safety, security fixes, 126 tests
|
|
158
176
|
- **1.1.0** (2026-02-10): Function calling, config system, test suite
|
|
159
177
|
- **1.0.3** (2025-02-07): Cost tracking and prompt templates
|
|
@@ -166,7 +184,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
166
184
|
- [GitHub repository](https://github.com/arikusi/deepseek-mcp-server)
|
|
167
185
|
- [Issue tracker](https://github.com/arikusi/deepseek-mcp-server/issues)
|
|
168
186
|
|
|
169
|
-
[Unreleased]: https://github.com/arikusi/deepseek-mcp-server/compare/v1.
|
|
187
|
+
[Unreleased]: https://github.com/arikusi/deepseek-mcp-server/compare/v1.2.0...HEAD
|
|
188
|
+
[1.2.0]: https://github.com/arikusi/deepseek-mcp-server/compare/v1.1.1...v1.2.0
|
|
170
189
|
[1.1.1]: https://github.com/arikusi/deepseek-mcp-server/compare/v1.1.0...v1.1.1
|
|
171
190
|
[1.1.0]: https://github.com/arikusi/deepseek-mcp-server/compare/v1.0.3...v1.1.0
|
|
172
191
|
[1.0.3]: https://github.com/arikusi/deepseek-mcp-server/releases/tag/v1.0.3
|
package/README.md
CHANGED
|
@@ -48,14 +48,15 @@ That's it! Your MCP client can now use DeepSeek models!
|
|
|
48
48
|
|
|
49
49
|
## Features
|
|
50
50
|
|
|
51
|
-
- **DeepSeek
|
|
52
|
-
- **
|
|
51
|
+
- **DeepSeek V3.2**: Both models now run DeepSeek-V3.2 (since Sept 2025)
|
|
52
|
+
- **Thinking Mode**: Enable enhanced reasoning on deepseek-chat with `thinking: {type: "enabled"}`
|
|
53
|
+
- **JSON Output Mode**: Structured JSON responses with `json_mode: true`
|
|
53
54
|
- **Function Calling**: OpenAI-compatible tool use with up to 128 tool definitions
|
|
54
|
-
- **Cost Tracking**: Automatic cost calculation
|
|
55
|
+
- **Cache-Aware Cost Tracking**: Automatic cost calculation with cache hit/miss breakdown
|
|
55
56
|
- **Configurable**: Environment-based configuration with validation
|
|
56
57
|
- **12 Prompt Templates**: Pre-built templates for debugging, code review, function calling, and more
|
|
57
58
|
- **Streaming Support**: Real-time response generation
|
|
58
|
-
- **Tested**:
|
|
59
|
+
- **Tested**: 150 tests with 90%+ code coverage
|
|
59
60
|
- **Type-Safe**: Full TypeScript implementation
|
|
60
61
|
- **MCP Compatible**: Works with any MCP-compatible CLI (Claude Code, Gemini CLI, etc.)
|
|
61
62
|
|
|
@@ -142,11 +143,13 @@ Chat with DeepSeek AI models with automatic cost tracking and function calling s
|
|
|
142
143
|
- `content`: Message text
|
|
143
144
|
- `tool_call_id` (optional): Required for tool role messages
|
|
144
145
|
- `model` (optional): "deepseek-chat" (default) or "deepseek-reasoner"
|
|
145
|
-
- `temperature` (optional): 0-2, controls randomness (default: 1.0)
|
|
146
|
-
- `max_tokens` (optional): Maximum tokens to generate
|
|
146
|
+
- `temperature` (optional): 0-2, controls randomness (default: 1.0). Ignored when thinking mode is enabled.
|
|
147
|
+
- `max_tokens` (optional): Maximum tokens to generate (deepseek-chat: max 8192, deepseek-reasoner: max 65536)
|
|
147
148
|
- `stream` (optional): Enable streaming mode (default: false)
|
|
148
149
|
- `tools` (optional): Array of tool definitions for function calling (max 128)
|
|
149
150
|
- `tool_choice` (optional): "auto" | "none" | "required" | `{type: "function", function: {name: "..."}}`
|
|
151
|
+
- `thinking` (optional): Enable thinking mode `{type: "enabled"}` for enhanced reasoning
|
|
152
|
+
- `json_mode` (optional): Enable JSON output mode (supported by both models)
|
|
150
153
|
|
|
151
154
|
**Response includes:**
|
|
152
155
|
- Content with formatting
|
|
@@ -221,6 +224,40 @@ The reasoner model will show its thinking process in `<thinking>` tags followed
|
|
|
221
224
|
|
|
222
225
|
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`.
|
|
223
226
|
|
|
227
|
+
**Thinking Mode Example:**
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"messages": [
|
|
232
|
+
{
|
|
233
|
+
"role": "user",
|
|
234
|
+
"content": "Analyze the time complexity of quicksort"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"model": "deepseek-chat",
|
|
238
|
+
"thinking": { "type": "enabled" }
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
When thinking mode is enabled, `temperature`, `top_p`, `frequency_penalty`, and `presence_penalty` are automatically ignored. The model provides enhanced reasoning capabilities similar to deepseek-reasoner.
|
|
243
|
+
|
|
244
|
+
**JSON Output Mode Example:**
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"messages": [
|
|
249
|
+
{
|
|
250
|
+
"role": "user",
|
|
251
|
+
"content": "Return a json object with name, age, and city fields for a sample user"
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"model": "deepseek-chat",
|
|
255
|
+
"json_mode": true
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
JSON mode ensures the model outputs valid JSON. Include the word "json" in your prompt for best results. Supported by both `deepseek-chat` and `deepseek-reasoner`.
|
|
260
|
+
|
|
224
261
|
## Available Prompts
|
|
225
262
|
|
|
226
263
|
Pre-built prompt templates for common tasks (12 total):
|
|
@@ -247,20 +284,28 @@ Each prompt is optimized for the DeepSeek Reasoner model to provide detailed rea
|
|
|
247
284
|
|
|
248
285
|
## Models
|
|
249
286
|
|
|
287
|
+
Both models run **DeepSeek-V3.2** with unified pricing.
|
|
288
|
+
|
|
250
289
|
### deepseek-chat
|
|
251
290
|
|
|
252
291
|
- **Best for**: General conversations, coding, content generation
|
|
253
292
|
- **Speed**: Fast
|
|
254
|
-
- **Context**:
|
|
255
|
-
- **
|
|
293
|
+
- **Context**: 128K tokens
|
|
294
|
+
- **Max Output**: 8K tokens (default 4K)
|
|
295
|
+
- **Mode**: Non-thinking (can enable thinking via parameter)
|
|
296
|
+
- **Features**: Thinking mode, JSON mode, function calling, FIM completion
|
|
297
|
+
- **Pricing**: $0.028/1M cache hit, $0.28/1M cache miss, $0.42/1M output
|
|
256
298
|
|
|
257
|
-
### deepseek-reasoner
|
|
299
|
+
### deepseek-reasoner
|
|
258
300
|
|
|
259
301
|
- **Best for**: Complex reasoning, math, logic problems, multi-step tasks
|
|
260
302
|
- **Speed**: Slower (shows thinking process)
|
|
261
|
-
- **Context**:
|
|
262
|
-
- **
|
|
303
|
+
- **Context**: 128K tokens
|
|
304
|
+
- **Max Output**: 64K tokens (default 32K)
|
|
305
|
+
- **Mode**: Thinking (always active, chain-of-thought reasoning)
|
|
306
|
+
- **Features**: JSON mode, function calling
|
|
263
307
|
- **Output**: Both reasoning process and final answer
|
|
308
|
+
- **Pricing**: $0.028/1M cache hit, $0.28/1M cache miss, $0.42/1M output
|
|
264
309
|
|
|
265
310
|
## Configuration
|
|
266
311
|
|
package/dist/cost.d.ts
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cost Calculation Module
|
|
3
3
|
* Handles pricing and cost formatting for DeepSeek API requests
|
|
4
|
+
*
|
|
5
|
+
* DeepSeek V3.2 unified pricing (both deepseek-chat and deepseek-reasoner):
|
|
6
|
+
* - Cache hit input: $0.028/1M tokens
|
|
7
|
+
* - Cache miss input: $0.28/1M tokens
|
|
8
|
+
* - Output: $0.42/1M tokens
|
|
4
9
|
*/
|
|
5
|
-
/** DeepSeek pricing per 1M tokens (USD) */
|
|
10
|
+
/** DeepSeek V3.2 unified pricing per 1M tokens (USD) */
|
|
6
11
|
export declare const PRICING: {
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
readonly 'deepseek-reasoner': {
|
|
12
|
-
readonly prompt: 0.55;
|
|
13
|
-
readonly completion: 2.19;
|
|
14
|
-
};
|
|
12
|
+
readonly cache_hit: 0.028;
|
|
13
|
+
readonly cache_miss: 0.28;
|
|
14
|
+
readonly output: 0.42;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Cost breakdown for a request
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export interface CostBreakdown {
|
|
20
|
+
inputCost: number;
|
|
21
|
+
outputCost: number;
|
|
22
|
+
totalCost: number;
|
|
23
|
+
cacheHitRatio?: number;
|
|
24
|
+
cacheSavings?: number;
|
|
25
|
+
}
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
27
|
+
* Calculate cost for a request based on token usage.
|
|
28
|
+
* Supports V3.2 cache hit/miss pricing. If cache fields are absent,
|
|
29
|
+
* treats all input tokens as cache miss (backward compatible).
|
|
22
30
|
*/
|
|
23
|
-
export declare function
|
|
31
|
+
export declare function calculateCost(usage: {
|
|
32
|
+
prompt_tokens: number;
|
|
33
|
+
completion_tokens: number;
|
|
34
|
+
prompt_cache_hit_tokens?: number;
|
|
35
|
+
prompt_cache_miss_tokens?: number;
|
|
36
|
+
}): CostBreakdown;
|
|
37
|
+
/**
|
|
38
|
+
* Format cost as readable USD string with optional cache savings info
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatCost(breakdown: CostBreakdown): string;
|
|
24
41
|
//# sourceMappingURL=cost.d.ts.map
|
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;;;;;;;;GAQG;AAEH,wDAAwD;AACxD,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX;;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,GAAG,aAAa,CA4ChB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAqB3D"}
|
package/dist/cost.js
CHANGED
|
@@ -1,34 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cost Calculation Module
|
|
3
3
|
* Handles pricing and cost formatting for DeepSeek API requests
|
|
4
|
+
*
|
|
5
|
+
* DeepSeek V3.2 unified pricing (both deepseek-chat and deepseek-reasoner):
|
|
6
|
+
* - Cache hit input: $0.028/1M tokens
|
|
7
|
+
* - Cache miss input: $0.28/1M tokens
|
|
8
|
+
* - Output: $0.42/1M tokens
|
|
4
9
|
*/
|
|
5
|
-
/** DeepSeek pricing per 1M tokens (USD) */
|
|
10
|
+
/** DeepSeek V3.2 unified pricing per 1M tokens (USD) */
|
|
6
11
|
export const PRICING = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
'deepseek-reasoner': {
|
|
12
|
-
prompt: 0.55,
|
|
13
|
-
completion: 2.19,
|
|
14
|
-
},
|
|
12
|
+
cache_hit: 0.028,
|
|
13
|
+
cache_miss: 0.28,
|
|
14
|
+
output: 0.42,
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Calculate cost for a request based on token usage
|
|
17
|
+
* Calculate cost for a request based on token usage.
|
|
18
|
+
* Supports V3.2 cache hit/miss pricing. If cache fields are absent,
|
|
19
|
+
* treats all input tokens as cache miss (backward compatible).
|
|
18
20
|
*/
|
|
19
|
-
export function calculateCost(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export function calculateCost(usage) {
|
|
22
|
+
const { prompt_tokens, completion_tokens, prompt_cache_hit_tokens, prompt_cache_miss_tokens, } = usage;
|
|
23
|
+
let inputCost;
|
|
24
|
+
let cacheHitRatio;
|
|
25
|
+
let cacheSavings;
|
|
26
|
+
if (prompt_cache_hit_tokens !== undefined &&
|
|
27
|
+
prompt_cache_miss_tokens !== undefined) {
|
|
28
|
+
// V3.2 cache-aware pricing
|
|
29
|
+
const hitCost = (prompt_cache_hit_tokens / 1_000_000) * PRICING.cache_hit;
|
|
30
|
+
const missCost = (prompt_cache_miss_tokens / 1_000_000) * PRICING.cache_miss;
|
|
31
|
+
inputCost = hitCost + missCost;
|
|
32
|
+
if (prompt_tokens > 0) {
|
|
33
|
+
cacheHitRatio = prompt_cache_hit_tokens / prompt_tokens;
|
|
34
|
+
}
|
|
35
|
+
// Savings = what all-miss would cost minus actual cost
|
|
36
|
+
const allMissCost = (prompt_tokens / 1_000_000) * PRICING.cache_miss;
|
|
37
|
+
cacheSavings = allMissCost - inputCost;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Backward compatible: treat all input as cache miss
|
|
41
|
+
inputCost = (prompt_tokens / 1_000_000) * PRICING.cache_miss;
|
|
42
|
+
}
|
|
43
|
+
const outputCost = (completion_tokens / 1_000_000) * PRICING.output;
|
|
44
|
+
return {
|
|
45
|
+
inputCost,
|
|
46
|
+
outputCost,
|
|
47
|
+
totalCost: inputCost + outputCost,
|
|
48
|
+
cacheHitRatio,
|
|
49
|
+
cacheSavings,
|
|
50
|
+
};
|
|
24
51
|
}
|
|
25
52
|
/**
|
|
26
|
-
* Format cost as readable USD string
|
|
53
|
+
* Format cost as readable USD string with optional cache savings info
|
|
27
54
|
*/
|
|
28
|
-
export function formatCost(
|
|
55
|
+
export function formatCost(breakdown) {
|
|
56
|
+
const cost = breakdown.totalCost;
|
|
57
|
+
let formatted;
|
|
29
58
|
if (cost < 0.01) {
|
|
30
|
-
|
|
59
|
+
formatted = `$${cost.toFixed(4)}`;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
formatted = `$${cost.toFixed(2)}`;
|
|
63
|
+
}
|
|
64
|
+
if (breakdown.cacheHitRatio !== undefined &&
|
|
65
|
+
breakdown.cacheHitRatio > 0 &&
|
|
66
|
+
breakdown.cacheSavings !== undefined &&
|
|
67
|
+
breakdown.cacheSavings > 0) {
|
|
68
|
+
const pct = Math.round(breakdown.cacheHitRatio * 100);
|
|
69
|
+
formatted += ` (cache hit: ${pct}%, saved ~$${breakdown.cacheSavings.toFixed(4)})`;
|
|
31
70
|
}
|
|
32
|
-
return
|
|
71
|
+
return formatted;
|
|
33
72
|
}
|
|
34
73
|
//# sourceMappingURL=cost.js.map
|
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;;;;;;;;GAQG;AAEH,wDAAwD;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;CACJ,CAAC;AAaX;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAK7B;IACC,MAAM,EACJ,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,GACzB,GAAG,KAAK,CAAC;IAEV,IAAI,SAAiB,CAAC;IACtB,IAAI,aAAiC,CAAC;IACtC,IAAI,YAAgC,CAAC;IAErC,IACE,uBAAuB,KAAK,SAAS;QACrC,wBAAwB,KAAK,SAAS,EACtC,CAAC;QACD,2BAA2B;QAC3B,MAAM,OAAO,GACX,CAAC,uBAAuB,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;QAC5D,MAAM,QAAQ,GACZ,CAAC,wBAAwB,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;QAC9D,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;QAE/B,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YACtB,aAAa,GAAG,uBAAuB,GAAG,aAAa,CAAC;QAC1D,CAAC;QAED,uDAAuD;QACvD,MAAM,WAAW,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;QACrE,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,qDAAqD;QACrD,SAAS,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/D,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAEpE,OAAO;QACL,SAAS;QACT,UAAU;QACV,SAAS,EAAE,SAAS,GAAG,UAAU;QACjC,aAAa;QACb,YAAY;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,SAAwB;IACjD,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC;IACjC,IAAI,SAAiB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-client.d.ts","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EAKvB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"deepseek-client.d.ts","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EAKvB,MAAM,YAAY,CAAC;AAWpB,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;;IAavB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyD1B;;OAEG;IACH,OAAO,CAAC,SAAS;IAOjB;;OAEG;IACG,oBAAoB,CACxB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IA+ClC;;;OAGG;IACG,6BAA6B,CACjC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IA0GlC;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;CAazC"}
|
package/dist/deepseek-client.js
CHANGED
|
@@ -6,6 +6,13 @@ import OpenAI from 'openai';
|
|
|
6
6
|
import { getConfig } from './config.js';
|
|
7
7
|
import { ApiError } from './errors.js';
|
|
8
8
|
import { hasReasoningContent, getErrorMessage } from './types.js';
|
|
9
|
+
/** Parameters that are incompatible with thinking mode */
|
|
10
|
+
const THINKING_INCOMPATIBLE_PARAMS = [
|
|
11
|
+
'temperature',
|
|
12
|
+
'top_p',
|
|
13
|
+
'frequency_penalty',
|
|
14
|
+
'presence_penalty',
|
|
15
|
+
];
|
|
9
16
|
export class DeepSeekClient {
|
|
10
17
|
client;
|
|
11
18
|
constructor() {
|
|
@@ -21,17 +28,41 @@ export class DeepSeekClient {
|
|
|
21
28
|
* Build request params shared between streaming and non-streaming
|
|
22
29
|
*/
|
|
23
30
|
buildRequestParams(params, stream) {
|
|
31
|
+
const isThinkingEnabled = params.thinking?.type === 'enabled';
|
|
32
|
+
// Filter incompatible params when thinking mode is active
|
|
33
|
+
if (isThinkingEnabled) {
|
|
34
|
+
const filtered = [];
|
|
35
|
+
for (const key of THINKING_INCOMPATIBLE_PARAMS) {
|
|
36
|
+
if (params[key] !== undefined) {
|
|
37
|
+
filtered.push(key);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (filtered.length > 0) {
|
|
41
|
+
console.error(`[DeepSeek MCP] Warning: Thinking mode active, ignoring incompatible params: ${filtered.join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
const requestParams = {
|
|
25
45
|
model: params.model,
|
|
26
46
|
messages: params.messages,
|
|
27
|
-
temperature: params.temperature ?? 1.0,
|
|
47
|
+
temperature: isThinkingEnabled ? undefined : (params.temperature ?? 1.0),
|
|
28
48
|
max_tokens: params.max_tokens,
|
|
29
|
-
top_p: params.top_p,
|
|
30
|
-
frequency_penalty: params.frequency_penalty,
|
|
31
|
-
presence_penalty: params.presence_penalty,
|
|
49
|
+
top_p: isThinkingEnabled ? undefined : params.top_p,
|
|
50
|
+
frequency_penalty: isThinkingEnabled ? undefined : params.frequency_penalty,
|
|
51
|
+
presence_penalty: isThinkingEnabled ? undefined : params.presence_penalty,
|
|
32
52
|
stop: params.stop,
|
|
33
53
|
stream,
|
|
34
54
|
};
|
|
55
|
+
// Pass thinking config via extra_body (DeepSeek extension)
|
|
56
|
+
if (params.thinking) {
|
|
57
|
+
requestParams.extra_body = {
|
|
58
|
+
...requestParams.extra_body,
|
|
59
|
+
thinking: params.thinking,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Pass response_format for JSON mode
|
|
63
|
+
if (params.response_format) {
|
|
64
|
+
requestParams.response_format = params.response_format;
|
|
65
|
+
}
|
|
35
66
|
if (params.tools?.length) {
|
|
36
67
|
requestParams.tools = params.tools;
|
|
37
68
|
}
|
|
@@ -85,6 +116,8 @@ export class DeepSeekClient {
|
|
|
85
116
|
prompt_tokens: response.usage?.prompt_tokens || 0,
|
|
86
117
|
completion_tokens: response.usage?.completion_tokens || 0,
|
|
87
118
|
total_tokens: response.usage?.total_tokens || 0,
|
|
119
|
+
prompt_cache_hit_tokens: response.usage?.prompt_cache_hit_tokens,
|
|
120
|
+
prompt_cache_miss_tokens: response.usage?.prompt_cache_miss_tokens,
|
|
88
121
|
},
|
|
89
122
|
finish_reason: choice.finish_reason || 'stop',
|
|
90
123
|
tool_calls: tool_calls?.length ? tool_calls : undefined,
|
|
@@ -160,7 +193,13 @@ export class DeepSeekClient {
|
|
|
160
193
|
}
|
|
161
194
|
// Get usage info (usually in last chunk)
|
|
162
195
|
if (chunk.usage) {
|
|
163
|
-
usage =
|
|
196
|
+
usage = {
|
|
197
|
+
prompt_tokens: chunk.usage.prompt_tokens,
|
|
198
|
+
completion_tokens: chunk.usage.completion_tokens,
|
|
199
|
+
total_tokens: chunk.usage.total_tokens,
|
|
200
|
+
prompt_cache_hit_tokens: chunk.usage.prompt_cache_hit_tokens,
|
|
201
|
+
prompt_cache_miss_tokens: chunk.usage.prompt_cache_miss_tokens,
|
|
202
|
+
};
|
|
164
203
|
}
|
|
165
204
|
}
|
|
166
205
|
// Convert tool calls map to sorted array
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-client.js","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AASxD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,OAAO,cAAc;IACjB,MAAM,CAAS;IAEvB;QACE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,cAAc;YAC9B,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,kBAAkB,CACxB,MAA4B,EAC5B,MAAe;QAEf,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"deepseek-client.js","sourceRoot":"","sources":["../src/deepseek-client.ts"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AC;qBACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;gBACxB,CAAC,CAAC,SAAS,CAAC;YAEhB,OAAO;gBACL,OAAO,EAAE,WAAW;gBACpB,iBAAiB,EAAE,gBAAgB,IAAI,SAAS;gBAChD,KAAK,EAAE,SAA0B;gBACjC,KAAK;gBACL,aAAa,EAAE,YAAY;gBAC3B,UAAU,EAAE,SAAS;aACtB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC;gBAC/C,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC3C,UAAU,EAAE,EAAE;aACf,CAAC,CAAC;YACH,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
13
13
|
content: string;
|
|
14
14
|
role: "system" | "user" | "assistant";
|
|
15
15
|
}>;
|
|
16
|
+
export declare const ThinkingSchema: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
type: z.ZodEnum<["enabled", "disabled"]>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
type: "enabled" | "disabled";
|
|
20
|
+
}, {
|
|
21
|
+
type: "enabled" | "disabled";
|
|
22
|
+
}>>;
|
|
16
23
|
export declare const ChatInputSchema: z.ZodObject<{
|
|
17
24
|
messages: z.ZodArray<z.ZodObject<{
|
|
18
25
|
role: z.ZodEnum<["system", "user", "assistant"]>;
|
|
@@ -28,24 +35,40 @@ export declare const ChatInputSchema: z.ZodObject<{
|
|
|
28
35
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
29
36
|
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
30
37
|
stream: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
38
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
type: z.ZodEnum<["enabled", "disabled"]>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
type: "enabled" | "disabled";
|
|
42
|
+
}, {
|
|
43
|
+
type: "enabled" | "disabled";
|
|
44
|
+
}>>;
|
|
45
|
+
json_mode: z.ZodOptional<z.ZodBoolean>;
|
|
31
46
|
}, "strip", z.ZodTypeAny, {
|
|
32
|
-
|
|
47
|
+
stream: boolean;
|
|
33
48
|
messages: {
|
|
34
49
|
content: string;
|
|
35
50
|
role: "system" | "user" | "assistant";
|
|
36
51
|
}[];
|
|
37
|
-
|
|
52
|
+
model: "deepseek-chat" | "deepseek-reasoner";
|
|
38
53
|
temperature?: number | undefined;
|
|
54
|
+
thinking?: {
|
|
55
|
+
type: "enabled" | "disabled";
|
|
56
|
+
} | undefined;
|
|
39
57
|
max_tokens?: number | undefined;
|
|
58
|
+
json_mode?: boolean | undefined;
|
|
40
59
|
}, {
|
|
41
60
|
messages: {
|
|
42
61
|
content: string;
|
|
43
62
|
role: "system" | "user" | "assistant";
|
|
44
63
|
}[];
|
|
45
|
-
model?: "deepseek-chat" | "deepseek-reasoner" | undefined;
|
|
46
64
|
temperature?: number | undefined;
|
|
47
|
-
|
|
65
|
+
thinking?: {
|
|
66
|
+
type: "enabled" | "disabled";
|
|
67
|
+
} | undefined;
|
|
48
68
|
stream?: boolean | undefined;
|
|
69
|
+
model?: "deepseek-chat" | "deepseek-reasoner" | undefined;
|
|
70
|
+
max_tokens?: number | undefined;
|
|
71
|
+
json_mode?: boolean | undefined;
|
|
49
72
|
}>;
|
|
50
73
|
export declare const FunctionDefinitionSchema: z.ZodObject<{
|
|
51
74
|
name: z.ZodString;
|
|
@@ -204,16 +227,33 @@ export declare const ChatInputWithToolsSchema: z.ZodObject<{
|
|
|
204
227
|
};
|
|
205
228
|
type: "function";
|
|
206
229
|
}>]>>;
|
|
230
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
231
|
+
type: z.ZodEnum<["enabled", "disabled"]>;
|
|
232
|
+
}, "strip", z.ZodTypeAny, {
|
|
233
|
+
type: "enabled" | "disabled";
|
|
234
|
+
}, {
|
|
235
|
+
type: "enabled" | "disabled";
|
|
236
|
+
}>>;
|
|
237
|
+
json_mode: z.ZodOptional<z.ZodBoolean>;
|
|
207
238
|
}, "strip", z.ZodTypeAny, {
|
|
208
|
-
|
|
239
|
+
stream: boolean;
|
|
209
240
|
messages: {
|
|
210
241
|
content: string;
|
|
211
242
|
role: "system" | "user" | "assistant" | "tool";
|
|
212
243
|
tool_call_id?: string | undefined;
|
|
213
244
|
}[];
|
|
214
|
-
|
|
245
|
+
model: "deepseek-chat" | "deepseek-reasoner";
|
|
215
246
|
temperature?: number | undefined;
|
|
247
|
+
thinking?: {
|
|
248
|
+
type: "enabled" | "disabled";
|
|
249
|
+
} | undefined;
|
|
216
250
|
max_tokens?: number | undefined;
|
|
251
|
+
tool_choice?: "auto" | "none" | "required" | {
|
|
252
|
+
function: {
|
|
253
|
+
name: string;
|
|
254
|
+
};
|
|
255
|
+
type: "function";
|
|
256
|
+
} | undefined;
|
|
217
257
|
tools?: {
|
|
218
258
|
function: {
|
|
219
259
|
name: string;
|
|
@@ -223,22 +263,26 @@ export declare const ChatInputWithToolsSchema: z.ZodObject<{
|
|
|
223
263
|
};
|
|
224
264
|
type: "function";
|
|
225
265
|
}[] | undefined;
|
|
226
|
-
|
|
227
|
-
function: {
|
|
228
|
-
name: string;
|
|
229
|
-
};
|
|
230
|
-
type: "function";
|
|
231
|
-
} | undefined;
|
|
266
|
+
json_mode?: boolean | undefined;
|
|
232
267
|
}, {
|
|
233
268
|
messages: {
|
|
234
269
|
content: string;
|
|
235
270
|
role: "system" | "user" | "assistant" | "tool";
|
|
236
271
|
tool_call_id?: string | undefined;
|
|
237
272
|
}[];
|
|
238
|
-
model?: "deepseek-chat" | "deepseek-reasoner" | undefined;
|
|
239
273
|
temperature?: number | undefined;
|
|
240
|
-
|
|
274
|
+
thinking?: {
|
|
275
|
+
type: "enabled" | "disabled";
|
|
276
|
+
} | undefined;
|
|
241
277
|
stream?: boolean | undefined;
|
|
278
|
+
model?: "deepseek-chat" | "deepseek-reasoner" | undefined;
|
|
279
|
+
max_tokens?: number | undefined;
|
|
280
|
+
tool_choice?: "auto" | "none" | "required" | {
|
|
281
|
+
function: {
|
|
282
|
+
name: string;
|
|
283
|
+
};
|
|
284
|
+
type: "function";
|
|
285
|
+
} | undefined;
|
|
242
286
|
tools?: {
|
|
243
287
|
function: {
|
|
244
288
|
name: string;
|
|
@@ -248,11 +292,6 @@ export declare const ChatInputWithToolsSchema: z.ZodObject<{
|
|
|
248
292
|
};
|
|
249
293
|
type: "function";
|
|
250
294
|
}[] | undefined;
|
|
251
|
-
|
|
252
|
-
function: {
|
|
253
|
-
name: string;
|
|
254
|
-
};
|
|
255
|
-
type: "function";
|
|
256
|
-
} | undefined;
|
|
295
|
+
json_mode?: boolean | undefined;
|
|
257
296
|
}>;
|
|
258
297
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;;;;;;EAGxB,CAAC;AAEH,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;;;;;;EAGxB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;GAEd,CAAC;AAEd,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU1B,CAAC;AAIH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;IAQ3B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAIhC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnC,CAAC"}
|
package/dist/schemas.js
CHANGED
|
@@ -8,14 +8,19 @@ export const MessageSchema = z.object({
|
|
|
8
8
|
role: z.enum(['system', 'user', 'assistant']),
|
|
9
9
|
content: z.string(),
|
|
10
10
|
});
|
|
11
|
+
export const ThinkingSchema = z
|
|
12
|
+
.object({ type: z.enum(['enabled', 'disabled']) })
|
|
13
|
+
.optional();
|
|
11
14
|
export const ChatInputSchema = z.object({
|
|
12
15
|
messages: z.array(MessageSchema).min(1),
|
|
13
16
|
model: z
|
|
14
17
|
.enum(['deepseek-chat', 'deepseek-reasoner'])
|
|
15
18
|
.default('deepseek-chat'),
|
|
16
19
|
temperature: z.number().min(0).max(2).optional(),
|
|
17
|
-
max_tokens: z.number().min(1).max(
|
|
20
|
+
max_tokens: z.number().min(1).max(65536).optional(),
|
|
18
21
|
stream: z.boolean().optional().default(false),
|
|
22
|
+
thinking: ThinkingSchema,
|
|
23
|
+
json_mode: z.boolean().optional(),
|
|
19
24
|
});
|
|
20
25
|
// ─── Function Calling Schemas ───────────────────────────────────
|
|
21
26
|
export const FunctionDefinitionSchema = z.object({
|
|
@@ -48,9 +53,11 @@ export const ChatInputWithToolsSchema = z.object({
|
|
|
48
53
|
.enum(['deepseek-chat', 'deepseek-reasoner'])
|
|
49
54
|
.default('deepseek-chat'),
|
|
50
55
|
temperature: z.number().min(0).max(2).optional(),
|
|
51
|
-
max_tokens: z.number().min(1).max(
|
|
56
|
+
max_tokens: z.number().min(1).max(65536).optional(),
|
|
52
57
|
stream: z.boolean().optional().default(false),
|
|
53
58
|
tools: z.array(ToolDefinitionSchema).max(128).optional(),
|
|
54
59
|
tool_choice: ToolChoiceSchema.optional(),
|
|
60
|
+
thinking: ThinkingSchema,
|
|
61
|
+
json_mode: z.boolean().optional(),
|
|
55
62
|
});
|
|
56
63
|
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mEAAmE;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,G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GAAG,CAAC,CAAC,QAAQ,EAAE;IACxD,WAAW,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACxC,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-chat.d.ts","sourceRoot":"","sources":["../../src/tools/deepseek-chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"deepseek-chat.d.ts","sourceRoot":"","sources":["../../src/tools/deepseek-chat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAgB5D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAmNhF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool: deepseek_chat
|
|
3
|
-
* Chat completion with DeepSeek models
|
|
3
|
+
* Chat completion with DeepSeek models (V3.2)
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { getConfig } from '../config.js';
|
|
7
7
|
import { calculateCost, formatCost } from '../cost.js';
|
|
8
|
-
import { ExtendedMessageSchema, ChatInputWithToolsSchema, ToolDefinitionSchema, ToolChoiceSchema, } from '../schemas.js';
|
|
8
|
+
import { ExtendedMessageSchema, ChatInputWithToolsSchema, ToolDefinitionSchema, ToolChoiceSchema, ThinkingSchema, } from '../schemas.js';
|
|
9
9
|
import { getErrorMessage } from '../types.js';
|
|
10
10
|
/** Maximum allowed message content length (from config) */
|
|
11
11
|
function validateMessageLength(input) {
|
|
@@ -19,10 +19,10 @@ function validateMessageLength(input) {
|
|
|
19
19
|
export function registerChatTool(server, client) {
|
|
20
20
|
server.registerTool('deepseek_chat', {
|
|
21
21
|
title: 'DeepSeek Chat Completion',
|
|
22
|
-
description: 'Chat with DeepSeek AI models. Supports deepseek-chat for general conversations and ' +
|
|
23
|
-
'deepseek-reasoner
|
|
24
|
-
'
|
|
25
|
-
'
|
|
22
|
+
description: 'Chat with DeepSeek V3.2 AI models. Supports deepseek-chat for general conversations and ' +
|
|
23
|
+
'deepseek-reasoner for complex reasoning tasks with chain-of-thought explanations. ' +
|
|
24
|
+
'Features: function calling (tools parameter), thinking mode for enhanced reasoning, ' +
|
|
25
|
+
'JSON output mode, and automatic cost tracking with cache hit/miss breakdown.',
|
|
26
26
|
inputSchema: {
|
|
27
27
|
messages: z
|
|
28
28
|
.array(ExtendedMessageSchema)
|
|
@@ -31,19 +31,19 @@ export function registerChatTool(server, client) {
|
|
|
31
31
|
model: z
|
|
32
32
|
.enum(['deepseek-chat', 'deepseek-reasoner'])
|
|
33
33
|
.default('deepseek-chat')
|
|
34
|
-
.describe('Model to use. deepseek-chat
|
|
34
|
+
.describe('Model to use. Both run DeepSeek V3.2 (128K context). deepseek-chat: non-thinking mode (max 8K output), deepseek-reasoner: thinking mode (max 64K output)'),
|
|
35
35
|
temperature: z
|
|
36
36
|
.number()
|
|
37
37
|
.min(0)
|
|
38
38
|
.max(2)
|
|
39
39
|
.optional()
|
|
40
|
-
.describe('Sampling temperature (0-2). Higher = more random. Default: 1.0'),
|
|
40
|
+
.describe('Sampling temperature (0-2). Higher = more random. Default: 1.0. Ignored when thinking mode is enabled.'),
|
|
41
41
|
max_tokens: z
|
|
42
42
|
.number()
|
|
43
43
|
.min(1)
|
|
44
|
-
.max(
|
|
44
|
+
.max(65536)
|
|
45
45
|
.optional()
|
|
46
|
-
.describe('Maximum tokens to generate.
|
|
46
|
+
.describe('Maximum tokens to generate. deepseek-chat: max 8192, deepseek-reasoner: max 65536'),
|
|
47
47
|
stream: z
|
|
48
48
|
.boolean()
|
|
49
49
|
.optional()
|
|
@@ -55,6 +55,11 @@ export function registerChatTool(server, client) {
|
|
|
55
55
|
.optional()
|
|
56
56
|
.describe('Array of tool definitions for function calling. Each tool has type "function" and a function object with name, description, and parameters (JSON Schema).'),
|
|
57
57
|
tool_choice: ToolChoiceSchema.optional().describe('Controls which tool the model calls. "auto" (default), "none", "required", or {type:"function",function:{name:"..."}}'),
|
|
58
|
+
thinking: ThinkingSchema.describe('Enable thinking mode for enhanced reasoning. When enabled, temperature/top_p/frequency_penalty/presence_penalty are automatically ignored. Use {type: "enabled"} to activate.'),
|
|
59
|
+
json_mode: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('Enable JSON output mode. The model will output valid JSON. Include the word "json" in your prompt for best results. Supported by both models.'),
|
|
58
63
|
},
|
|
59
64
|
outputSchema: {
|
|
60
65
|
content: z.string(),
|
|
@@ -64,6 +69,8 @@ export function registerChatTool(server, client) {
|
|
|
64
69
|
prompt_tokens: z.number(),
|
|
65
70
|
completion_tokens: z.number(),
|
|
66
71
|
total_tokens: z.number(),
|
|
72
|
+
prompt_cache_hit_tokens: z.number().optional(),
|
|
73
|
+
prompt_cache_miss_tokens: z.number().optional(),
|
|
67
74
|
}),
|
|
68
75
|
finish_reason: z.string(),
|
|
69
76
|
tool_calls: z
|
|
@@ -83,25 +90,40 @@ export function registerChatTool(server, client) {
|
|
|
83
90
|
validateMessageLength(input);
|
|
84
91
|
// Validate input with extended schema (supports tools)
|
|
85
92
|
const validated = ChatInputWithToolsSchema.parse(input);
|
|
86
|
-
|
|
93
|
+
// JSON mode guard: warn if "json" word is not in any message content
|
|
94
|
+
if (validated.json_mode) {
|
|
95
|
+
const hasJsonWord = validated.messages.some((m) => m.content.toLowerCase().includes('json'));
|
|
96
|
+
if (!hasJsonWord) {
|
|
97
|
+
console.error('[DeepSeek MCP] Warning: json_mode enabled but no "json" word found in messages. Results may be unreliable.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Model-aware max_tokens warnings
|
|
101
|
+
if (validated.max_tokens) {
|
|
102
|
+
if (validated.model === 'deepseek-chat' && validated.max_tokens > 8192) {
|
|
103
|
+
console.error(`[DeepSeek MCP] Warning: deepseek-chat max output is 8192 tokens, requested ${validated.max_tokens}. API may truncate.`);
|
|
104
|
+
}
|
|
105
|
+
if (validated.model === 'deepseek-reasoner' && validated.max_tokens > 65536) {
|
|
106
|
+
console.error(`[DeepSeek MCP] Warning: deepseek-reasoner max output is 65536 tokens, requested ${validated.max_tokens}. API may truncate.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
console.error(`[DeepSeek MCP] Request: model=${validated.model}, messages=${validated.messages.length}, stream=${validated.stream}${validated.tools ? `, tools=${validated.tools.length}` : ''}${validated.thinking ? `, thinking=${validated.thinking.type}` : ''}${validated.json_mode ? ', json_mode=true' : ''}`);
|
|
110
|
+
// Build params for client
|
|
111
|
+
const clientParams = {
|
|
112
|
+
model: validated.model,
|
|
113
|
+
messages: validated.messages,
|
|
114
|
+
temperature: validated.temperature,
|
|
115
|
+
max_tokens: validated.max_tokens,
|
|
116
|
+
tools: validated.tools,
|
|
117
|
+
tool_choice: validated.tool_choice,
|
|
118
|
+
thinking: validated.thinking,
|
|
119
|
+
response_format: validated.json_mode
|
|
120
|
+
? { type: 'json_object' }
|
|
121
|
+
: undefined,
|
|
122
|
+
};
|
|
87
123
|
// Call appropriate method based on stream parameter
|
|
88
124
|
const response = validated.stream
|
|
89
|
-
? await client.createStreamingChatCompletion(
|
|
90
|
-
|
|
91
|
-
messages: validated.messages,
|
|
92
|
-
temperature: validated.temperature,
|
|
93
|
-
max_tokens: validated.max_tokens,
|
|
94
|
-
tools: validated.tools,
|
|
95
|
-
tool_choice: validated.tool_choice,
|
|
96
|
-
})
|
|
97
|
-
: await client.createChatCompletion({
|
|
98
|
-
model: validated.model,
|
|
99
|
-
messages: validated.messages,
|
|
100
|
-
temperature: validated.temperature,
|
|
101
|
-
max_tokens: validated.max_tokens,
|
|
102
|
-
tools: validated.tools,
|
|
103
|
-
tool_choice: validated.tool_choice,
|
|
104
|
-
});
|
|
125
|
+
? await client.createStreamingChatCompletion(clientParams)
|
|
126
|
+
: await client.createChatCompletion(clientParams);
|
|
105
127
|
console.error(`[DeepSeek MCP] Response: tokens=${response.usage.total_tokens}, finish_reason=${response.finish_reason}${response.tool_calls ? `, tool_calls=${response.tool_calls.length}` : ''}`);
|
|
106
128
|
// Format response
|
|
107
129
|
let responseText = '';
|
|
@@ -120,13 +142,13 @@ export function registerChatTool(server, client) {
|
|
|
120
142
|
}
|
|
121
143
|
}
|
|
122
144
|
// Calculate cost
|
|
123
|
-
const
|
|
145
|
+
const costBreakdown = calculateCost(response.usage);
|
|
124
146
|
// Add usage stats with cost information (controlled by config)
|
|
125
147
|
if (getConfig().showCostInfo) {
|
|
126
148
|
responseText += `\n---\n**Request Information:**\n`;
|
|
127
149
|
responseText += `- **Tokens:** ${response.usage.total_tokens} (${response.usage.prompt_tokens} prompt + ${response.usage.completion_tokens} completion)\n`;
|
|
128
150
|
responseText += `- **Model:** ${response.model}\n`;
|
|
129
|
-
responseText += `- **Cost:** ${formatCost(
|
|
151
|
+
responseText += `- **Cost:** ${formatCost(costBreakdown)}`;
|
|
130
152
|
if (response.tool_calls?.length) {
|
|
131
153
|
responseText += `\n- **Tool Calls:** ${response.tool_calls.length}`;
|
|
132
154
|
}
|
|
@@ -140,7 +162,7 @@ export function registerChatTool(server, client) {
|
|
|
140
162
|
],
|
|
141
163
|
structuredContent: {
|
|
142
164
|
...response,
|
|
143
|
-
cost_usd: parseFloat(
|
|
165
|
+
cost_usd: parseFloat(costBreakdown.totalCost.toFixed(6)),
|
|
144
166
|
},
|
|
145
167
|
};
|
|
146
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-chat.js","sourceRoot":"","sources":["../../src/tools/deepseek-chat.ts"],"names":[],"mappings":"AAAA;;;GA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,IAAI,mCAAmC,CAAC;gBACpD,YAAY,IAAI,iBAAiB,QAAQ,CAAC,KAAK,CAAC,YAAY,KAAK,QAAQ,CAAC,KAAK,CAAC,aAAa,aAAa,QAAQ,CAAC,KAAK,CAAC,iBAAiB,gBAAgB,CAAC;gBAC3J,YAAY,IAAI,gBAAgB,QAAQ,CAAC,KAAK,IAAI,CAAC;gBACnD,YAAY,IAAI,eAAe,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC3D,IAAI,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;oBAChC,YAAY,IAAI,uBAAuB,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;gBACtE,CAAC;YACH,CAAC;YAED,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,YAAY;qBACnB;iBACF;gBACD,iBAAiB,EAAE;oBACjB,GAAG,QAAQ;oBACX,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACnB;aACxC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;YAC9C,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;YAE5C,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,UAAU,YAAY,EAAE;qBAC/B;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -68,6 +68,12 @@ export interface ChatCompletionParams {
|
|
|
68
68
|
stop?: string | string[];
|
|
69
69
|
tools?: ToolDefinition[];
|
|
70
70
|
tool_choice?: ToolChoice;
|
|
71
|
+
thinking?: {
|
|
72
|
+
type: 'enabled' | 'disabled';
|
|
73
|
+
};
|
|
74
|
+
response_format?: {
|
|
75
|
+
type: 'json_object';
|
|
76
|
+
};
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* Response from DeepSeek chat completion
|
|
@@ -80,6 +86,8 @@ export interface ChatCompletionResponse {
|
|
|
80
86
|
prompt_tokens: number;
|
|
81
87
|
completion_tokens: number;
|
|
82
88
|
total_tokens: number;
|
|
89
|
+
prompt_cache_hit_tokens?: number;
|
|
90
|
+
prompt_cache_miss_tokens?: number;
|
|
83
91
|
};
|
|
84
92
|
finish_reason: string;
|
|
85
93
|
tool_calls?: ToolCall[];
|
|
@@ -112,6 +120,10 @@ export interface DeepSeekChatInput {
|
|
|
112
120
|
name: string;
|
|
113
121
|
};
|
|
114
122
|
};
|
|
123
|
+
thinking?: {
|
|
124
|
+
type: 'enabled' | 'disabled';
|
|
125
|
+
};
|
|
126
|
+
json_mode?: boolean;
|
|
115
127
|
}
|
|
116
128
|
/**
|
|
117
129
|
* Error response structure
|
|
@@ -158,6 +170,8 @@ export interface DeepSeekRawResponse {
|
|
|
158
170
|
prompt_tokens: number;
|
|
159
171
|
completion_tokens: number;
|
|
160
172
|
total_tokens: number;
|
|
173
|
+
prompt_cache_hit_tokens?: number;
|
|
174
|
+
prompt_cache_miss_tokens?: number;
|
|
161
175
|
};
|
|
162
176
|
}
|
|
163
177
|
/**
|
|
@@ -189,6 +203,8 @@ export interface DeepSeekStreamChunk {
|
|
|
189
203
|
prompt_tokens: number;
|
|
190
204
|
completion_tokens: number;
|
|
191
205
|
total_tokens: number;
|
|
206
|
+
prompt_cache_hit_tokens?: number;
|
|
207
|
+
prompt_cache_miss_tokens?: number;
|
|
192
208
|
};
|
|
193
209
|
}
|
|
194
210
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;G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ACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAO1C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAItD"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuNH,kEAAkE;AAElE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB;IAEhB,OAAO,CACL,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,KAAK,IAAI;QAChB,mBAAmB,IAAI,OAAO;QAC9B,OAAQ,OAAmC,CAAC,iBAAiB,KAAK,QAAQ,CAC3E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED