@zavudev/sdk-mcp 0.26.0 → 0.27.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/auth.d.mts +3 -1
- package/auth.d.mts.map +1 -1
- package/auth.d.ts +3 -1
- package/auth.d.ts.map +1 -1
- package/auth.js +15 -3
- package/auth.js.map +1 -1
- package/auth.mjs +12 -1
- package/auth.mjs.map +1 -1
- 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 +301 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +296 -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 +247 -41
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +212 -42
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +9 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +9 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +2 -4
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +2 -4
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +1 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts +1 -1
- package/http.d.ts.map +1 -1
- package/http.js +16 -26
- package/http.js.map +1 -1
- package/http.mjs +17 -27
- package/http.mjs.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/instructions.d.mts +2 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +2 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +55 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +52 -0
- package/instructions.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 +21 -0
- package/options.js.map +1 -1
- package/options.mjs +21 -0
- package/options.mjs.map +1 -1
- package/package.json +29 -3
- package/server.d.mts +8 -4
- package/server.d.mts.map +1 -1
- package/server.d.ts +8 -4
- package/server.d.ts.map +1 -1
- package/server.js +72 -50
- package/server.js.map +1 -1
- package/server.mjs +72 -50
- package/server.mjs.map +1 -1
- package/src/auth.ts +16 -1
- package/src/code-tool-paths.cts +3 -0
- package/src/code-tool-types.ts +1 -0
- package/src/code-tool-worker.ts +347 -0
- package/src/code-tool.ts +286 -57
- package/src/docs-search-tool.ts +9 -6
- package/src/http.ts +22 -26
- package/src/index.ts +1 -1
- package/src/instructions.ts +74 -0
- package/src/options.ts +30 -0
- package/src/server.ts +85 -66
- package/src/stdio.ts +2 -2
- package/src/types.ts +12 -4
- package/stdio.js +2 -2
- package/stdio.js.map +1 -1
- package/stdio.mjs +2 -2
- package/stdio.mjs.map +1 -1
- package/types.d.mts +8 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +8 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
package/options.js
CHANGED
|
@@ -10,6 +10,7 @@ const qs_1 = __importDefault(require("qs"));
|
|
|
10
10
|
const yargs_1 = __importDefault(require("yargs"));
|
|
11
11
|
const helpers_1 = require("yargs/helpers");
|
|
12
12
|
const zod_1 = __importDefault(require("zod"));
|
|
13
|
+
const util_1 = require("./util.js");
|
|
13
14
|
function parseCLIOptions() {
|
|
14
15
|
const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
15
16
|
.option('code-allow-http-gets', {
|
|
@@ -25,6 +26,12 @@ function parseCLIOptions() {
|
|
|
25
26
|
type: 'string',
|
|
26
27
|
array: true,
|
|
27
28
|
description: '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.',
|
|
29
|
+
})
|
|
30
|
+
.option('code-execution-mode', {
|
|
31
|
+
type: 'string',
|
|
32
|
+
choices: ['stainless-sandbox', 'local'],
|
|
33
|
+
default: 'stainless-sandbox',
|
|
34
|
+
description: "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.",
|
|
28
35
|
})
|
|
29
36
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
30
37
|
.option('no-tools', {
|
|
@@ -39,6 +46,11 @@ function parseCLIOptions() {
|
|
|
39
46
|
description: 'Port to serve on if using http transport',
|
|
40
47
|
})
|
|
41
48
|
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
49
|
+
.option('stainless-api-key', {
|
|
50
|
+
type: 'string',
|
|
51
|
+
default: (0, util_1.readEnv)('STAINLESS_API_KEY'),
|
|
52
|
+
description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
53
|
+
})
|
|
42
54
|
.option('tools', {
|
|
43
55
|
type: 'string',
|
|
44
56
|
array: true,
|
|
@@ -58,14 +70,18 @@ function parseCLIOptions() {
|
|
|
58
70
|
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
59
71
|
: argv.tools?.includes(toolType) ? true
|
|
60
72
|
: undefined;
|
|
73
|
+
const includeCodeTool = shouldIncludeToolType('code');
|
|
61
74
|
const includeDocsTools = shouldIncludeToolType('docs');
|
|
62
75
|
const transport = argv.transport;
|
|
63
76
|
return {
|
|
77
|
+
...(includeCodeTool !== undefined && { includeCodeTool }),
|
|
64
78
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
65
79
|
debug: !!argv.debug,
|
|
80
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
66
81
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
67
82
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
68
83
|
codeBlockedMethods: argv.codeBlockedMethods,
|
|
84
|
+
codeExecutionMode: argv.codeExecutionMode,
|
|
69
85
|
transport,
|
|
70
86
|
port: argv.port,
|
|
71
87
|
socket: argv.socket,
|
|
@@ -82,11 +98,16 @@ const QueryOptions = zod_1.default.object({
|
|
|
82
98
|
function parseQueryOptions(defaultOptions, query) {
|
|
83
99
|
const queryObject = typeof query === 'string' ? qs_1.default.parse(query) : query;
|
|
84
100
|
const queryOptions = QueryOptions.parse(queryObject);
|
|
101
|
+
let codeTool = queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
|
|
102
|
+
: queryOptions.tools?.includes('code') ? true
|
|
103
|
+
: defaultOptions.includeCodeTool;
|
|
85
104
|
let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
86
105
|
: queryOptions.tools?.includes('docs') ? true
|
|
87
106
|
: defaultOptions.includeDocsTools;
|
|
88
107
|
return {
|
|
108
|
+
...(codeTool !== undefined && { includeCodeTool: codeTool }),
|
|
89
109
|
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
110
|
+
codeExecutionMode: defaultOptions.codeExecutionMode,
|
|
90
111
|
};
|
|
91
112
|
}
|
|
92
113
|
//# sourceMappingURL=options.js.map
|
package/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;AA2BtF,0CAsFC;AAiBD,8CAmBC;AAnJD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AACpB,oCAAiC;AAqBjC,SAA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C,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC;IAEnC,IAAI,SAAS,GACX,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QAC5D,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;QAC/D,iBAAiB,EAAE,cAAc,CAAC,iBAAiB;KACpD,CAAC;AACJ,CAAC"}
|
package/options.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import qs from 'qs';
|
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
5
|
import z from 'zod';
|
|
6
|
+
import { readEnv } from "./util.mjs";
|
|
6
7
|
export function parseCLIOptions() {
|
|
7
8
|
const opts = yargs(hideBin(process.argv))
|
|
8
9
|
.option('code-allow-http-gets', {
|
|
@@ -18,6 +19,12 @@ export function parseCLIOptions() {
|
|
|
18
19
|
type: 'string',
|
|
19
20
|
array: true,
|
|
20
21
|
description: '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.',
|
|
22
|
+
})
|
|
23
|
+
.option('code-execution-mode', {
|
|
24
|
+
type: 'string',
|
|
25
|
+
choices: ['stainless-sandbox', 'local'],
|
|
26
|
+
default: 'stainless-sandbox',
|
|
27
|
+
description: "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.",
|
|
21
28
|
})
|
|
22
29
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
23
30
|
.option('no-tools', {
|
|
@@ -32,6 +39,11 @@ export function parseCLIOptions() {
|
|
|
32
39
|
description: 'Port to serve on if using http transport',
|
|
33
40
|
})
|
|
34
41
|
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
42
|
+
.option('stainless-api-key', {
|
|
43
|
+
type: 'string',
|
|
44
|
+
default: readEnv('STAINLESS_API_KEY'),
|
|
45
|
+
description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
46
|
+
})
|
|
35
47
|
.option('tools', {
|
|
36
48
|
type: 'string',
|
|
37
49
|
array: true,
|
|
@@ -51,14 +63,18 @@ export function parseCLIOptions() {
|
|
|
51
63
|
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
52
64
|
: argv.tools?.includes(toolType) ? true
|
|
53
65
|
: undefined;
|
|
66
|
+
const includeCodeTool = shouldIncludeToolType('code');
|
|
54
67
|
const includeDocsTools = shouldIncludeToolType('docs');
|
|
55
68
|
const transport = argv.transport;
|
|
56
69
|
return {
|
|
70
|
+
...(includeCodeTool !== undefined && { includeCodeTool }),
|
|
57
71
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
58
72
|
debug: !!argv.debug,
|
|
73
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
59
74
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
60
75
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
61
76
|
codeBlockedMethods: argv.codeBlockedMethods,
|
|
77
|
+
codeExecutionMode: argv.codeExecutionMode,
|
|
62
78
|
transport,
|
|
63
79
|
port: argv.port,
|
|
64
80
|
socket: argv.socket,
|
|
@@ -75,11 +91,16 @@ const QueryOptions = z.object({
|
|
|
75
91
|
export function parseQueryOptions(defaultOptions, query) {
|
|
76
92
|
const queryObject = typeof query === 'string' ? qs.parse(query) : query;
|
|
77
93
|
const queryOptions = QueryOptions.parse(queryObject);
|
|
94
|
+
let codeTool = queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
|
|
95
|
+
: queryOptions.tools?.includes('code') ? true
|
|
96
|
+
: defaultOptions.includeCodeTool;
|
|
78
97
|
let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
79
98
|
: queryOptions.tools?.includes('docs') ? true
|
|
80
99
|
: defaultOptions.includeDocsTools;
|
|
81
100
|
return {
|
|
101
|
+
...(codeTool !== undefined && { includeCodeTool: codeTool }),
|
|
82
102
|
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
103
|
+
codeExecutionMode: defaultOptions.codeExecutionMode,
|
|
83
104
|
};
|
|
84
105
|
}
|
|
85
106
|
//# sourceMappingURL=options.mjs.map
|
package/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;
|
|
1
|
+
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;OACZ,EAAE,OAAO,EAAE;AAqBlB,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,SAAS;QACf,WAAW,EACT,+HAA+H;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YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QAC5D,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;QAC/D,iBAAiB,EAAE,cAAc,CAAC,iBAAiB;KACpD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zavudev/sdk-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "The official MCP Server for the Zavudev API",
|
|
5
5
|
"author": "Zavudev <hi@zavu.dev>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@zavudev/sdk": "^0.
|
|
21
|
+
"@zavudev/sdk": "^0.27.0",
|
|
22
22
|
"@cloudflare/cabidela": "^0.2.4",
|
|
23
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
24
24
|
"@valtown/deno-http-worker": "^0.0.21",
|
|
25
25
|
"cookie-parser": "^1.4.6",
|
|
26
26
|
"cors": "^2.8.5",
|
|
@@ -62,6 +62,12 @@
|
|
|
62
62
|
"./auth.mjs": {
|
|
63
63
|
"default": "./auth.mjs"
|
|
64
64
|
},
|
|
65
|
+
"./code-tool-paths": {
|
|
66
|
+
"require": "./code-tool-paths.cjs"
|
|
67
|
+
},
|
|
68
|
+
"./code-tool-paths.cjs": {
|
|
69
|
+
"default": "./code-tool-paths.cjs"
|
|
70
|
+
},
|
|
65
71
|
"./code-tool-types": {
|
|
66
72
|
"import": "./code-tool-types.mjs",
|
|
67
73
|
"require": "./code-tool-types.js"
|
|
@@ -72,6 +78,16 @@
|
|
|
72
78
|
"./code-tool-types.mjs": {
|
|
73
79
|
"default": "./code-tool-types.mjs"
|
|
74
80
|
},
|
|
81
|
+
"./code-tool-worker": {
|
|
82
|
+
"import": "./code-tool-worker.mjs",
|
|
83
|
+
"require": "./code-tool-worker.js"
|
|
84
|
+
},
|
|
85
|
+
"./code-tool-worker.js": {
|
|
86
|
+
"default": "./code-tool-worker.js"
|
|
87
|
+
},
|
|
88
|
+
"./code-tool-worker.mjs": {
|
|
89
|
+
"default": "./code-tool-worker.mjs"
|
|
90
|
+
},
|
|
75
91
|
"./code-tool": {
|
|
76
92
|
"import": "./code-tool.mjs",
|
|
77
93
|
"require": "./code-tool.js"
|
|
@@ -112,6 +128,16 @@
|
|
|
112
128
|
"./index.mjs": {
|
|
113
129
|
"default": "./index.mjs"
|
|
114
130
|
},
|
|
131
|
+
"./instructions": {
|
|
132
|
+
"import": "./instructions.mjs",
|
|
133
|
+
"require": "./instructions.js"
|
|
134
|
+
},
|
|
135
|
+
"./instructions.js": {
|
|
136
|
+
"default": "./instructions.js"
|
|
137
|
+
},
|
|
138
|
+
"./instructions.mjs": {
|
|
139
|
+
"default": "./instructions.mjs"
|
|
140
|
+
},
|
|
115
141
|
"./methods": {
|
|
116
142
|
"import": "./methods.mjs",
|
|
117
143
|
"require": "./methods.js"
|
package/server.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { ClientOptions } from '@zavudev/sdk';
|
|
4
|
-
import Zavudev from '@zavudev/sdk';
|
|
5
4
|
import { McpOptions } from "./options.mjs";
|
|
6
|
-
import { HandlerFunction, McpTool } from "./types.mjs";
|
|
7
|
-
export declare const newMcpServer: () => Promise<McpServer>;
|
|
5
|
+
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.mjs";
|
|
6
|
+
export declare const newMcpServer: (stainlessApiKey: string | undefined) => Promise<McpServer>;
|
|
8
7
|
/**
|
|
9
8
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
10
9
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -13,6 +12,7 @@ export declare function initMcpServer(params: {
|
|
|
13
12
|
server: Server | McpServer;
|
|
14
13
|
clientOptions?: ClientOptions;
|
|
15
14
|
mcpOptions?: McpOptions;
|
|
15
|
+
stainlessApiKey?: string | undefined;
|
|
16
16
|
}): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
@@ -21,5 +21,9 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
21
21
|
/**
|
|
22
22
|
* Runs the provided handler with the given client and arguments.
|
|
23
23
|
*/
|
|
24
|
-
export declare function executeHandler(handler
|
|
24
|
+
export declare function executeHandler({ handler, reqContext, args, }: {
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
reqContext: McpRequestContext;
|
|
27
|
+
args: Record<string, unknown> | undefined;
|
|
28
|
+
}): Promise<ToolCallResult>;
|
|
25
29
|
//# sourceMappingURL=server.d.mts.map
|
package/server.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OAKrC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,iBAAiB,MAAM,GAAG,SAAS,uBAUnE,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,iBAiHA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAe3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GACL,EAAE;IACD,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,cAAc,CAAC,CAE1B"}
|
package/server.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { ClientOptions } from '@zavudev/sdk';
|
|
4
|
-
import Zavudev from '@zavudev/sdk';
|
|
5
4
|
import { McpOptions } from "./options.js";
|
|
6
|
-
import { HandlerFunction, McpTool } from "./types.js";
|
|
7
|
-
export declare const newMcpServer: () => Promise<McpServer>;
|
|
5
|
+
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.js";
|
|
6
|
+
export declare const newMcpServer: (stainlessApiKey: string | undefined) => Promise<McpServer>;
|
|
8
7
|
/**
|
|
9
8
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
10
9
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -13,6 +12,7 @@ export declare function initMcpServer(params: {
|
|
|
13
12
|
server: Server | McpServer;
|
|
14
13
|
clientOptions?: ClientOptions;
|
|
15
14
|
mcpOptions?: McpOptions;
|
|
15
|
+
stainlessApiKey?: string | undefined;
|
|
16
16
|
}): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
@@ -21,5 +21,9 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
21
21
|
/**
|
|
22
22
|
* Runs the provided handler with the given client and arguments.
|
|
23
23
|
*/
|
|
24
|
-
export declare function executeHandler(handler
|
|
24
|
+
export declare function executeHandler({ handler, reqContext, args, }: {
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
reqContext: McpRequestContext;
|
|
27
|
+
args: Record<string, unknown> | undefined;
|
|
28
|
+
}): Promise<ToolCallResult>;
|
|
25
29
|
//# sourceMappingURL=server.d.ts.map
|
package/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OAKrC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,iBAAiB,MAAM,GAAG,SAAS,uBAUnE,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,iBAiHA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAe3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GACL,EAAE;IACD,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,cAAc,CAAC,CAE1B"}
|
package/server.js
CHANGED
|
@@ -13,39 +13,13 @@ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
13
13
|
const sdk_1 = __importDefault(require("@zavudev/sdk"));
|
|
14
14
|
const code_tool_1 = require("./code-tool.js");
|
|
15
15
|
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
|
+
const instructions_1 = require("./instructions.js");
|
|
16
17
|
const methods_1 = require("./methods.js");
|
|
17
|
-
const
|
|
18
|
-
async function getInstructions() {
|
|
19
|
-
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
20
|
-
const stainlessAPIKey = (0, util_1.readEnv)('STAINLESS_API_KEY');
|
|
21
|
-
const response = await fetch((0, util_1.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/zavudev', {
|
|
22
|
-
method: 'GET',
|
|
23
|
-
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
24
|
-
});
|
|
25
|
-
let instructions;
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
28
|
-
instructions = `
|
|
29
|
-
This is the zavudev MCP server. You will use Code Mode to help the user perform
|
|
30
|
-
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
31
|
-
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
32
|
-
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
33
|
-
block: it can be as long as you need to get the job done!
|
|
34
|
-
`;
|
|
35
|
-
}
|
|
36
|
-
instructions ??= (await response.json()).instructions;
|
|
37
|
-
instructions = `
|
|
38
|
-
The current time in Unix timestamps is ${Date.now()}.
|
|
39
|
-
|
|
40
|
-
${instructions}
|
|
41
|
-
`;
|
|
42
|
-
return instructions;
|
|
43
|
-
}
|
|
44
|
-
const newMcpServer = async () => new mcp_js_1.McpServer({
|
|
18
|
+
const newMcpServer = async (stainlessApiKey) => new mcp_js_1.McpServer({
|
|
45
19
|
name: 'zavudev_sdk_api',
|
|
46
|
-
version: '0.
|
|
20
|
+
version: '0.27.0',
|
|
47
21
|
}, {
|
|
48
|
-
instructions: await getInstructions(),
|
|
22
|
+
instructions: await (0, instructions_1.getInstructions)(stainlessApiKey),
|
|
49
23
|
capabilities: { tools: {}, logging: {} },
|
|
50
24
|
});
|
|
51
25
|
exports.newMcpServer = newMcpServer;
|
|
@@ -67,14 +41,33 @@ async function initMcpServer(params) {
|
|
|
67
41
|
warn: logAtLevel('warning'),
|
|
68
42
|
error: logAtLevel('error'),
|
|
69
43
|
};
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
let _client;
|
|
45
|
+
let _clientError;
|
|
46
|
+
let _logLevel;
|
|
47
|
+
const getClient = () => {
|
|
48
|
+
if (_clientError)
|
|
49
|
+
throw _clientError;
|
|
50
|
+
if (!_client) {
|
|
51
|
+
try {
|
|
52
|
+
_client = new sdk_1.default({
|
|
53
|
+
logger,
|
|
54
|
+
...params.clientOptions,
|
|
55
|
+
defaultHeaders: {
|
|
56
|
+
...params.clientOptions?.defaultHeaders,
|
|
57
|
+
'X-Stainless-MCP': 'true',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (_logLevel) {
|
|
61
|
+
_client = _client.withOptions({ logLevel: _logLevel });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
_clientError = e instanceof Error ? e : new Error(String(e));
|
|
66
|
+
throw _clientError;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return _client;
|
|
70
|
+
};
|
|
78
71
|
const providedTools = selectTools(params.mcpOptions);
|
|
79
72
|
const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
|
|
80
73
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
@@ -88,28 +81,55 @@ async function initMcpServer(params) {
|
|
|
88
81
|
if (!mcpTool) {
|
|
89
82
|
throw new Error(`Unknown tool: ${name}`);
|
|
90
83
|
}
|
|
91
|
-
|
|
84
|
+
let client;
|
|
85
|
+
try {
|
|
86
|
+
client = getClient();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: `Failed to initialize client: ${error instanceof Error ? error.message : String(error)}`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return executeHandler({
|
|
100
|
+
handler: mcpTool.handler,
|
|
101
|
+
reqContext: {
|
|
102
|
+
client,
|
|
103
|
+
stainlessApiKey: params.stainlessApiKey ?? params.mcpOptions?.stainlessApiKey,
|
|
104
|
+
},
|
|
105
|
+
args,
|
|
106
|
+
});
|
|
92
107
|
});
|
|
93
108
|
server.setRequestHandler(types_js_1.SetLevelRequestSchema, async (request) => {
|
|
94
109
|
const { level } = request.params;
|
|
110
|
+
let logLevel;
|
|
95
111
|
switch (level) {
|
|
96
112
|
case 'debug':
|
|
97
|
-
|
|
113
|
+
logLevel = 'debug';
|
|
98
114
|
break;
|
|
99
115
|
case 'info':
|
|
100
|
-
|
|
116
|
+
logLevel = 'info';
|
|
101
117
|
break;
|
|
102
118
|
case 'notice':
|
|
103
119
|
case 'warning':
|
|
104
|
-
|
|
120
|
+
logLevel = 'warn';
|
|
105
121
|
break;
|
|
106
122
|
case 'error':
|
|
107
|
-
|
|
123
|
+
logLevel = 'error';
|
|
108
124
|
break;
|
|
109
125
|
default:
|
|
110
|
-
|
|
126
|
+
logLevel = 'off';
|
|
111
127
|
break;
|
|
112
128
|
}
|
|
129
|
+
_logLevel = logLevel;
|
|
130
|
+
if (_client) {
|
|
131
|
+
_client = _client.withOptions({ logLevel });
|
|
132
|
+
}
|
|
113
133
|
return {};
|
|
114
134
|
});
|
|
115
135
|
}
|
|
@@ -117,11 +137,13 @@ async function initMcpServer(params) {
|
|
|
117
137
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
118
138
|
*/
|
|
119
139
|
function selectTools(options) {
|
|
120
|
-
const includedTools = [
|
|
121
|
-
|
|
140
|
+
const includedTools = [];
|
|
141
|
+
if (options?.includeCodeTool ?? true) {
|
|
142
|
+
includedTools.push((0, code_tool_1.codeTool)({
|
|
122
143
|
blockedMethods: (0, methods_1.blockedMethodsForCodeTool)(options),
|
|
123
|
-
|
|
124
|
-
|
|
144
|
+
codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox',
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
125
147
|
if (options?.includeDocsTools ?? true) {
|
|
126
148
|
includedTools.push(docs_search_tool_1.default);
|
|
127
149
|
}
|
|
@@ -130,7 +152,7 @@ function selectTools(options) {
|
|
|
130
152
|
/**
|
|
131
153
|
* Runs the provided handler with the given client and arguments.
|
|
132
154
|
*/
|
|
133
|
-
async function executeHandler(handler,
|
|
134
|
-
return await handler(
|
|
155
|
+
async function executeHandler({ handler, reqContext, args, }) {
|
|
156
|
+
return await handler({ reqContext, args: args || {} });
|
|
135
157
|
}
|
|
136
158
|
//# sourceMappingURL=server.js.map
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAkCtF,sCAsHC;AAKD,kCAeC;AAKD,wCAUC;AAxLD,oEAAoE;AACpE,iEAI4C;AAE5C,uDAAmC;AACnC,8CAAuC;AACvC,6EAAgD;AAChD,oDAAiD;AAEjD,0CAAsD;AAG/C,MAAM,YAAY,GAAG,KAAK,EAAE,eAAmC,EAAE,EAAE,CACxE,IAAI,kBAAS,CACX;IACE,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,QAAQ;CAClB,EACD;IACE,YAAY,EAAE,MAAM,IAAA,8BAAe,EAAC,eAAe,CAAC;IACpD,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;CACzC,CACF,CAAC;AAVS,QAAA,YAAY,gBAUrB;AAEJ;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,MAKnC;IACC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,YAAY,kBAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEzF,MAAM,UAAU,GACd,CAAC,KAA6C,EAAE,EAAE,CAClD,CAAC,OAAe,EAAE,GAAG,IAAe,EAA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