@arikusi/deepseek-mcp-server 1.0.3 → 1.1.1
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 +68 -1
- package/README.md +120 -23
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +68 -0
- package/dist/config.js.map +1 -0
- package/dist/cost.d.ts +24 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +34 -0
- package/dist/cost.js.map +1 -0
- package/dist/deepseek-client.d.ts +10 -3
- package/dist/deepseek-client.d.ts.map +1 -1
- package/dist/deepseek-client.js +99 -37
- package/dist/deepseek-client.js.map +1 -1
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -505
- package/dist/index.js.map +1 -1
- package/dist/prompts/advanced.d.ts +8 -0
- package/dist/prompts/advanced.d.ts.map +1 -0
- package/dist/prompts/advanced.js +187 -0
- package/dist/prompts/advanced.js.map +1 -0
- package/dist/prompts/core.d.ts +8 -0
- package/dist/prompts/core.d.ts.map +1 -0
- package/dist/prompts/core.js +188 -0
- package/dist/prompts/core.js.map +1 -0
- package/dist/prompts/function-calling.d.ts +7 -0
- package/dist/prompts/function-calling.d.ts.map +1 -0
- package/dist/prompts/function-calling.js +87 -0
- package/dist/prompts/function-calling.js.map +1 -0
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +13 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/schemas.d.ts +258 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +56 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +16 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/deepseek-chat.d.ts +8 -0
- package/dist/tools/deepseek-chat.d.ts.map +1 -0
- package/dist/tools/deepseek-chat.js +162 -0
- package/dist/tools/deepseek-chat.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +135 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +20 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -4
package/dist/deepseek-client.js
CHANGED
|
@@ -3,42 +3,80 @@
|
|
|
3
3
|
* Wrapper around OpenAI SDK for DeepSeek API
|
|
4
4
|
*/
|
|
5
5
|
import OpenAI from 'openai';
|
|
6
|
+
import { getConfig } from './config.js';
|
|
7
|
+
import { ApiError } from './errors.js';
|
|
8
|
+
import { hasReasoningContent, getErrorMessage } from './types.js';
|
|
6
9
|
export class DeepSeekClient {
|
|
7
10
|
client;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!apiKey) {
|
|
11
|
-
throw new Error('DeepSeek API key is required');
|
|
12
|
-
}
|
|
11
|
+
constructor() {
|
|
12
|
+
const config = getConfig();
|
|
13
13
|
this.client = new OpenAI({
|
|
14
|
-
apiKey,
|
|
15
|
-
baseURL:
|
|
14
|
+
apiKey: config.apiKey,
|
|
15
|
+
baseURL: config.baseUrl,
|
|
16
|
+
timeout: config.requestTimeout,
|
|
17
|
+
maxRetries: config.maxRetries,
|
|
16
18
|
});
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Build request params shared between streaming and non-streaming
|
|
22
|
+
*/
|
|
23
|
+
buildRequestParams(params, stream) {
|
|
24
|
+
const requestParams = {
|
|
25
|
+
model: params.model,
|
|
26
|
+
messages: params.messages,
|
|
27
|
+
temperature: params.temperature ?? 1.0,
|
|
28
|
+
max_tokens: params.max_tokens,
|
|
29
|
+
top_p: params.top_p,
|
|
30
|
+
frequency_penalty: params.frequency_penalty,
|
|
31
|
+
presence_penalty: params.presence_penalty,
|
|
32
|
+
stop: params.stop,
|
|
33
|
+
stream,
|
|
34
|
+
};
|
|
35
|
+
if (params.tools?.length) {
|
|
36
|
+
requestParams.tools = params.tools;
|
|
37
|
+
}
|
|
38
|
+
if (params.tool_choice !== undefined) {
|
|
39
|
+
requestParams.tool_choice =
|
|
40
|
+
params.tool_choice;
|
|
41
|
+
}
|
|
42
|
+
return requestParams;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wrap caught errors with appropriate custom error class
|
|
46
|
+
*/
|
|
47
|
+
wrapError(error, context) {
|
|
48
|
+
if (error instanceof ApiError)
|
|
49
|
+
throw error;
|
|
50
|
+
const message = getErrorMessage(error);
|
|
51
|
+
const cause = error instanceof Error ? error : undefined;
|
|
52
|
+
throw new ApiError(`${context}: ${message}`, { cause });
|
|
53
|
+
}
|
|
18
54
|
/**
|
|
19
55
|
* Create a chat completion (non-streaming)
|
|
20
56
|
*/
|
|
21
57
|
async createChatCompletion(params) {
|
|
22
58
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
temperature: params.temperature ?? 1.0,
|
|
27
|
-
max_tokens: params.max_tokens,
|
|
28
|
-
top_p: params.top_p,
|
|
29
|
-
frequency_penalty: params.frequency_penalty,
|
|
30
|
-
presence_penalty: params.presence_penalty,
|
|
31
|
-
stop: params.stop,
|
|
32
|
-
stream: false,
|
|
33
|
-
});
|
|
59
|
+
const requestParams = this.buildRequestParams(params, false);
|
|
60
|
+
const rawResponse = await this.client.chat.completions.create(requestParams);
|
|
61
|
+
const response = rawResponse;
|
|
34
62
|
const choice = response.choices[0];
|
|
35
63
|
if (!choice) {
|
|
36
|
-
throw new
|
|
64
|
+
throw new ApiError('No response from DeepSeek API');
|
|
37
65
|
}
|
|
38
66
|
// Extract reasoning content if available (for deepseek-reasoner)
|
|
39
|
-
const reasoning_content =
|
|
67
|
+
const reasoning_content = hasReasoningContent(choice.message)
|
|
40
68
|
? choice.message.reasoning_content
|
|
41
69
|
: undefined;
|
|
70
|
+
// Extract tool_calls if present
|
|
71
|
+
const tool_calls = choice.message.tool_calls
|
|
72
|
+
?.map((tc) => ({
|
|
73
|
+
id: tc.id,
|
|
74
|
+
type: 'function',
|
|
75
|
+
function: {
|
|
76
|
+
name: tc.function.name,
|
|
77
|
+
arguments: tc.function.arguments,
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
42
80
|
return {
|
|
43
81
|
content: choice.message.content || '',
|
|
44
82
|
reasoning_content,
|
|
@@ -49,30 +87,22 @@ export class DeepSeekClient {
|
|
|
49
87
|
total_tokens: response.usage?.total_tokens || 0,
|
|
50
88
|
},
|
|
51
89
|
finish_reason: choice.finish_reason || 'stop',
|
|
90
|
+
tool_calls: tool_calls?.length ? tool_calls : undefined,
|
|
52
91
|
};
|
|
53
92
|
}
|
|
54
93
|
catch (error) {
|
|
55
94
|
console.error('DeepSeek API Error:', error);
|
|
56
|
-
|
|
95
|
+
this.wrapError(error, 'DeepSeek API Error');
|
|
57
96
|
}
|
|
58
97
|
}
|
|
59
98
|
/**
|
|
60
99
|
* Create a streaming chat completion
|
|
61
|
-
* Returns the full text after streaming completes
|
|
100
|
+
* Returns the full text after streaming completes (buffered)
|
|
62
101
|
*/
|
|
63
102
|
async createStreamingChatCompletion(params) {
|
|
64
103
|
try {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
messages: params.messages,
|
|
68
|
-
temperature: params.temperature ?? 1.0,
|
|
69
|
-
max_tokens: params.max_tokens,
|
|
70
|
-
top_p: params.top_p,
|
|
71
|
-
frequency_penalty: params.frequency_penalty,
|
|
72
|
-
presence_penalty: params.presence_penalty,
|
|
73
|
-
stop: params.stop,
|
|
74
|
-
stream: true,
|
|
75
|
-
});
|
|
104
|
+
const requestParams = this.buildRequestParams(params, true);
|
|
105
|
+
const stream = await this.client.chat.completions.create(requestParams);
|
|
76
106
|
let fullContent = '';
|
|
77
107
|
let reasoningContent = '';
|
|
78
108
|
let modelName = params.model;
|
|
@@ -82,8 +112,11 @@ export class DeepSeekClient {
|
|
|
82
112
|
completion_tokens: 0,
|
|
83
113
|
total_tokens: 0,
|
|
84
114
|
};
|
|
115
|
+
// Tool calls accumulation (index-based)
|
|
116
|
+
const toolCallsMap = new Map();
|
|
85
117
|
// Collect all chunks
|
|
86
|
-
for await (const
|
|
118
|
+
for await (const rawChunk of stream) {
|
|
119
|
+
const chunk = rawChunk;
|
|
87
120
|
const choice = chunk.choices[0];
|
|
88
121
|
if (!choice)
|
|
89
122
|
continue;
|
|
@@ -92,8 +125,30 @@ export class DeepSeekClient {
|
|
|
92
125
|
fullContent += choice.delta.content;
|
|
93
126
|
}
|
|
94
127
|
// Collect reasoning content (for deepseek-reasoner)
|
|
95
|
-
if (
|
|
96
|
-
reasoningContent += choice.delta.reasoning_content
|
|
128
|
+
if (choice.delta && hasReasoningContent(choice.delta)) {
|
|
129
|
+
reasoningContent += choice.delta.reasoning_content;
|
|
130
|
+
}
|
|
131
|
+
// Accumulate tool_calls deltas
|
|
132
|
+
if (choice.delta?.tool_calls) {
|
|
133
|
+
for (const tc of choice.delta.tool_calls) {
|
|
134
|
+
const existing = toolCallsMap.get(tc.index);
|
|
135
|
+
if (existing) {
|
|
136
|
+
if (tc.function?.name)
|
|
137
|
+
existing.function.name += tc.function.name;
|
|
138
|
+
if (tc.function?.arguments)
|
|
139
|
+
existing.function.arguments += tc.function.arguments;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
toolCallsMap.set(tc.index, {
|
|
143
|
+
id: tc.id || '',
|
|
144
|
+
type: 'function',
|
|
145
|
+
function: {
|
|
146
|
+
name: tc.function?.name || '',
|
|
147
|
+
arguments: tc.function?.arguments || '',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
97
152
|
}
|
|
98
153
|
// Get finish reason
|
|
99
154
|
if (choice.finish_reason) {
|
|
@@ -108,17 +163,24 @@ export class DeepSeekClient {
|
|
|
108
163
|
usage = chunk.usage;
|
|
109
164
|
}
|
|
110
165
|
}
|
|
166
|
+
// Convert tool calls map to sorted array
|
|
167
|
+
const toolCalls = toolCallsMap.size > 0
|
|
168
|
+
? Array.from(toolCallsMap.entries())
|
|
169
|
+
.sort(([a], [b]) => a - b)
|
|
170
|
+
.map(([, tc]) => tc)
|
|
171
|
+
: undefined;
|
|
111
172
|
return {
|
|
112
173
|
content: fullContent,
|
|
113
174
|
reasoning_content: reasoningContent || undefined,
|
|
114
175
|
model: modelName,
|
|
115
176
|
usage,
|
|
116
177
|
finish_reason: finishReason,
|
|
178
|
+
tool_calls: toolCalls,
|
|
117
179
|
};
|
|
118
180
|
}
|
|
119
181
|
catch (error) {
|
|
120
182
|
console.error('DeepSeek Streaming API Error:', error);
|
|
121
|
-
|
|
183
|
+
this.wrapError(error, 'DeepSeek Streaming API Error');
|
|
122
184
|
}
|
|
123
185
|
}
|
|
124
186
|
/**
|
|
@@ -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;
|
|
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,M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;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/errors.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
* Structured error hierarchy for DeepSeek MCP Server
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base error class for all DeepSeek MCP errors
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseError extends Error {
|
|
9
|
+
constructor(message: string, options?: ErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration validation error
|
|
13
|
+
* Thrown when config validation fails (replaces process.exit)
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConfigError extends BaseError {
|
|
16
|
+
readonly issues: Array<{
|
|
17
|
+
path: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
constructor(message: string, issues?: Array<{
|
|
21
|
+
path: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}>, options?: ErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* DeepSeek API error
|
|
27
|
+
* Wraps errors from the DeepSeek/OpenAI API
|
|
28
|
+
*/
|
|
29
|
+
export declare class ApiError extends BaseError {
|
|
30
|
+
readonly statusCode?: number;
|
|
31
|
+
readonly retryable: boolean;
|
|
32
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
33
|
+
statusCode?: number;
|
|
34
|
+
retryable?: boolean;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rate limit error (429)
|
|
39
|
+
*/
|
|
40
|
+
export declare class RateLimitError extends ApiError {
|
|
41
|
+
constructor(message: string, options?: ErrorOptions);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Authentication error (401)
|
|
45
|
+
*/
|
|
46
|
+
export declare class AuthenticationError extends ApiError {
|
|
47
|
+
constructor(message: string, options?: ErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Input validation error
|
|
51
|
+
*/
|
|
52
|
+
export declare class ValidationError extends BaseError {
|
|
53
|
+
readonly zodErrors?: Array<{
|
|
54
|
+
path: string;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
constructor(message: string, zodErrors?: Array<{
|
|
58
|
+
path: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}>, options?: ErrorOptions);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Network/connection error
|
|
64
|
+
*/
|
|
65
|
+
export declare class ConnectionError extends BaseError {
|
|
66
|
+
readonly retryable: boolean;
|
|
67
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
68
|
+
retryable?: boolean;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,SAAgB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;gBAG/D,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAM,EAC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class for all DeepSeek MCP errors
|
|
7
|
+
*/
|
|
8
|
+
export class BaseError extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = this.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configuration validation error
|
|
16
|
+
* Thrown when config validation fails (replaces process.exit)
|
|
17
|
+
*/
|
|
18
|
+
export class ConfigError extends BaseError {
|
|
19
|
+
issues;
|
|
20
|
+
constructor(message, issues = [], options) {
|
|
21
|
+
super(message, options);
|
|
22
|
+
this.issues = issues;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* DeepSeek API error
|
|
27
|
+
* Wraps errors from the DeepSeek/OpenAI API
|
|
28
|
+
*/
|
|
29
|
+
export class ApiError extends BaseError {
|
|
30
|
+
statusCode;
|
|
31
|
+
retryable;
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
this.statusCode = options?.statusCode;
|
|
35
|
+
this.retryable = options?.retryable ?? false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Rate limit error (429)
|
|
40
|
+
*/
|
|
41
|
+
export class RateLimitError extends ApiError {
|
|
42
|
+
constructor(message, options) {
|
|
43
|
+
super(message, { ...options, statusCode: 429, retryable: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Authentication error (401)
|
|
48
|
+
*/
|
|
49
|
+
export class AuthenticationError extends ApiError {
|
|
50
|
+
constructor(message, options) {
|
|
51
|
+
super(message, { ...options, statusCode: 401, retryable: false });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Input validation error
|
|
56
|
+
*/
|
|
57
|
+
export class ValidationError extends BaseError {
|
|
58
|
+
zodErrors;
|
|
59
|
+
constructor(message, zodErrors, options) {
|
|
60
|
+
super(message, options);
|
|
61
|
+
this.zodErrors = zodErrors;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Network/connection error
|
|
66
|
+
*/
|
|
67
|
+
export class ConnectionError extends BaseError {
|
|
68
|
+
retryable;
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super(message, options);
|
|
71
|
+
this.retryable = options?.retryable ?? true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxB,MAAM,CAA2C;IAEjE,YACE,OAAe,EACf,SAAmD,EAAE,EACrD,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrB,UAAU,CAAU;IACpB,SAAS,CAAU;IAEnC,YACE,OAAe,EACf,OAAqE;QAErE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC;IAC/C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IAC/C,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5B,SAAS,CAA4C;IAErE,YACE,OAAe,EACf,SAAoD,EACpD,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5B,SAAS,CAAU;IAEnC,YAAY,OAAe,EAAE,OAAgD;QAC3E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IAC9C,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* DeepSeek MCP Server
|
|
4
4
|
* Model Context Protocol server for DeepSeek API integration
|
|
5
|
-
*
|
|
6
|
-
* This server exposes DeepSeek's chat and reasoning models as MCP tools
|
|
7
|
-
* that can be used by Claude Code and other MCP clients.
|
|
8
5
|
*/
|
|
9
6
|
export {};
|
|
10
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|