@zavudev/sdk-mcp 0.23.0 → 0.25.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 +3 -3
- package/code-tool.d.mts +4 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +4 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +17 -4
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +18 -5
- package/code-tool.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 +4 -1
- package/headers.js.map +1 -1
- package/headers.mjs +4 -1
- package/headers.mjs.map +1 -1
- package/http.d.mts +8 -3
- package/http.d.mts.map +1 -1
- package/http.d.ts +8 -3
- package/http.d.ts.map +1 -1
- package/http.js +27 -10
- package/http.js.map +1 -1
- package/http.mjs +27 -10
- package/http.mjs.map +1 -1
- package/index.js +6 -2
- package/index.js.map +1 -1
- package/index.mjs +6 -2
- package/index.mjs.map +1 -1
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +526 -0
- package/methods.js.map +1 -0
- package/methods.mjs +522 -0
- package/methods.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 +31 -12
- package/options.js.map +1 -1
- package/options.mjs +31 -12
- package/options.mjs.map +1 -1
- package/package.json +15 -2
- package/server.d.mts +3 -3
- package/server.d.mts.map +1 -1
- package/server.d.ts +3 -3
- package/server.d.ts.map +1 -1
- package/server.js +47 -8
- package/server.js.map +1 -1
- package/server.mjs +45 -7
- package/server.mjs.map +1 -1
- package/src/code-tool.ts +28 -5
- package/src/headers.ts +3 -1
- package/src/http.ts +37 -13
- package/src/index.ts +6 -2
- package/src/methods.ts +546 -0
- package/src/options.ts +38 -12
- package/src/server.ts +56 -8
- package/src/stdio.ts +4 -3
- package/stdio.d.mts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +2 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +3 -3
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
package/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;AAmBA,0CAqEC;AAiBD,8CAYC;AArHD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AAgBpB,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,SAAS;QACf,WAAW,EACT,+HAA+H;KAClI,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;SACzE,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,6BAA6B;KAC3C,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,QAAQ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K;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,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
package/options.mjs
CHANGED
|
@@ -4,32 +4,47 @@ import { hideBin } from 'yargs/helpers';
|
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
export function parseCLIOptions() {
|
|
6
6
|
const opts = yargs(hideBin(process.argv))
|
|
7
|
-
.option('
|
|
7
|
+
.option('code-allow-http-gets', {
|
|
8
|
+
type: 'boolean',
|
|
9
|
+
description: 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
|
|
10
|
+
})
|
|
11
|
+
.option('code-allowed-methods', {
|
|
8
12
|
type: 'string',
|
|
9
13
|
array: true,
|
|
10
|
-
|
|
11
|
-
description: 'Use dynamic tools or all tools',
|
|
14
|
+
description: 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
12
15
|
})
|
|
13
|
-
.option('
|
|
16
|
+
.option('code-blocked-methods', {
|
|
14
17
|
type: 'string',
|
|
15
18
|
array: true,
|
|
16
|
-
|
|
17
|
-
description: 'Do not use any dynamic or all tools',
|
|
19
|
+
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.',
|
|
18
20
|
})
|
|
19
|
-
.option('
|
|
21
|
+
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
22
|
+
.option('no-tools', {
|
|
20
23
|
type: 'string',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
description: '
|
|
24
|
+
array: true,
|
|
25
|
+
choices: ['code', 'docs'],
|
|
26
|
+
description: 'Tools to explicitly disable',
|
|
24
27
|
})
|
|
25
28
|
.option('port', {
|
|
26
29
|
type: 'number',
|
|
30
|
+
default: 3000,
|
|
27
31
|
description: 'Port to serve on if using http transport',
|
|
28
32
|
})
|
|
29
|
-
.option('socket', {
|
|
33
|
+
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
34
|
+
.option('tools', {
|
|
35
|
+
type: 'string',
|
|
36
|
+
array: true,
|
|
37
|
+
choices: ['code', 'docs'],
|
|
38
|
+
description: 'Tools to explicitly enable',
|
|
39
|
+
})
|
|
40
|
+
.option('transport', {
|
|
30
41
|
type: 'string',
|
|
31
|
-
|
|
42
|
+
choices: ['stdio', 'http'],
|
|
43
|
+
default: 'stdio',
|
|
44
|
+
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
32
45
|
})
|
|
46
|
+
.env('MCP_SERVER')
|
|
47
|
+
.version(true)
|
|
33
48
|
.help();
|
|
34
49
|
const argv = opts.parseSync();
|
|
35
50
|
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
@@ -39,6 +54,10 @@ export function parseCLIOptions() {
|
|
|
39
54
|
const transport = argv.transport;
|
|
40
55
|
return {
|
|
41
56
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
57
|
+
debug: !!argv.debug,
|
|
58
|
+
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
59
|
+
codeAllowedMethods: argv.codeAllowedMethods,
|
|
60
|
+
codeBlockedMethods: argv.codeBlockedMethods,
|
|
42
61
|
transport,
|
|
43
62
|
port: argv.port,
|
|
44
63
|
socket: argv.socket,
|
package/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;
|
|
1
|
+
{"version":3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"name": "@zavudev/sdk-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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,14 +18,17 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@zavudev/sdk": "^0.
|
|
21
|
+
"@zavudev/sdk": "^0.25.0",
|
|
22
22
|
"@cloudflare/cabidela": "^0.2.4",
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
24
24
|
"@valtown/deno-http-worker": "^0.0.21",
|
|
25
|
+
"cookie-parser": "^1.4.6",
|
|
25
26
|
"cors": "^2.8.5",
|
|
26
27
|
"express": "^5.1.0",
|
|
27
28
|
"fuse.js": "^7.1.0",
|
|
28
29
|
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
|
|
30
|
+
"morgan": "^1.10.0",
|
|
31
|
+
"morgan-body": "^2.6.9",
|
|
29
32
|
"qs": "^6.14.1",
|
|
30
33
|
"typescript": "5.8.3",
|
|
31
34
|
"yargs": "^17.7.2",
|
|
@@ -109,6 +112,16 @@
|
|
|
109
112
|
"./index.mjs": {
|
|
110
113
|
"default": "./index.mjs"
|
|
111
114
|
},
|
|
115
|
+
"./methods": {
|
|
116
|
+
"import": "./methods.mjs",
|
|
117
|
+
"require": "./methods.js"
|
|
118
|
+
},
|
|
119
|
+
"./methods.js": {
|
|
120
|
+
"default": "./methods.js"
|
|
121
|
+
},
|
|
122
|
+
"./methods.mjs": {
|
|
123
|
+
"default": "./methods.mjs"
|
|
124
|
+
},
|
|
112
125
|
"./options": {
|
|
113
126
|
"import": "./options.mjs",
|
|
114
127
|
"require": "./options.js"
|
package/server.d.mts
CHANGED
|
@@ -6,8 +6,7 @@ import { McpOptions } from "./options.mjs";
|
|
|
6
6
|
import { HandlerFunction, McpTool } from "./types.mjs";
|
|
7
7
|
export { McpOptions } from "./options.mjs";
|
|
8
8
|
export { ClientOptions } from '@zavudev/sdk';
|
|
9
|
-
export declare const newMcpServer: () => McpServer
|
|
10
|
-
export declare const server: McpServer;
|
|
9
|
+
export declare const newMcpServer: () => Promise<McpServer>;
|
|
11
10
|
/**
|
|
12
11
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
12
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -16,7 +15,7 @@ export declare function initMcpServer(params: {
|
|
|
16
15
|
server: Server | McpServer;
|
|
17
16
|
clientOptions?: ClientOptions;
|
|
18
17
|
mcpOptions?: McpOptions;
|
|
19
|
-
}): void
|
|
18
|
+
}): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
21
|
*/
|
|
@@ -27,4 +26,5 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
27
26
|
export declare function executeHandler(handler: HandlerFunction, client: Zavudev, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
|
|
28
27
|
export declare const readEnv: (env: string) => string | undefined;
|
|
29
28
|
export declare const readEnvOrError: (env: string) => string;
|
|
29
|
+
export declare const requireValue: <T>(value: T | undefined, description: string) => T;
|
|
30
30
|
//# 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;OACrC,OAAO,MAAM,cAAc;OAG3B,EAAE,UAAU,EAAE;
|
|
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;OACrC,OAAO,MAAM,cAAc;OAG3B,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,cAAc;AAsC5C,eAAO,MAAM,YAAY,0BAUtB,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;CACzB,iBAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAU3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
|
package/server.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { McpOptions } from "./options.js";
|
|
|
6
6
|
import { HandlerFunction, McpTool } from "./types.js";
|
|
7
7
|
export { McpOptions } from "./options.js";
|
|
8
8
|
export { ClientOptions } from '@zavudev/sdk';
|
|
9
|
-
export declare const newMcpServer: () => McpServer
|
|
10
|
-
export declare const server: McpServer;
|
|
9
|
+
export declare const newMcpServer: () => Promise<McpServer>;
|
|
11
10
|
/**
|
|
12
11
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
12
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -16,7 +15,7 @@ export declare function initMcpServer(params: {
|
|
|
16
15
|
server: Server | McpServer;
|
|
17
16
|
clientOptions?: ClientOptions;
|
|
18
17
|
mcpOptions?: McpOptions;
|
|
19
|
-
}): void
|
|
18
|
+
}): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
21
|
*/
|
|
@@ -27,4 +26,5 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
27
26
|
export declare function executeHandler(handler: HandlerFunction, client: Zavudev, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
|
|
28
27
|
export declare const readEnv: (env: string) => string | undefined;
|
|
29
28
|
export declare const readEnvOrError: (env: string) => string;
|
|
29
|
+
export declare const requireValue: <T>(value: T | undefined, description: string) => T;
|
|
30
30
|
//# 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;OACrC,OAAO,MAAM,cAAc;OAG3B,EAAE,UAAU,EAAE;
|
|
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;OACrC,OAAO,MAAM,cAAc;OAG3B,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,cAAc;AAsC5C,eAAO,MAAM,YAAY,0BAUtB,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;CACzB,iBAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAU3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
|
package/server.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.requireValue = exports.readEnvOrError = exports.readEnv = exports.newMcpServer = void 0;
|
|
8
8
|
exports.initMcpServer = initMcpServer;
|
|
9
9
|
exports.selectTools = selectTools;
|
|
10
10
|
exports.executeHandler = executeHandler;
|
|
@@ -13,18 +13,46 @@ 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
|
|
16
|
+
const methods_1 = require("./methods.js");
|
|
17
|
+
async function getInstructions() {
|
|
18
|
+
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
19
|
+
const stainlessAPIKey = (0, exports.readEnv)('STAINLESS_API_KEY');
|
|
20
|
+
const response = await fetch((0, exports.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/zavudev', {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
23
|
+
});
|
|
24
|
+
let instructions;
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
27
|
+
instructions = `
|
|
28
|
+
This is the zavudev MCP server. You will use Code Mode to help the user perform
|
|
29
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
30
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
31
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
32
|
+
block: it can be as long as you need to get the job done!
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
instructions ??= (await response.json()).instructions;
|
|
36
|
+
instructions = `
|
|
37
|
+
The current time in Unix timestamps is ${Date.now()}.
|
|
38
|
+
|
|
39
|
+
${instructions}
|
|
40
|
+
`;
|
|
41
|
+
return instructions;
|
|
42
|
+
}
|
|
43
|
+
const newMcpServer = async () => new mcp_js_1.McpServer({
|
|
17
44
|
name: 'zavudev_sdk_api',
|
|
18
|
-
version: '0.
|
|
19
|
-
}, {
|
|
45
|
+
version: '0.25.0',
|
|
46
|
+
}, {
|
|
47
|
+
instructions: await getInstructions(),
|
|
48
|
+
capabilities: { tools: {}, logging: {} },
|
|
49
|
+
});
|
|
20
50
|
exports.newMcpServer = newMcpServer;
|
|
21
|
-
// Create server instance
|
|
22
|
-
exports.server = (0, exports.newMcpServer)();
|
|
23
51
|
/**
|
|
24
52
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
25
53
|
* If not provided, the default client, tools and handlers will be used.
|
|
26
54
|
*/
|
|
27
|
-
function initMcpServer(params) {
|
|
55
|
+
async function initMcpServer(params) {
|
|
28
56
|
const server = params.server instanceof mcp_js_1.McpServer ? params.server.server : params.server;
|
|
29
57
|
const logAtLevel = (level) => (message, ...rest) => {
|
|
30
58
|
void server.sendLoggingMessage({
|
|
@@ -88,7 +116,11 @@ function initMcpServer(params) {
|
|
|
88
116
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
89
117
|
*/
|
|
90
118
|
function selectTools(options) {
|
|
91
|
-
const includedTools = [
|
|
119
|
+
const includedTools = [
|
|
120
|
+
(0, code_tool_1.codeTool)({
|
|
121
|
+
blockedMethods: (0, methods_1.blockedMethodsForCodeTool)(options),
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
92
124
|
if (options?.includeDocsTools ?? true) {
|
|
93
125
|
includedTools.push(docs_search_tool_1.default);
|
|
94
126
|
}
|
|
@@ -118,4 +150,11 @@ const readEnvOrError = (env) => {
|
|
|
118
150
|
return envValue;
|
|
119
151
|
};
|
|
120
152
|
exports.readEnvOrError = readEnvOrError;
|
|
153
|
+
const requireValue = (value, description) => {
|
|
154
|
+
if (value === undefined) {
|
|
155
|
+
throw new Error(`Missing required value: ${description}`);
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
};
|
|
159
|
+
exports.requireValue = requireValue;
|
|
121
160
|
//# 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;;;;;;AAwEtF,sCAwEC;AAKD,kCAUC;AAKD,wCAMC;AAvKD,oEAAoE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AAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB"}
|
package/server.mjs
CHANGED
|
@@ -4,17 +4,45 @@ import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, }
|
|
|
4
4
|
import Zavudev from '@zavudev/sdk';
|
|
5
5
|
import { codeTool } from "./code-tool.mjs";
|
|
6
6
|
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
|
-
|
|
7
|
+
import { blockedMethodsForCodeTool } from "./methods.mjs";
|
|
8
|
+
async function getInstructions() {
|
|
9
|
+
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
10
|
+
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
11
|
+
const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/zavudev', {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
14
|
+
});
|
|
15
|
+
let instructions;
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
18
|
+
instructions = `
|
|
19
|
+
This is the zavudev MCP server. You will use Code Mode to help the user perform
|
|
20
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
21
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
22
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
23
|
+
block: it can be as long as you need to get the job done!
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
instructions ??= (await response.json()).instructions;
|
|
27
|
+
instructions = `
|
|
28
|
+
The current time in Unix timestamps is ${Date.now()}.
|
|
29
|
+
|
|
30
|
+
${instructions}
|
|
31
|
+
`;
|
|
32
|
+
return instructions;
|
|
33
|
+
}
|
|
34
|
+
export const newMcpServer = async () => new McpServer({
|
|
8
35
|
name: 'zavudev_sdk_api',
|
|
9
|
-
version: '0.
|
|
10
|
-
}, {
|
|
11
|
-
|
|
12
|
-
|
|
36
|
+
version: '0.25.0',
|
|
37
|
+
}, {
|
|
38
|
+
instructions: await getInstructions(),
|
|
39
|
+
capabilities: { tools: {}, logging: {} },
|
|
40
|
+
});
|
|
13
41
|
/**
|
|
14
42
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
15
43
|
* If not provided, the default client, tools and handlers will be used.
|
|
16
44
|
*/
|
|
17
|
-
export function initMcpServer(params) {
|
|
45
|
+
export async function initMcpServer(params) {
|
|
18
46
|
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
19
47
|
const logAtLevel = (level) => (message, ...rest) => {
|
|
20
48
|
void server.sendLoggingMessage({
|
|
@@ -78,7 +106,11 @@ export function initMcpServer(params) {
|
|
|
78
106
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
79
107
|
*/
|
|
80
108
|
export function selectTools(options) {
|
|
81
|
-
const includedTools = [
|
|
109
|
+
const includedTools = [
|
|
110
|
+
codeTool({
|
|
111
|
+
blockedMethods: blockedMethodsForCodeTool(options),
|
|
112
|
+
}),
|
|
113
|
+
];
|
|
82
114
|
if (options?.includeDocsTools ?? true) {
|
|
83
115
|
includedTools.push(docsSearchTool);
|
|
84
116
|
}
|
|
@@ -106,4 +138,10 @@ export const readEnvOrError = (env) => {
|
|
|
106
138
|
}
|
|
107
139
|
return envValue;
|
|
108
140
|
};
|
|
141
|
+
export const requireValue = (value, description) => {
|
|
142
|
+
if (value === undefined) {
|
|
143
|
+
throw new Error(`Missing required value: ${description}`);
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
};
|
|
109
147
|
//# sourceMappingURL=server.mjs.map
|
package/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"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AW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,KAAoB,EAAE,WAAmB,EAAK,EAAE;IAC9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/src/code-tool.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult } from './types';
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { readEnv,
|
|
5
|
+
import { readEnv, requireValue } from './server';
|
|
6
6
|
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
7
|
+
import { SdkMethod } from './methods';
|
|
8
|
+
import { Zavudev } from '@zavudev/sdk';
|
|
7
9
|
|
|
8
10
|
const prompt = `Runs JavaScript code to interact with the Zavudev API.
|
|
9
11
|
|
|
@@ -34,7 +36,7 @@ Variables will not persist between calls, so make sure to return or log any data
|
|
|
34
36
|
*
|
|
35
37
|
* @param endpoints - The endpoints to include in the list.
|
|
36
38
|
*/
|
|
37
|
-
export function codeTool(): McpTool {
|
|
39
|
+
export function codeTool(params: { blockedMethods: SdkMethod[] | undefined }): McpTool {
|
|
38
40
|
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
39
41
|
const tool: Tool = {
|
|
40
42
|
name: 'execute',
|
|
@@ -54,10 +56,28 @@ export function codeTool(): McpTool {
|
|
|
54
56
|
required: ['code'],
|
|
55
57
|
},
|
|
56
58
|
};
|
|
57
|
-
const handler = async (
|
|
59
|
+
const handler = async (client: Zavudev, args: any): Promise<ToolCallResult> => {
|
|
58
60
|
const code = args.code as string;
|
|
59
61
|
const intent = args.intent as string | undefined;
|
|
60
62
|
|
|
63
|
+
// Do very basic blocking of code that includes forbidden method names.
|
|
64
|
+
//
|
|
65
|
+
// WARNING: This is not secure against obfuscation and other evasion methods. If
|
|
66
|
+
// stronger security blocks are required, then these should be enforced in the downstream
|
|
67
|
+
// API (e.g., by having users call the MCP server with API keys with limited permissions).
|
|
68
|
+
if (params.blockedMethods) {
|
|
69
|
+
const blockedMatches = params.blockedMethods.filter((method) =>
|
|
70
|
+
code.includes(method.fullyQualifiedName),
|
|
71
|
+
);
|
|
72
|
+
if (blockedMatches.length > 0) {
|
|
73
|
+
return asErrorResult(
|
|
74
|
+
`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches
|
|
75
|
+
.map((m) => m.fullyQualifiedName)
|
|
76
|
+
.join(', ')}`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
// this is not required, but passing a Stainless API key for the matching project_name
|
|
62
82
|
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
63
83
|
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
@@ -70,8 +90,11 @@ export function codeTool(): McpTool {
|
|
|
70
90
|
...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
|
|
71
91
|
'Content-Type': 'application/json',
|
|
72
92
|
client_envs: JSON.stringify({
|
|
73
|
-
ZAVUDEV_API_KEY:
|
|
74
|
-
|
|
93
|
+
ZAVUDEV_API_KEY: requireValue(
|
|
94
|
+
readEnv('ZAVUDEV_API_KEY') ?? client.apiKey,
|
|
95
|
+
'set ZAVUDEV_API_KEY environment variable or provide apiKey client option',
|
|
96
|
+
),
|
|
97
|
+
ZAVUDEV_BASE_URL: readEnv('ZAVUDEV_BASE_URL') ?? client.baseURL ?? undefined,
|
|
75
98
|
}),
|
|
76
99
|
},
|
|
77
100
|
body: JSON.stringify({
|
package/src/headers.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { IncomingMessage } from 'node:http';
|
|
4
4
|
import { ClientOptions } from '@zavudev/sdk';
|
|
5
5
|
|
|
6
|
-
export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> => {
|
|
6
|
+
export const parseAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => {
|
|
7
7
|
if (req.headers.authorization) {
|
|
8
8
|
const scheme = req.headers.authorization.split(' ')[0]!;
|
|
9
9
|
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
@@ -15,6 +15,8 @@ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> =
|
|
|
15
15
|
'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).',
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
|
+
} else if (required) {
|
|
19
|
+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
const apiKey =
|
package/src/http.ts
CHANGED
|
@@ -2,27 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
-
|
|
6
5
|
import express from 'express';
|
|
6
|
+
import morgan from 'morgan';
|
|
7
|
+
import morganBody from 'morgan-body';
|
|
7
8
|
import { McpOptions } from './options';
|
|
8
9
|
import { ClientOptions, initMcpServer, newMcpServer } from './server';
|
|
9
10
|
import { parseAuthHeaders } from './headers';
|
|
10
11
|
|
|
11
|
-
const newServer = ({
|
|
12
|
+
const newServer = async ({
|
|
12
13
|
clientOptions,
|
|
14
|
+
mcpOptions,
|
|
13
15
|
req,
|
|
14
16
|
res,
|
|
15
17
|
}: {
|
|
16
18
|
clientOptions: ClientOptions;
|
|
19
|
+
mcpOptions: McpOptions;
|
|
17
20
|
req: express.Request;
|
|
18
21
|
res: express.Response;
|
|
19
|
-
}): McpServer | null => {
|
|
20
|
-
const server = newMcpServer();
|
|
22
|
+
}): Promise<McpServer | null> => {
|
|
23
|
+
const server = await newMcpServer();
|
|
21
24
|
|
|
22
25
|
try {
|
|
23
|
-
const authOptions = parseAuthHeaders(req);
|
|
24
|
-
initMcpServer({
|
|
26
|
+
const authOptions = parseAuthHeaders(req, false);
|
|
27
|
+
await initMcpServer({
|
|
25
28
|
server: server,
|
|
29
|
+
mcpOptions: mcpOptions,
|
|
26
30
|
clientOptions: {
|
|
27
31
|
...clientOptions,
|
|
28
32
|
...authOptions,
|
|
@@ -45,7 +49,7 @@ const newServer = ({
|
|
|
45
49
|
const post =
|
|
46
50
|
(options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) =>
|
|
47
51
|
async (req: express.Request, res: express.Response) => {
|
|
48
|
-
const server = newServer({ ...options, req, res });
|
|
52
|
+
const server = await newServer({ ...options, req, res });
|
|
49
53
|
// If we return null, we already set the authorization error.
|
|
50
54
|
if (server === null) return;
|
|
51
55
|
const transport = new StreamableHTTPServerTransport();
|
|
@@ -75,15 +79,31 @@ const del = async (req: express.Request, res: express.Response) => {
|
|
|
75
79
|
|
|
76
80
|
export const streamableHTTPApp = ({
|
|
77
81
|
clientOptions = {},
|
|
78
|
-
mcpOptions
|
|
82
|
+
mcpOptions,
|
|
83
|
+
debug,
|
|
79
84
|
}: {
|
|
80
85
|
clientOptions?: ClientOptions;
|
|
81
|
-
mcpOptions
|
|
86
|
+
mcpOptions: McpOptions;
|
|
87
|
+
debug: boolean;
|
|
82
88
|
}): express.Express => {
|
|
83
89
|
const app = express();
|
|
84
90
|
app.set('query parser', 'extended');
|
|
85
91
|
app.use(express.json());
|
|
86
92
|
|
|
93
|
+
if (debug) {
|
|
94
|
+
morganBody(app, {
|
|
95
|
+
logAllReqHeader: true,
|
|
96
|
+
logAllResHeader: true,
|
|
97
|
+
logRequestBody: true,
|
|
98
|
+
logResponseBody: true,
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
app.use(morgan('combined'));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
app.get('/health', async (req: express.Request, res: express.Response) => {
|
|
105
|
+
res.status(200).send('OK');
|
|
106
|
+
});
|
|
87
107
|
app.get('/', get);
|
|
88
108
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
89
109
|
app.delete('/', del);
|
|
@@ -91,9 +111,13 @@ export const streamableHTTPApp = ({
|
|
|
91
111
|
return app;
|
|
92
112
|
};
|
|
93
113
|
|
|
94
|
-
export const launchStreamableHTTPServer = async (
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
export const launchStreamableHTTPServer = async (params: {
|
|
115
|
+
mcpOptions: McpOptions;
|
|
116
|
+
debug: boolean;
|
|
117
|
+
port: number | string | undefined;
|
|
118
|
+
}) => {
|
|
119
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
120
|
+
const server = app.listen(params.port);
|
|
97
121
|
const address = server.address();
|
|
98
122
|
|
|
99
123
|
if (typeof address === 'string') {
|
|
@@ -101,6 +125,6 @@ export const launchStreamableHTTPServer = async (options: McpOptions, port: numb
|
|
|
101
125
|
} else if (address !== null) {
|
|
102
126
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
103
127
|
} else {
|
|
104
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
128
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
105
129
|
}
|
|
106
130
|
};
|
package/src/index.ts
CHANGED
|
@@ -18,10 +18,14 @@ async function main() {
|
|
|
18
18
|
|
|
19
19
|
switch (options.transport) {
|
|
20
20
|
case 'stdio':
|
|
21
|
-
await launchStdioServer();
|
|
21
|
+
await launchStdioServer(options);
|
|
22
22
|
break;
|
|
23
23
|
case 'http':
|
|
24
|
-
await launchStreamableHTTPServer(
|
|
24
|
+
await launchStreamableHTTPServer({
|
|
25
|
+
mcpOptions: options,
|
|
26
|
+
debug: options.debug,
|
|
27
|
+
port: options.port ?? options.socket,
|
|
28
|
+
});
|
|
25
29
|
break;
|
|
26
30
|
}
|
|
27
31
|
}
|