cas-parser-node-mcp 1.1.0 → 1.3.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/README.md +14 -3
- package/code-tool-paths.cjs +6 -0
- package/code-tool-paths.cjs.map +1 -0
- package/code-tool-paths.d.cts +2 -0
- package/code-tool-paths.d.cts.map +1 -0
- package/code-tool-types.d.mts +14 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +14 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool-worker.d.mts +5 -0
- package/code-tool-worker.d.mts.map +1 -0
- package/code-tool-worker.d.ts +5 -0
- package/code-tool-worker.d.ts.map +1 -0
- package/code-tool-worker.js +45 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +40 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +12 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +12 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +123 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +120 -0
- package/code-tool.mjs.map +1 -0
- package/compat.d.mts +4 -2
- package/compat.d.mts.map +1 -1
- package/compat.d.ts +4 -2
- package/compat.d.ts.map +1 -1
- package/compat.js +3 -1
- package/compat.js.map +1 -1
- package/compat.mjs +2 -0
- package/compat.mjs.map +1 -1
- package/headers.d.mts +1 -1
- package/headers.d.mts.map +1 -1
- package/headers.d.ts +1 -1
- package/headers.d.ts.map +1 -1
- package/headers.js +1 -1
- package/headers.js.map +1 -1
- package/headers.mjs +1 -1
- package/headers.mjs.map +1 -1
- package/http.d.mts +1 -2
- package/http.d.mts.map +1 -1
- package/http.d.ts +1 -2
- package/http.d.ts.map +1 -1
- package/http.js +19 -2
- package/http.js.map +1 -1
- package/http.mjs +19 -2
- package/http.mjs.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/index.mjs +4 -4
- package/index.mjs.map +1 -1
- package/options.d.mts +8 -6
- package/options.d.mts.map +1 -1
- package/options.d.ts +8 -6
- package/options.d.ts.map +1 -1
- package/options.js +118 -15
- package/options.js.map +1 -1
- package/options.mjs +117 -15
- package/options.mjs.map +1 -1
- package/package.json +47 -4
- package/server.d.mts +3 -16
- package/server.d.mts.map +1 -1
- package/server.d.ts +3 -16
- package/server.d.ts.map +1 -1
- package/server.js +45 -26
- package/server.js.map +1 -1
- package/server.mjs +44 -25
- package/server.mjs.map +1 -1
- package/src/code-tool-paths.cts +3 -0
- package/src/code-tool-types.ts +14 -0
- package/src/code-tool-worker.ts +46 -0
- package/src/code-tool.ts +144 -0
- package/src/compat.ts +4 -2
- package/src/headers.ts +2 -3
- package/src/http.ts +24 -8
- package/src/index.ts +4 -4
- package/src/options.ts +136 -21
- package/src/server.ts +54 -39
- package/src/stdio.ts +3 -4
- package/stdio.d.mts +1 -2
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +1 -2
- package/stdio.d.ts.map +1 -1
- package/stdio.js +2 -2
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
package/src/options.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import qs from 'qs';
|
|
1
2
|
import yargs from 'yargs';
|
|
2
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import z from 'zod';
|
|
3
5
|
import { endpoints, Filter } from './tools';
|
|
4
6
|
import { ClientCapabilities, knownClients, ClientType } from './compat';
|
|
5
7
|
|
|
@@ -11,11 +13,12 @@ export type CLIOptions = McpOptions & {
|
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export type McpOptions = {
|
|
14
|
-
client
|
|
15
|
-
includeDynamicTools
|
|
16
|
-
includeAllTools
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
client?: ClientType | undefined;
|
|
17
|
+
includeDynamicTools?: boolean | undefined;
|
|
18
|
+
includeAllTools?: boolean | undefined;
|
|
19
|
+
includeCodeTools?: boolean | undefined;
|
|
20
|
+
filters?: Filter[] | undefined;
|
|
21
|
+
capabilities?: Partial<ClientCapabilities> | undefined;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
const CAPABILITY_CHOICES = [
|
|
@@ -47,18 +50,18 @@ function parseCapabilityValue(cap: string): { name: Capability; value?: number }
|
|
|
47
50
|
return { name: cap as Capability };
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
export function
|
|
53
|
+
export function parseCLIOptions(): CLIOptions {
|
|
51
54
|
const opts = yargs(hideBin(process.argv))
|
|
52
55
|
.option('tools', {
|
|
53
56
|
type: 'string',
|
|
54
57
|
array: true,
|
|
55
|
-
choices: ['dynamic', 'all'],
|
|
58
|
+
choices: ['dynamic', 'all', 'code'],
|
|
56
59
|
description: 'Use dynamic tools or all tools',
|
|
57
60
|
})
|
|
58
61
|
.option('no-tools', {
|
|
59
62
|
type: 'string',
|
|
60
63
|
array: true,
|
|
61
|
-
choices: ['dynamic', 'all'],
|
|
64
|
+
choices: ['dynamic', 'all', 'code'],
|
|
62
65
|
description: 'Do not use any dynamic or all tools',
|
|
63
66
|
})
|
|
64
67
|
.option('tool', {
|
|
@@ -201,14 +204,7 @@ export function parseOptions(): CLIOptions {
|
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
// Parse client capabilities
|
|
204
|
-
const clientCapabilities: ClientCapabilities = {
|
|
205
|
-
topLevelUnions: true,
|
|
206
|
-
validJson: true,
|
|
207
|
-
refs: true,
|
|
208
|
-
unions: true,
|
|
209
|
-
formats: true,
|
|
210
|
-
toolNameLength: undefined,
|
|
211
|
-
};
|
|
207
|
+
const clientCapabilities: Partial<ClientCapabilities> = {};
|
|
212
208
|
|
|
213
209
|
// Apply individual capability overrides
|
|
214
210
|
if (Array.isArray(argv.capability)) {
|
|
@@ -249,19 +245,22 @@ export function parseOptions(): CLIOptions {
|
|
|
249
245
|
}
|
|
250
246
|
}
|
|
251
247
|
|
|
248
|
+
const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code') =>
|
|
249
|
+
explicitTools ? argv.tools?.includes(toolType) && !argv.noTools?.includes(toolType) : undefined;
|
|
250
|
+
|
|
252
251
|
const explicitTools = Boolean(argv.tools || argv.noTools);
|
|
253
|
-
const includeDynamicTools =
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
explicitTools ? argv.tools?.includes('all') && !argv.noTools?.includes('all') : undefined;
|
|
252
|
+
const includeDynamicTools = shouldIncludeToolType('dynamic');
|
|
253
|
+
const includeAllTools = shouldIncludeToolType('all');
|
|
254
|
+
const includeCodeTools = shouldIncludeToolType('code');
|
|
257
255
|
|
|
258
256
|
const transport = argv.transport as 'stdio' | 'http';
|
|
259
257
|
|
|
260
258
|
const client = argv.client as ClientType;
|
|
261
259
|
return {
|
|
262
|
-
client: client && knownClients[client] ? client : undefined,
|
|
260
|
+
client: client && client !== 'infer' && knownClients[client] ? client : undefined,
|
|
263
261
|
includeDynamicTools,
|
|
264
262
|
includeAllTools,
|
|
263
|
+
includeCodeTools,
|
|
265
264
|
filters,
|
|
266
265
|
capabilities: clientCapabilities,
|
|
267
266
|
list: argv.list || false,
|
|
@@ -271,6 +270,122 @@ export function parseOptions(): CLIOptions {
|
|
|
271
270
|
};
|
|
272
271
|
}
|
|
273
272
|
|
|
273
|
+
const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
|
|
274
|
+
z.preprocess(
|
|
275
|
+
(val) =>
|
|
276
|
+
Array.isArray(val) ? val
|
|
277
|
+
: val ? [val]
|
|
278
|
+
: val,
|
|
279
|
+
z.array(zodType).optional(),
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const QueryOptions = z.object({
|
|
283
|
+
tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Use dynamic tools or all tools'),
|
|
284
|
+
no_tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Do not use dynamic tools or all tools'),
|
|
285
|
+
tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
|
|
286
|
+
resource: coerceArray(z.string()).describe('Include tools matching the specified resources'),
|
|
287
|
+
operation: coerceArray(z.enum(['read', 'write'])).describe(
|
|
288
|
+
'Include tools matching the specified operations',
|
|
289
|
+
),
|
|
290
|
+
tag: coerceArray(z.string()).describe('Include tools with the specified tags'),
|
|
291
|
+
no_tool: coerceArray(z.string()).describe('Exclude tools matching the specified names'),
|
|
292
|
+
no_resource: coerceArray(z.string()).describe('Exclude tools matching the specified resources'),
|
|
293
|
+
no_operation: coerceArray(z.enum(['read', 'write'])).describe(
|
|
294
|
+
'Exclude tools matching the specified operations',
|
|
295
|
+
),
|
|
296
|
+
no_tag: coerceArray(z.string()).describe('Exclude tools with the specified tags'),
|
|
297
|
+
client: ClientType.optional().describe('Specify the MCP client being used'),
|
|
298
|
+
capability: coerceArray(z.string()).describe('Specify client capabilities'),
|
|
299
|
+
no_capability: coerceArray(z.enum(CAPABILITY_CHOICES)).describe('Unset client capabilities'),
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions {
|
|
303
|
+
const queryObject = typeof query === 'string' ? qs.parse(query) : query;
|
|
304
|
+
const queryOptions = QueryOptions.parse(queryObject);
|
|
305
|
+
|
|
306
|
+
const filters: Filter[] = [...(defaultOptions.filters ?? [])];
|
|
307
|
+
|
|
308
|
+
for (const resource of queryOptions.resource || []) {
|
|
309
|
+
filters.push({ type: 'resource', op: 'include', value: resource });
|
|
310
|
+
}
|
|
311
|
+
for (const operation of queryOptions.operation || []) {
|
|
312
|
+
filters.push({ type: 'operation', op: 'include', value: operation });
|
|
313
|
+
}
|
|
314
|
+
for (const tag of queryOptions.tag || []) {
|
|
315
|
+
filters.push({ type: 'tag', op: 'include', value: tag });
|
|
316
|
+
}
|
|
317
|
+
for (const tool of queryOptions.tool || []) {
|
|
318
|
+
filters.push({ type: 'tool', op: 'include', value: tool });
|
|
319
|
+
}
|
|
320
|
+
for (const resource of queryOptions.no_resource || []) {
|
|
321
|
+
filters.push({ type: 'resource', op: 'exclude', value: resource });
|
|
322
|
+
}
|
|
323
|
+
for (const operation of queryOptions.no_operation || []) {
|
|
324
|
+
filters.push({ type: 'operation', op: 'exclude', value: operation });
|
|
325
|
+
}
|
|
326
|
+
for (const tag of queryOptions.no_tag || []) {
|
|
327
|
+
filters.push({ type: 'tag', op: 'exclude', value: tag });
|
|
328
|
+
}
|
|
329
|
+
for (const tool of queryOptions.no_tool || []) {
|
|
330
|
+
filters.push({ type: 'tool', op: 'exclude', value: tool });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Parse client capabilities
|
|
334
|
+
const clientCapabilities: Partial<ClientCapabilities> = { ...defaultOptions.capabilities };
|
|
335
|
+
|
|
336
|
+
for (const cap of queryOptions.capability || []) {
|
|
337
|
+
const parsed = parseCapabilityValue(cap);
|
|
338
|
+
if (parsed.name === 'top-level-unions') {
|
|
339
|
+
clientCapabilities.topLevelUnions = true;
|
|
340
|
+
} else if (parsed.name === 'valid-json') {
|
|
341
|
+
clientCapabilities.validJson = true;
|
|
342
|
+
} else if (parsed.name === 'refs') {
|
|
343
|
+
clientCapabilities.refs = true;
|
|
344
|
+
} else if (parsed.name === 'unions') {
|
|
345
|
+
clientCapabilities.unions = true;
|
|
346
|
+
} else if (parsed.name === 'formats') {
|
|
347
|
+
clientCapabilities.formats = true;
|
|
348
|
+
} else if (parsed.name === 'tool-name-length') {
|
|
349
|
+
clientCapabilities.toolNameLength = parsed.value;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
for (const cap of queryOptions.no_capability || []) {
|
|
354
|
+
if (cap === 'top-level-unions') {
|
|
355
|
+
clientCapabilities.topLevelUnions = false;
|
|
356
|
+
} else if (cap === 'valid-json') {
|
|
357
|
+
clientCapabilities.validJson = false;
|
|
358
|
+
} else if (cap === 'refs') {
|
|
359
|
+
clientCapabilities.refs = false;
|
|
360
|
+
} else if (cap === 'unions') {
|
|
361
|
+
clientCapabilities.unions = false;
|
|
362
|
+
} else if (cap === 'formats') {
|
|
363
|
+
clientCapabilities.formats = false;
|
|
364
|
+
} else if (cap === 'tool-name-length') {
|
|
365
|
+
clientCapabilities.toolNameLength = undefined;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
let dynamicTools: boolean | undefined =
|
|
370
|
+
queryOptions.no_tools && !queryOptions.no_tools?.includes('dynamic') ? false
|
|
371
|
+
: queryOptions.tools?.includes('dynamic') ? true
|
|
372
|
+
: defaultOptions.includeDynamicTools;
|
|
373
|
+
|
|
374
|
+
let allTools: boolean | undefined =
|
|
375
|
+
queryOptions.no_tools && !queryOptions.no_tools?.includes('all') ? false
|
|
376
|
+
: queryOptions.tools?.includes('all') ? true
|
|
377
|
+
: defaultOptions.includeAllTools;
|
|
378
|
+
|
|
379
|
+
return {
|
|
380
|
+
client: queryOptions.client ?? defaultOptions.client,
|
|
381
|
+
includeDynamicTools: dynamicTools,
|
|
382
|
+
includeAllTools: allTools,
|
|
383
|
+
includeCodeTools: undefined,
|
|
384
|
+
filters,
|
|
385
|
+
capabilities: clientCapabilities,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
274
389
|
function getCapabilitiesExplanation(): string {
|
|
275
390
|
return `
|
|
276
391
|
Client Capabilities Explanation:
|
package/src/server.ts
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
5
|
import { Endpoint, endpoints, HandlerFunction, query } from './tools';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
CallToolRequestSchema,
|
|
8
|
+
Implementation,
|
|
9
|
+
ListToolsRequestSchema,
|
|
10
|
+
Tool,
|
|
11
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
7
12
|
import { ClientOptions } from 'cas-parser-node';
|
|
8
13
|
import CasParser from 'cas-parser-node';
|
|
9
14
|
import {
|
|
@@ -14,6 +19,7 @@ import {
|
|
|
14
19
|
parseEmbeddedJSON,
|
|
15
20
|
} from './compat';
|
|
16
21
|
import { dynamicTools } from './dynamic-tools';
|
|
22
|
+
import { codeTool } from './code-tool';
|
|
17
23
|
import { McpOptions } from './options';
|
|
18
24
|
|
|
19
25
|
export { McpOptions } from './options';
|
|
@@ -26,7 +32,7 @@ export const newMcpServer = () =>
|
|
|
26
32
|
new McpServer(
|
|
27
33
|
{
|
|
28
34
|
name: 'cas_parser_node_api',
|
|
29
|
-
version: '1.
|
|
35
|
+
version: '1.3.0',
|
|
30
36
|
},
|
|
31
37
|
{ capabilities: { tools: {}, logging: {} } },
|
|
32
38
|
);
|
|
@@ -40,29 +46,29 @@ export const server = newMcpServer();
|
|
|
40
46
|
*/
|
|
41
47
|
export function initMcpServer(params: {
|
|
42
48
|
server: Server | McpServer;
|
|
43
|
-
clientOptions
|
|
44
|
-
mcpOptions
|
|
45
|
-
endpoints?: { tool: Tool; handler: HandlerFunction }[];
|
|
46
|
-
}) {
|
|
47
|
-
const transformedEndpoints = selectTools(endpoints, params.mcpOptions);
|
|
48
|
-
const client = new CasParser(params.clientOptions);
|
|
49
|
-
const capabilities = {
|
|
50
|
-
...defaultClientCapabilities,
|
|
51
|
-
...(params.mcpOptions.client ? knownClients[params.mcpOptions.client] : params.mcpOptions.capabilities),
|
|
52
|
-
};
|
|
53
|
-
init({ server: params.server, client, endpoints: transformedEndpoints, capabilities });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function init(params: {
|
|
57
|
-
server: Server | McpServer;
|
|
58
|
-
client?: CasParser;
|
|
59
|
-
endpoints?: { tool: Tool; handler: HandlerFunction }[];
|
|
60
|
-
capabilities?: Partial<ClientCapabilities>;
|
|
49
|
+
clientOptions?: ClientOptions;
|
|
50
|
+
mcpOptions?: McpOptions;
|
|
61
51
|
}) {
|
|
62
52
|
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const mcpOptions = params.mcpOptions ?? {};
|
|
54
|
+
|
|
55
|
+
let providedEndpoints: Endpoint[] | null = null;
|
|
56
|
+
let endpointMap: Record<string, Endpoint> | null = null;
|
|
57
|
+
|
|
58
|
+
const initTools = (implementation?: Implementation) => {
|
|
59
|
+
if (implementation && (!mcpOptions.client || mcpOptions.client === 'infer')) {
|
|
60
|
+
mcpOptions.client =
|
|
61
|
+
implementation.name.toLowerCase().includes('claude') ? 'claude'
|
|
62
|
+
: implementation.name.toLowerCase().includes('cursor') ? 'cursor'
|
|
63
|
+
: undefined;
|
|
64
|
+
mcpOptions.capabilities = {
|
|
65
|
+
...(mcpOptions.client && knownClients[mcpOptions.client]),
|
|
66
|
+
...mcpOptions.capabilities,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
providedEndpoints = selectTools(endpoints, mcpOptions);
|
|
70
|
+
endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint]));
|
|
71
|
+
};
|
|
66
72
|
|
|
67
73
|
const logAtLevel =
|
|
68
74
|
(level: 'debug' | 'info' | 'warning' | 'error') =>
|
|
@@ -79,54 +85,63 @@ export function init(params: {
|
|
|
79
85
|
error: logAtLevel('error'),
|
|
80
86
|
};
|
|
81
87
|
|
|
82
|
-
const client =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
defaultHeaders
|
|
87
|
-
|
|
88
|
-
}
|
|
88
|
+
const client = new CasParser({
|
|
89
|
+
logger,
|
|
90
|
+
...params.clientOptions,
|
|
91
|
+
defaultHeaders: {
|
|
92
|
+
...params.clientOptions?.defaultHeaders,
|
|
93
|
+
'X-Stainless-MCP': 'true',
|
|
94
|
+
},
|
|
95
|
+
});
|
|
89
96
|
|
|
90
97
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
98
|
+
if (providedEndpoints === null) {
|
|
99
|
+
initTools(server.getClientVersion());
|
|
100
|
+
}
|
|
91
101
|
return {
|
|
92
|
-
tools: providedEndpoints
|
|
102
|
+
tools: providedEndpoints!.map((endpoint) => endpoint.tool),
|
|
93
103
|
};
|
|
94
104
|
});
|
|
95
105
|
|
|
96
106
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
107
|
+
if (endpointMap === null) {
|
|
108
|
+
initTools(server.getClientVersion());
|
|
109
|
+
}
|
|
97
110
|
const { name, arguments: args } = request.params;
|
|
98
|
-
const endpoint = endpointMap[name];
|
|
111
|
+
const endpoint = endpointMap![name];
|
|
99
112
|
if (!endpoint) {
|
|
100
113
|
throw new Error(`Unknown tool: ${name}`);
|
|
101
114
|
}
|
|
102
115
|
|
|
103
|
-
return executeHandler(endpoint.tool, endpoint.handler, client, args,
|
|
116
|
+
return executeHandler(endpoint.tool, endpoint.handler, client, args, mcpOptions.capabilities);
|
|
104
117
|
});
|
|
105
118
|
}
|
|
106
119
|
|
|
107
120
|
/**
|
|
108
121
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
109
122
|
*/
|
|
110
|
-
export function selectTools(endpoints: Endpoint[], options
|
|
111
|
-
const filteredEndpoints = query(options
|
|
123
|
+
export function selectTools(endpoints: Endpoint[], options?: McpOptions): Endpoint[] {
|
|
124
|
+
const filteredEndpoints = query(options?.filters ?? [], endpoints);
|
|
112
125
|
|
|
113
126
|
let includedTools = filteredEndpoints;
|
|
114
127
|
|
|
115
128
|
if (includedTools.length > 0) {
|
|
116
|
-
if (options
|
|
129
|
+
if (options?.includeDynamicTools) {
|
|
117
130
|
includedTools = dynamicTools(includedTools);
|
|
118
131
|
}
|
|
119
132
|
} else {
|
|
120
|
-
if (options
|
|
133
|
+
if (options?.includeAllTools) {
|
|
121
134
|
includedTools = endpoints;
|
|
122
|
-
} else if (options
|
|
135
|
+
} else if (options?.includeDynamicTools) {
|
|
123
136
|
includedTools = dynamicTools(endpoints);
|
|
137
|
+
} else if (options?.includeCodeTools) {
|
|
138
|
+
includedTools = [codeTool()];
|
|
124
139
|
} else {
|
|
125
140
|
includedTools = endpoints;
|
|
126
141
|
}
|
|
127
142
|
}
|
|
128
143
|
|
|
129
|
-
const capabilities = { ...defaultClientCapabilities, ...options
|
|
144
|
+
const capabilities = { ...defaultClientCapabilities, ...options?.capabilities };
|
|
130
145
|
return applyCompatibilityTransformations(includedTools, capabilities);
|
|
131
146
|
}
|
|
132
147
|
|
package/src/stdio.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
|
-
import {
|
|
3
|
-
import { Endpoint } from './tools';
|
|
2
|
+
import { initMcpServer, newMcpServer } from './server';
|
|
4
3
|
import { McpOptions } from './options';
|
|
5
4
|
|
|
6
|
-
export const launchStdioServer = async (options: McpOptions
|
|
5
|
+
export const launchStdioServer = async (options: McpOptions) => {
|
|
7
6
|
const server = newMcpServer();
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
initMcpServer({ server, mcpOptions: options });
|
|
10
9
|
|
|
11
10
|
const transport = new StdioServerTransport();
|
|
12
11
|
await server.connect(transport);
|
package/stdio.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Endpoint } from "./tools.mjs";
|
|
2
1
|
import { McpOptions } from "./options.mjs";
|
|
3
|
-
export declare const launchStdioServer: (options: McpOptions
|
|
2
|
+
export declare const launchStdioServer: (options: McpOptions) => Promise<void>;
|
|
4
3
|
//# sourceMappingURL=stdio.d.mts.map
|
package/stdio.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAEO,EAAE,
|
|
1
|
+
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,iBAAiB,GAAU,SAAS,UAAU,kBAQ1D,CAAC"}
|
package/stdio.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Endpoint } from "./tools.js";
|
|
2
1
|
import { McpOptions } from "./options.js";
|
|
3
|
-
export declare const launchStdioServer: (options: McpOptions
|
|
2
|
+
export declare const launchStdioServer: (options: McpOptions) => Promise<void>;
|
|
4
3
|
//# sourceMappingURL=stdio.d.ts.map
|
package/stdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAEO,EAAE,
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,iBAAiB,GAAU,SAAS,UAAU,kBAQ1D,CAAC"}
|
package/stdio.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.launchStdioServer = void 0;
|
|
4
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
5
|
const server_1 = require("./server.js");
|
|
6
|
-
const launchStdioServer = async (options
|
|
6
|
+
const launchStdioServer = async (options) => {
|
|
7
7
|
const server = (0, server_1.newMcpServer)();
|
|
8
|
-
(0, server_1.
|
|
8
|
+
(0, server_1.initMcpServer)({ server, mcpOptions: options });
|
|
9
9
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
10
10
|
await server.connect(transport);
|
|
11
11
|
console.error('MCP Server running on stdio');
|
package/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AACjF,wCAAuD;AAGhD,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAmB,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,IAAA,qBAAY,GAAE,CAAC;IAE9B,IAAA,sBAAa,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
|
package/stdio.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
|
-
import {
|
|
3
|
-
export const launchStdioServer = async (options
|
|
2
|
+
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
3
|
+
export const launchStdioServer = async (options) => {
|
|
4
4
|
const server = newMcpServer();
|
|
5
|
-
|
|
5
|
+
initMcpServer({ server, mcpOptions: options });
|
|
6
6
|
const transport = new StdioServerTransport();
|
|
7
7
|
await server.connect(transport);
|
|
8
8
|
console.error('MCP Server running on stdio');
|
package/stdio.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OACzE,EAAE,
|
|
1
|
+
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OACzE,EAAE,aAAa,EAAE,YAAY,EAAE;AAGtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAmB,EAAE,EAAE;IAC7D,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|