cas-parser-node-mcp 1.9.0 → 1.10.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/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.map +1 -1
- package/code-tool-types.d.ts.map +1 -1
- 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 +245 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +240 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +8 -2
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +8 -2
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +260 -37
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +224 -37
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +1 -1
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +1 -1
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +22 -3
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +22 -3
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +2 -4
- package/http.d.mts.map +1 -1
- package/http.d.ts +2 -4
- package/http.d.ts.map +1 -1
- package/http.js +52 -19
- package/http.js.map +1 -1
- package/http.mjs +52 -19
- package/http.mjs.map +1 -1
- package/index.js +12 -11
- package/index.js.map +1 -1
- package/index.mjs +12 -11
- package/index.mjs.map +1 -1
- package/instructions.d.mts.map +1 -1
- package/instructions.d.ts.map +1 -1
- package/instructions.js +4 -13
- package/instructions.js.map +1 -1
- package/instructions.mjs +4 -13
- package/instructions.mjs.map +1 -1
- package/logger.d.mts +7 -0
- package/logger.d.mts.map +1 -0
- package/logger.d.ts +7 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +29 -0
- package/logger.js.map +1 -0
- package/logger.mjs +22 -0
- package/logger.mjs.map +1 -0
- package/options.d.mts +4 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +4 -0
- package/options.d.ts.map +1 -1
- package/options.js +23 -0
- package/options.js.map +1 -1
- package/options.mjs +23 -0
- package/options.mjs.map +1 -1
- package/package.json +32 -5
- package/server.d.mts.map +1 -1
- package/server.d.ts.map +1 -1
- package/server.js +7 -5
- package/server.js.map +1 -1
- package/server.mjs +7 -5
- package/server.mjs.map +1 -1
- package/src/code-tool-paths.cts +3 -0
- package/src/code-tool-types.ts +1 -0
- package/src/code-tool-worker.ts +291 -0
- package/src/code-tool.ts +291 -47
- package/src/docs-search-tool.ts +36 -4
- package/src/http.ts +53 -21
- package/src/index.ts +14 -12
- package/src/instructions.ts +4 -13
- package/src/logger.ts +28 -0
- package/src/options.ts +32 -0
- package/src/server.ts +11 -6
- package/src/stdio.ts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +2 -1
- package/stdio.js.map +1 -1
- package/stdio.mjs +2 -1
- package/stdio.mjs.map +1 -1
package/src/logger.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { pino, type Level, type Logger } from 'pino';
|
|
4
|
+
import pretty from 'pino-pretty';
|
|
5
|
+
|
|
6
|
+
let _logger: Logger | undefined;
|
|
7
|
+
|
|
8
|
+
export function configureLogger({ level, pretty: usePretty }: { level: Level; pretty: boolean }): void {
|
|
9
|
+
_logger = pino(
|
|
10
|
+
{
|
|
11
|
+
level,
|
|
12
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
13
|
+
formatters: {
|
|
14
|
+
level(label) {
|
|
15
|
+
return { level: label };
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
usePretty ? pretty({ colorize: true, levelFirst: true, destination: 2 }) : process.stderr,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getLogger(): Logger {
|
|
24
|
+
if (!_logger) {
|
|
25
|
+
throw new Error('Logger has not been configured. Call configureLogger() before using the logger.');
|
|
26
|
+
}
|
|
27
|
+
return _logger;
|
|
28
|
+
}
|
package/src/options.ts
CHANGED
|
@@ -8,19 +8,24 @@ import { readEnv } from './util';
|
|
|
8
8
|
|
|
9
9
|
export type CLIOptions = McpOptions & {
|
|
10
10
|
debug: boolean;
|
|
11
|
+
logFormat: 'json' | 'pretty';
|
|
11
12
|
transport: 'stdio' | 'http';
|
|
12
13
|
port: number | undefined;
|
|
13
14
|
socket: string | undefined;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export type McpOptions = {
|
|
18
|
+
includeCodeTool?: boolean | undefined;
|
|
17
19
|
includeDocsTools?: boolean | undefined;
|
|
18
20
|
stainlessApiKey?: string | undefined;
|
|
19
21
|
codeAllowHttpGets?: boolean | undefined;
|
|
20
22
|
codeAllowedMethods?: string[] | undefined;
|
|
21
23
|
codeBlockedMethods?: string[] | undefined;
|
|
24
|
+
codeExecutionMode: McpCodeExecutionMode;
|
|
22
25
|
};
|
|
23
26
|
|
|
27
|
+
export type McpCodeExecutionMode = 'stainless-sandbox' | 'local';
|
|
28
|
+
|
|
24
29
|
export function parseCLIOptions(): CLIOptions {
|
|
25
30
|
const opts = yargs(hideBin(process.argv))
|
|
26
31
|
.option('code-allow-http-gets', {
|
|
@@ -40,7 +45,19 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
40
45
|
description:
|
|
41
46
|
'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
42
47
|
})
|
|
48
|
+
.option('code-execution-mode', {
|
|
49
|
+
type: 'string',
|
|
50
|
+
choices: ['stainless-sandbox', 'local'],
|
|
51
|
+
default: 'stainless-sandbox',
|
|
52
|
+
description:
|
|
53
|
+
"Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
|
|
54
|
+
})
|
|
43
55
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
56
|
+
.option('log-format', {
|
|
57
|
+
type: 'string',
|
|
58
|
+
choices: ['json', 'pretty'],
|
|
59
|
+
description: 'Format for log output; defaults to json unless tty is detected',
|
|
60
|
+
})
|
|
44
61
|
.option('no-tools', {
|
|
45
62
|
type: 'string',
|
|
46
63
|
array: true,
|
|
@@ -82,18 +99,26 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
82
99
|
: argv.tools?.includes(toolType) ? true
|
|
83
100
|
: undefined;
|
|
84
101
|
|
|
102
|
+
const includeCodeTool = shouldIncludeToolType('code');
|
|
85
103
|
const includeDocsTools = shouldIncludeToolType('docs');
|
|
86
104
|
|
|
87
105
|
const transport = argv.transport as 'stdio' | 'http';
|
|
106
|
+
const logFormat =
|
|
107
|
+
argv.logFormat ? (argv.logFormat as 'json' | 'pretty')
|
|
108
|
+
: process.stderr.isTTY ? 'pretty'
|
|
109
|
+
: 'json';
|
|
88
110
|
|
|
89
111
|
return {
|
|
112
|
+
...(includeCodeTool !== undefined && { includeCodeTool }),
|
|
90
113
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
91
114
|
debug: !!argv.debug,
|
|
92
115
|
stainlessApiKey: argv.stainlessApiKey,
|
|
93
116
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
94
117
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
95
118
|
codeBlockedMethods: argv.codeBlockedMethods,
|
|
119
|
+
codeExecutionMode: argv.codeExecutionMode as McpCodeExecutionMode,
|
|
96
120
|
transport,
|
|
121
|
+
logFormat,
|
|
97
122
|
port: argv.port,
|
|
98
123
|
socket: argv.socket,
|
|
99
124
|
};
|
|
@@ -118,12 +143,19 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M
|
|
|
118
143
|
const queryObject = typeof query === 'string' ? qs.parse(query) : query;
|
|
119
144
|
const queryOptions = QueryOptions.parse(queryObject);
|
|
120
145
|
|
|
146
|
+
let codeTool: boolean | undefined =
|
|
147
|
+
queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
|
|
148
|
+
: queryOptions.tools?.includes('code') ? true
|
|
149
|
+
: defaultOptions.includeCodeTool;
|
|
150
|
+
|
|
121
151
|
let docsTools: boolean | undefined =
|
|
122
152
|
queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
123
153
|
: queryOptions.tools?.includes('docs') ? true
|
|
124
154
|
: defaultOptions.includeDocsTools;
|
|
125
155
|
|
|
126
156
|
return {
|
|
157
|
+
...(codeTool !== undefined && { includeCodeTool: codeTool }),
|
|
127
158
|
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
159
|
+
codeExecutionMode: defaultOptions.codeExecutionMode,
|
|
128
160
|
};
|
|
129
161
|
}
|
package/src/server.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const newMcpServer = async (stainlessApiKey: string | undefined) =>
|
|
|
20
20
|
new McpServer(
|
|
21
21
|
{
|
|
22
22
|
name: 'cas_parser_node_api',
|
|
23
|
-
version: '1.
|
|
23
|
+
version: '1.10.1',
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
instructions: await getInstructions(stainlessApiKey),
|
|
@@ -156,11 +156,16 @@ export async function initMcpServer(params: {
|
|
|
156
156
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
157
157
|
*/
|
|
158
158
|
export function selectTools(options?: McpOptions): McpTool[] {
|
|
159
|
-
const includedTools = [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
const includedTools = [];
|
|
160
|
+
|
|
161
|
+
if (options?.includeCodeTool ?? true) {
|
|
162
|
+
includedTools.push(
|
|
163
|
+
codeTool({
|
|
164
|
+
blockedMethods: blockedMethodsForCodeTool(options),
|
|
165
|
+
codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox',
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
164
169
|
if (options?.includeDocsTools ?? true) {
|
|
165
170
|
includedTools.push(docsSearchTool);
|
|
166
171
|
}
|
package/src/stdio.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { McpOptions } from './options';
|
|
3
3
|
import { initMcpServer, newMcpServer } from './server';
|
|
4
|
+
import { getLogger } from './logger';
|
|
4
5
|
|
|
5
6
|
export const launchStdioServer = async (mcpOptions: McpOptions) => {
|
|
6
7
|
const server = await newMcpServer(mcpOptions.stainlessApiKey);
|
|
@@ -9,5 +10,5 @@ export const launchStdioServer = async (mcpOptions: McpOptions) => {
|
|
|
9
10
|
|
|
10
11
|
const transport = new StdioServerTransport();
|
|
11
12
|
await server.connect(transport);
|
|
12
|
-
|
|
13
|
+
getLogger().info('MCP Server running on stdio');
|
|
13
14
|
};
|
package/stdio.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,kBAQ7D,CAAC"}
|
package/stdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,kBAQ7D,CAAC"}
|
package/stdio.js
CHANGED
|
@@ -3,12 +3,13 @@ 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 logger_1 = require("./logger.js");
|
|
6
7
|
const launchStdioServer = async (mcpOptions) => {
|
|
7
8
|
const server = await (0, server_1.newMcpServer)(mcpOptions.stainlessApiKey);
|
|
8
9
|
await (0, server_1.initMcpServer)({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
9
10
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
10
11
|
await server.connect(transport);
|
|
11
|
-
|
|
12
|
+
(0, logger_1.getLogger)().info('MCP Server running on stdio');
|
|
12
13
|
};
|
|
13
14
|
exports.launchStdioServer = launchStdioServer;
|
|
14
15
|
//# sourceMappingURL=stdio.js.map
|
package/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AAEjF,wCAAuD;
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AAEjF,wCAAuD;AACvD,wCAAqC;AAE9B,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAE9D,MAAM,IAAA,sBAAa,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,IAAA,kBAAS,GAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAClD,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
|
package/stdio.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
3
|
+
import { getLogger } from "./logger.mjs";
|
|
3
4
|
export const launchStdioServer = async (mcpOptions) => {
|
|
4
5
|
const server = await newMcpServer(mcpOptions.stainlessApiKey);
|
|
5
6
|
await initMcpServer({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
6
7
|
const transport = new StdioServerTransport();
|
|
7
8
|
await server.connect(transport);
|
|
8
|
-
|
|
9
|
+
getLogger().info('MCP Server running on stdio');
|
|
9
10
|
};
|
|
10
11
|
//# sourceMappingURL=stdio.mjs.map
|
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;OAEzE,EAAE,aAAa,EAAE,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OAEzE,EAAE,aAAa,EAAE,YAAY,EAAE;OAC/B,EAAE,SAAS,EAAE;AAEpB,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAE9D,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,SAAS,EAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAClD,CAAC,CAAC"}
|