cas-parser-node-mcp 1.8.0 → 1.10.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 +1 -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.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 +257 -39
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +221 -39
- 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 +18 -2
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +18 -2
- 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 +2 -1
- package/instructions.js.map +1 -1
- package/instructions.mjs +2 -1
- 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 -7
- package/server.js.map +1 -1
- package/server.mjs +7 -7
- 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 +287 -51
- package/src/docs-search-tool.ts +27 -3
- package/src/http.ts +53 -21
- package/src/index.ts +14 -12
- package/src/instructions.ts +2 -1
- package/src/logger.ts +28 -0
- package/src/options.ts +32 -0
- package/src/server.ts +11 -8
- 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/docs-search-tool.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
4
3
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
5
|
+
import { getLogger } from './logger';
|
|
5
6
|
|
|
6
7
|
export const metadata: Metadata = {
|
|
7
8
|
resource: 'all',
|
|
@@ -50,19 +51,42 @@ export const handler = async ({
|
|
|
50
51
|
}) => {
|
|
51
52
|
const body = args as any;
|
|
52
53
|
const query = new URLSearchParams(body).toString();
|
|
54
|
+
|
|
55
|
+
const startTime = Date.now();
|
|
53
56
|
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
54
57
|
headers: {
|
|
55
58
|
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
56
59
|
},
|
|
57
60
|
});
|
|
58
61
|
|
|
62
|
+
const logger = getLogger();
|
|
63
|
+
|
|
59
64
|
if (!result.ok) {
|
|
65
|
+
const errorText = await result.text();
|
|
66
|
+
logger.warn(
|
|
67
|
+
{
|
|
68
|
+
durationMs: Date.now() - startTime,
|
|
69
|
+
query: body.query,
|
|
70
|
+
status: result.status,
|
|
71
|
+
statusText: result.statusText,
|
|
72
|
+
errorText,
|
|
73
|
+
},
|
|
74
|
+
'Got error response from docs search tool',
|
|
75
|
+
);
|
|
60
76
|
throw new Error(
|
|
61
|
-
`${result.status}: ${result.statusText} when using doc search tool. Details: ${
|
|
77
|
+
`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`,
|
|
62
78
|
);
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
|
|
81
|
+
const resultBody = await result.json();
|
|
82
|
+
logger.info(
|
|
83
|
+
{
|
|
84
|
+
durationMs: Date.now() - startTime,
|
|
85
|
+
query: body.query,
|
|
86
|
+
},
|
|
87
|
+
'Got docs search result',
|
|
88
|
+
);
|
|
89
|
+
return asTextContentResult(resultBody);
|
|
66
90
|
};
|
|
67
91
|
|
|
68
92
|
export default { metadata, tool, handler };
|
package/src/http.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
5
|
import { ClientOptions } from 'cas-parser-node';
|
|
6
6
|
import express from 'express';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import pino from 'pino';
|
|
8
|
+
import pinoHttp from 'pino-http';
|
|
9
9
|
import { getStainlessApiKey, parseClientAuthHeaders } from './auth';
|
|
10
|
+
import { getLogger } from './logger';
|
|
10
11
|
import { McpOptions } from './options';
|
|
11
12
|
import { initMcpServer, newMcpServer } from './server';
|
|
12
13
|
|
|
@@ -70,29 +71,60 @@ const del = async (req: express.Request, res: express.Response) => {
|
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
73
|
|
|
74
|
+
const redactHeaders = (headers: Record<string, any>) => {
|
|
75
|
+
const hiddenHeaders = /auth|cookie|key|token/i;
|
|
76
|
+
const filtered = { ...headers };
|
|
77
|
+
Object.keys(filtered).forEach((key) => {
|
|
78
|
+
if (hiddenHeaders.test(key)) {
|
|
79
|
+
filtered[key] = '[REDACTED]';
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return filtered;
|
|
83
|
+
};
|
|
84
|
+
|
|
73
85
|
export const streamableHTTPApp = ({
|
|
74
86
|
clientOptions = {},
|
|
75
87
|
mcpOptions,
|
|
76
|
-
debug,
|
|
77
88
|
}: {
|
|
78
89
|
clientOptions?: ClientOptions;
|
|
79
90
|
mcpOptions: McpOptions;
|
|
80
|
-
debug: boolean;
|
|
81
91
|
}): express.Express => {
|
|
82
92
|
const app = express();
|
|
83
93
|
app.set('query parser', 'extended');
|
|
84
94
|
app.use(express.json());
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
app.use(
|
|
96
|
+
pinoHttp({
|
|
97
|
+
logger: getLogger(),
|
|
98
|
+
customLogLevel: (req, res) => {
|
|
99
|
+
if (res.statusCode >= 500) {
|
|
100
|
+
return 'error';
|
|
101
|
+
} else if (res.statusCode >= 400) {
|
|
102
|
+
return 'warn';
|
|
103
|
+
}
|
|
104
|
+
return 'info';
|
|
105
|
+
},
|
|
106
|
+
customSuccessMessage: function (req, res) {
|
|
107
|
+
return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
|
|
108
|
+
},
|
|
109
|
+
customErrorMessage: function (req, res, err) {
|
|
110
|
+
return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
|
|
111
|
+
},
|
|
112
|
+
serializers: {
|
|
113
|
+
req: pino.stdSerializers.wrapRequestSerializer((req) => {
|
|
114
|
+
return {
|
|
115
|
+
...req,
|
|
116
|
+
headers: redactHeaders(req.raw.headers),
|
|
117
|
+
};
|
|
118
|
+
}),
|
|
119
|
+
res: pino.stdSerializers.wrapResponseSerializer((res) => {
|
|
120
|
+
return {
|
|
121
|
+
...res,
|
|
122
|
+
headers: redactHeaders(res.headers),
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
96
128
|
|
|
97
129
|
app.get('/health', async (req: express.Request, res: express.Response) => {
|
|
98
130
|
res.status(200).send('OK');
|
|
@@ -106,22 +138,22 @@ export const streamableHTTPApp = ({
|
|
|
106
138
|
|
|
107
139
|
export const launchStreamableHTTPServer = async ({
|
|
108
140
|
mcpOptions,
|
|
109
|
-
debug,
|
|
110
141
|
port,
|
|
111
142
|
}: {
|
|
112
143
|
mcpOptions: McpOptions;
|
|
113
|
-
debug: boolean;
|
|
114
144
|
port: number | string | undefined;
|
|
115
145
|
}) => {
|
|
116
|
-
const app = streamableHTTPApp({ mcpOptions
|
|
146
|
+
const app = streamableHTTPApp({ mcpOptions });
|
|
117
147
|
const server = app.listen(port);
|
|
118
148
|
const address = server.address();
|
|
119
149
|
|
|
150
|
+
const logger = getLogger();
|
|
151
|
+
|
|
120
152
|
if (typeof address === 'string') {
|
|
121
|
-
|
|
153
|
+
logger.info(`MCP Server running on streamable HTTP at ${address}`);
|
|
122
154
|
} else if (address !== null) {
|
|
123
|
-
|
|
155
|
+
logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
124
156
|
} else {
|
|
125
|
-
|
|
157
|
+
logger.info(`MCP Server running on streamable HTTP on port ${port}`);
|
|
126
158
|
}
|
|
127
159
|
};
|
package/src/index.ts
CHANGED
|
@@ -5,15 +5,20 @@ import { McpOptions, parseCLIOptions } from './options';
|
|
|
5
5
|
import { launchStdioServer } from './stdio';
|
|
6
6
|
import { launchStreamableHTTPServer } from './http';
|
|
7
7
|
import type { McpTool } from './types';
|
|
8
|
+
import { configureLogger, getLogger } from './logger';
|
|
8
9
|
|
|
9
10
|
async function main() {
|
|
10
11
|
const options = parseOptionsOrError();
|
|
12
|
+
configureLogger({
|
|
13
|
+
level: options.debug ? 'debug' : 'info',
|
|
14
|
+
pretty: options.logFormat === 'pretty',
|
|
15
|
+
});
|
|
11
16
|
|
|
12
17
|
const selectedTools = await selectToolsOrError(options);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
selectedTools.
|
|
19
|
+
getLogger().info(
|
|
20
|
+
{ tools: selectedTools.map((e) => e.tool.name) },
|
|
21
|
+
`MCP Server starting with ${selectedTools.length} tools`,
|
|
17
22
|
);
|
|
18
23
|
|
|
19
24
|
switch (options.transport) {
|
|
@@ -23,7 +28,6 @@ async function main() {
|
|
|
23
28
|
case 'http':
|
|
24
29
|
await launchStreamableHTTPServer({
|
|
25
30
|
mcpOptions: options,
|
|
26
|
-
debug: options.debug,
|
|
27
31
|
port: options.socket ?? options.port,
|
|
28
32
|
});
|
|
29
33
|
break;
|
|
@@ -32,7 +36,8 @@ async function main() {
|
|
|
32
36
|
|
|
33
37
|
if (require.main === module) {
|
|
34
38
|
main().catch((error) => {
|
|
35
|
-
|
|
39
|
+
// Logger might not be initialized yet
|
|
40
|
+
console.error('Fatal error in main()', error);
|
|
36
41
|
process.exit(1);
|
|
37
42
|
});
|
|
38
43
|
}
|
|
@@ -41,7 +46,8 @@ function parseOptionsOrError() {
|
|
|
41
46
|
try {
|
|
42
47
|
return parseCLIOptions();
|
|
43
48
|
} catch (error) {
|
|
44
|
-
|
|
49
|
+
// Logger is initialized after options, so use console.error here
|
|
50
|
+
console.error('Error parsing options', error);
|
|
45
51
|
process.exit(1);
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -50,16 +56,12 @@ async function selectToolsOrError(options: McpOptions): Promise<McpTool[]> {
|
|
|
50
56
|
try {
|
|
51
57
|
const includedTools = selectTools(options);
|
|
52
58
|
if (includedTools.length === 0) {
|
|
53
|
-
|
|
59
|
+
getLogger().error('No tools match the provided filters');
|
|
54
60
|
process.exit(1);
|
|
55
61
|
}
|
|
56
62
|
return includedTools;
|
|
57
63
|
} catch (error) {
|
|
58
|
-
|
|
59
|
-
console.error('Error filtering tools:', error.message);
|
|
60
|
-
} else {
|
|
61
|
-
console.error('Error filtering tools:', error);
|
|
62
|
-
}
|
|
64
|
+
getLogger().error({ error }, 'Error filtering tools');
|
|
63
65
|
process.exit(1);
|
|
64
66
|
}
|
|
65
67
|
}
|
package/src/instructions.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { readEnv } from './util';
|
|
4
|
+
import { getLogger } from './logger';
|
|
4
5
|
|
|
5
6
|
const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
6
7
|
|
|
@@ -50,7 +51,7 @@ async function fetchLatestInstructions(stainlessApiKey: string | undefined): Pro
|
|
|
50
51
|
|
|
51
52
|
let instructions: string | undefined;
|
|
52
53
|
if (!response.ok) {
|
|
53
|
-
|
|
54
|
+
getLogger().warn(
|
|
54
55
|
'Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...',
|
|
55
56
|
);
|
|
56
57
|
|
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
|
@@ -15,13 +15,12 @@ import { getInstructions } from './instructions';
|
|
|
15
15
|
import { McpOptions } from './options';
|
|
16
16
|
import { blockedMethodsForCodeTool } from './methods';
|
|
17
17
|
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types';
|
|
18
|
-
import { readEnv } from './util';
|
|
19
18
|
|
|
20
19
|
export const newMcpServer = async (stainlessApiKey: string | undefined) =>
|
|
21
20
|
new McpServer(
|
|
22
21
|
{
|
|
23
22
|
name: 'cas_parser_node_api',
|
|
24
|
-
version: '1.
|
|
23
|
+
version: '1.10.0',
|
|
25
24
|
},
|
|
26
25
|
{
|
|
27
26
|
instructions: await getInstructions(stainlessApiKey),
|
|
@@ -65,7 +64,6 @@ export async function initMcpServer(params: {
|
|
|
65
64
|
if (!_client) {
|
|
66
65
|
try {
|
|
67
66
|
_client = new CasParser({
|
|
68
|
-
...{ environment: (readEnv('CAS_PARSER_ENVIRONMENT') || undefined) as any },
|
|
69
67
|
logger,
|
|
70
68
|
...params.clientOptions,
|
|
71
69
|
defaultHeaders: {
|
|
@@ -158,11 +156,16 @@ export async function initMcpServer(params: {
|
|
|
158
156
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
159
157
|
*/
|
|
160
158
|
export function selectTools(options?: McpOptions): McpTool[] {
|
|
161
|
-
const includedTools = [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
+
}
|
|
166
169
|
if (options?.includeDocsTools ?? true) {
|
|
167
170
|
includedTools.push(docsSearchTool);
|
|
168
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"}
|