@imagekit/api-mcp 7.2.2 → 7.4.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 +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/{headers.mjs → auth.js} +21 -2
- package/auth.js.map +1 -0
- package/{headers.js → auth.mjs} +16 -6
- package/auth.mjs.map +1 -0
- package/code-tool-paths.cjs +8 -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 +314 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +276 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +11 -2
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +11 -2
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +285 -42
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +253 -43
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +11 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +11 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +58 -5
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +57 -5
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +6 -3
- package/http.d.mts.map +1 -1
- package/http.d.ts +6 -3
- package/http.d.ts.map +1 -1
- package/http.js +130 -28
- package/http.js.map +1 -1
- package/http.mjs +130 -28
- package/http.mjs.map +1 -1
- package/index.js +17 -12
- package/index.js.map +1 -1
- package/index.mjs +17 -12
- package/index.mjs.map +1 -1
- package/instructions.d.mts +5 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +5 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +61 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +55 -0
- package/instructions.mjs.map +1 -0
- package/local-docs-search.d.mts +28 -0
- package/local-docs-search.d.mts.map +1 -0
- package/local-docs-search.d.ts +28 -0
- package/local-docs-search.d.ts.map +1 -0
- package/local-docs-search.js +2807 -0
- package/local-docs-search.js.map +1 -0
- package/local-docs-search.mjs +2767 -0
- package/local-docs-search.mjs.map +1 -0
- 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/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 +349 -0
- package/methods.js.map +1 -0
- package/methods.mjs +345 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +12 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +12 -0
- package/options.d.ts.map +1 -1
- package/options.js +81 -12
- package/options.js.map +1 -1
- package/options.mjs +81 -12
- package/options.mjs.map +1 -1
- package/package.json +89 -15
- package/server.d.mts +18 -11
- package/server.d.mts.map +1 -1
- package/server.d.ts +18 -11
- package/server.d.ts.map +1 -1
- package/server.js +89 -49
- package/server.js.map +1 -1
- package/server.mjs +88 -45
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +18 -1
- package/src/code-tool-paths.cts +5 -0
- package/src/code-tool-types.ts +1 -0
- package/src/code-tool-worker.ts +327 -0
- package/src/code-tool.ts +339 -55
- package/src/docs-search-tool.ts +86 -7
- package/src/http.ts +154 -33
- package/src/index.ts +19 -13
- package/src/instructions.ts +83 -0
- package/src/local-docs-search.ts +3380 -0
- package/src/logger.ts +28 -0
- package/src/methods.ts +370 -0
- package/src/options.ts +105 -12
- package/src/server.ts +111 -57
- package/src/stdio.ts +9 -4
- package/src/types.ts +15 -4
- package/src/util.ts +25 -0
- 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 +8 -4
- package/stdio.js.map +1 -1
- package/stdio.mjs +8 -4
- package/stdio.mjs.map +1 -1
- package/types.d.mts +14 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +14 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
package/http.d.mts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { ClientOptions } from '@imagekit/nodejs';
|
|
1
2
|
import express from 'express';
|
|
2
3
|
import { McpOptions } from "./options.mjs";
|
|
3
|
-
import { ClientOptions } from "./server.mjs";
|
|
4
4
|
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
|
|
5
5
|
clientOptions?: ClientOptions;
|
|
6
|
-
mcpOptions
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
7
|
}) => express.Express;
|
|
8
|
-
export declare const launchStreamableHTTPServer: (
|
|
8
|
+
export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
|
|
9
|
+
mcpOptions: McpOptions;
|
|
10
|
+
port: number | string | undefined;
|
|
11
|
+
}) => Promise<void>;
|
|
9
12
|
//# sourceMappingURL=http.d.mts.map
|
package/http.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AAgIrB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OA4DX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}
|
package/http.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { ClientOptions } from '@imagekit/nodejs';
|
|
1
2
|
import express from 'express';
|
|
2
3
|
import { McpOptions } from "./options.js";
|
|
3
|
-
import { ClientOptions } from "./server.js";
|
|
4
4
|
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
|
|
5
5
|
clientOptions?: ClientOptions;
|
|
6
|
-
mcpOptions
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
7
|
}) => express.Express;
|
|
8
|
-
export declare const launchStreamableHTTPServer: (
|
|
8
|
+
export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
|
|
9
|
+
mcpOptions: McpOptions;
|
|
10
|
+
port: number | string | undefined;
|
|
11
|
+
}) => Promise<void>;
|
|
9
12
|
//# sourceMappingURL=http.d.ts.map
|
package/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AAgIrB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OA4DX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}
|
package/http.js
CHANGED
|
@@ -7,34 +7,76 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
|
|
8
8
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
9
|
const express_1 = __importDefault(require("express"));
|
|
10
|
+
const pino_1 = __importDefault(require("pino"));
|
|
11
|
+
const pino_http_1 = __importDefault(require("pino-http"));
|
|
12
|
+
const auth_1 = require("./auth.js");
|
|
13
|
+
const logger_1 = require("./logger.js");
|
|
10
14
|
const server_1 = require("./server.js");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
16
|
+
const stainlessApiKey = (0, auth_1.getStainlessApiKey)(req, mcpOptions);
|
|
17
|
+
const customInstructionsPath = mcpOptions.customInstructionsPath;
|
|
18
|
+
const server = await (0, server_1.newMcpServer)({ stainlessApiKey, customInstructionsPath });
|
|
19
|
+
const authOptions = (0, auth_1.parseClientAuthHeaders)(req, false);
|
|
20
|
+
let upstreamClientEnvs;
|
|
21
|
+
const clientEnvsHeader = req.headers['x-stainless-mcp-client-envs'];
|
|
22
|
+
if (typeof clientEnvsHeader === 'string') {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(clientEnvsHeader);
|
|
25
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
26
|
+
upstreamClientEnvs = parsed;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Ignore malformed header
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
// Parse x-stainless-mcp-client-permissions header to override permission options
|
|
34
|
+
//
|
|
35
|
+
// Note: Permissions are best-effort and intended to prevent clients from doing unexpected things;
|
|
36
|
+
// they're not a hard security boundary, so we allow arbitrary, client-driven overrides.
|
|
37
|
+
//
|
|
38
|
+
// See the Stainless MCP documentation for more details.
|
|
39
|
+
let effectiveMcpOptions = mcpOptions;
|
|
40
|
+
const clientPermissionsHeader = req.headers['x-stainless-mcp-client-permissions'];
|
|
41
|
+
if (typeof clientPermissionsHeader === 'string') {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(clientPermissionsHeader);
|
|
44
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
45
|
+
effectiveMcpOptions = {
|
|
46
|
+
...mcpOptions,
|
|
47
|
+
...(typeof parsed.allow_http_gets === 'boolean' && { codeAllowHttpGets: parsed.allow_http_gets }),
|
|
48
|
+
...(Array.isArray(parsed.allowed_methods) && { codeAllowedMethods: parsed.allowed_methods }),
|
|
49
|
+
...(Array.isArray(parsed.blocked_methods) && { codeBlockedMethods: parsed.blocked_methods }),
|
|
50
|
+
};
|
|
51
|
+
(0, logger_1.getLogger)().info({ clientPermissions: parsed }, 'Overriding code execution permissions from x-stainless-mcp-client-permissions header');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
(0, logger_1.getLogger)().warn({ error }, 'Failed to parse x-stainless-mcp-client-permissions header');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const mcpClientInfo = typeof req.body?.params?.clientInfo?.name === 'string' ?
|
|
59
|
+
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
|
|
60
|
+
: undefined;
|
|
61
|
+
await (0, server_1.initMcpServer)({
|
|
62
|
+
server: server,
|
|
63
|
+
mcpOptions: effectiveMcpOptions,
|
|
64
|
+
clientOptions: {
|
|
65
|
+
...clientOptions,
|
|
66
|
+
...authOptions,
|
|
67
|
+
},
|
|
68
|
+
stainlessApiKey: stainlessApiKey,
|
|
69
|
+
upstreamClientEnvs,
|
|
70
|
+
mcpSessionId: req.mcpSessionId,
|
|
71
|
+
mcpClientInfo,
|
|
72
|
+
});
|
|
73
|
+
if (mcpClientInfo) {
|
|
74
|
+
(0, logger_1.getLogger)().info({ mcpSessionId: req.mcpSessionId, mcpClientInfo }, 'MCP client connected');
|
|
33
75
|
}
|
|
34
76
|
return server;
|
|
35
77
|
};
|
|
36
78
|
const post = (options) => async (req, res) => {
|
|
37
|
-
const server = newServer({ ...options, req, res });
|
|
79
|
+
const server = await newServer({ ...options, req, res });
|
|
38
80
|
// If we return null, we already set the authorization error.
|
|
39
81
|
if (server === null)
|
|
40
82
|
return;
|
|
@@ -60,28 +102,88 @@ const del = async (req, res) => {
|
|
|
60
102
|
},
|
|
61
103
|
});
|
|
62
104
|
};
|
|
63
|
-
const
|
|
105
|
+
const redactHeaders = (headers) => {
|
|
106
|
+
const hiddenHeaders = /auth|cookie|key|token|x-stainless-mcp-client-envs/i;
|
|
107
|
+
const filtered = { ...headers };
|
|
108
|
+
Object.keys(filtered).forEach((key) => {
|
|
109
|
+
if (hiddenHeaders.test(key)) {
|
|
110
|
+
filtered[key] = '[REDACTED]';
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return filtered;
|
|
114
|
+
};
|
|
115
|
+
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
|
|
64
116
|
const app = (0, express_1.default)();
|
|
65
117
|
app.set('query parser', 'extended');
|
|
66
118
|
app.use(express_1.default.json());
|
|
119
|
+
app.use((req, res, next) => {
|
|
120
|
+
const existing = req.headers['mcp-session-id'];
|
|
121
|
+
const sessionId = (Array.isArray(existing) ? existing[0] : existing) || crypto.randomUUID();
|
|
122
|
+
req.mcpSessionId = sessionId;
|
|
123
|
+
const origWriteHead = res.writeHead.bind(res);
|
|
124
|
+
res.writeHead = function (statusCode, ...rest) {
|
|
125
|
+
res.setHeader('mcp-session-id', sessionId);
|
|
126
|
+
return origWriteHead(statusCode, ...rest);
|
|
127
|
+
};
|
|
128
|
+
next();
|
|
129
|
+
});
|
|
130
|
+
app.use((0, pino_http_1.default)({
|
|
131
|
+
logger: (0, logger_1.getLogger)(),
|
|
132
|
+
customProps: (req) => ({
|
|
133
|
+
mcpSessionId: req.mcpSessionId,
|
|
134
|
+
}),
|
|
135
|
+
customLogLevel: (req, res) => {
|
|
136
|
+
if (res.statusCode >= 500) {
|
|
137
|
+
return 'error';
|
|
138
|
+
}
|
|
139
|
+
else if (res.statusCode >= 400) {
|
|
140
|
+
return 'warn';
|
|
141
|
+
}
|
|
142
|
+
return 'info';
|
|
143
|
+
},
|
|
144
|
+
customSuccessMessage: function (req, res) {
|
|
145
|
+
return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
|
|
146
|
+
},
|
|
147
|
+
customErrorMessage: function (req, res, err) {
|
|
148
|
+
return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
|
|
149
|
+
},
|
|
150
|
+
serializers: {
|
|
151
|
+
req: pino_1.default.stdSerializers.wrapRequestSerializer((req) => {
|
|
152
|
+
return {
|
|
153
|
+
...req,
|
|
154
|
+
headers: redactHeaders(req.raw.headers),
|
|
155
|
+
};
|
|
156
|
+
}),
|
|
157
|
+
res: pino_1.default.stdSerializers.wrapResponseSerializer((res) => {
|
|
158
|
+
return {
|
|
159
|
+
...res,
|
|
160
|
+
headers: redactHeaders(res.headers),
|
|
161
|
+
};
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
164
|
+
}));
|
|
165
|
+
app.get('/health', async (req, res) => {
|
|
166
|
+
res.status(200).send('OK');
|
|
167
|
+
});
|
|
67
168
|
app.get('/', get);
|
|
68
169
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
69
170
|
app.delete('/', del);
|
|
70
171
|
return app;
|
|
71
172
|
};
|
|
72
173
|
exports.streamableHTTPApp = streamableHTTPApp;
|
|
73
|
-
const launchStreamableHTTPServer = async (
|
|
74
|
-
const app = (0, exports.streamableHTTPApp)({ mcpOptions
|
|
174
|
+
const launchStreamableHTTPServer = async ({ mcpOptions, port, }) => {
|
|
175
|
+
const app = (0, exports.streamableHTTPApp)({ mcpOptions });
|
|
75
176
|
const server = app.listen(port);
|
|
76
177
|
const address = server.address();
|
|
178
|
+
const logger = (0, logger_1.getLogger)();
|
|
77
179
|
if (typeof address === 'string') {
|
|
78
|
-
|
|
180
|
+
logger.info(`MCP Server running on streamable HTTP at ${address}`);
|
|
79
181
|
}
|
|
80
182
|
else if (address !== null) {
|
|
81
|
-
|
|
183
|
+
logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
82
184
|
}
|
|
83
185
|
else {
|
|
84
|
-
|
|
186
|
+
logger.info(`MCP Server running on streamable HTTP on port ${port}`);
|
|
85
187
|
}
|
|
86
188
|
};
|
|
87
189
|
exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
|
package/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGt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,CAAC;IACrE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,0BAA0B,8BAoBrC"}
|
package/http.mjs
CHANGED
|
@@ -1,34 +1,76 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
3
|
import express from 'express';
|
|
4
|
+
import pino from 'pino';
|
|
5
|
+
import pinoHttp from 'pino-http';
|
|
6
|
+
import { getStainlessApiKey, parseClientAuthHeaders } from "./auth.mjs";
|
|
7
|
+
import { getLogger } from "./logger.mjs";
|
|
4
8
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
10
|
+
const stainlessApiKey = getStainlessApiKey(req, mcpOptions);
|
|
11
|
+
const customInstructionsPath = mcpOptions.customInstructionsPath;
|
|
12
|
+
const server = await newMcpServer({ stainlessApiKey, customInstructionsPath });
|
|
13
|
+
const authOptions = parseClientAuthHeaders(req, false);
|
|
14
|
+
let upstreamClientEnvs;
|
|
15
|
+
const clientEnvsHeader = req.headers['x-stainless-mcp-client-envs'];
|
|
16
|
+
if (typeof clientEnvsHeader === 'string') {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(clientEnvsHeader);
|
|
19
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
20
|
+
upstreamClientEnvs = parsed;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Ignore malformed header
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// Parse x-stainless-mcp-client-permissions header to override permission options
|
|
28
|
+
//
|
|
29
|
+
// Note: Permissions are best-effort and intended to prevent clients from doing unexpected things;
|
|
30
|
+
// they're not a hard security boundary, so we allow arbitrary, client-driven overrides.
|
|
31
|
+
//
|
|
32
|
+
// See the Stainless MCP documentation for more details.
|
|
33
|
+
let effectiveMcpOptions = mcpOptions;
|
|
34
|
+
const clientPermissionsHeader = req.headers['x-stainless-mcp-client-permissions'];
|
|
35
|
+
if (typeof clientPermissionsHeader === 'string') {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(clientPermissionsHeader);
|
|
38
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
39
|
+
effectiveMcpOptions = {
|
|
40
|
+
...mcpOptions,
|
|
41
|
+
...(typeof parsed.allow_http_gets === 'boolean' && { codeAllowHttpGets: parsed.allow_http_gets }),
|
|
42
|
+
...(Array.isArray(parsed.allowed_methods) && { codeAllowedMethods: parsed.allowed_methods }),
|
|
43
|
+
...(Array.isArray(parsed.blocked_methods) && { codeBlockedMethods: parsed.blocked_methods }),
|
|
44
|
+
};
|
|
45
|
+
getLogger().info({ clientPermissions: parsed }, 'Overriding code execution permissions from x-stainless-mcp-client-permissions header');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
getLogger().warn({ error }, 'Failed to parse x-stainless-mcp-client-permissions header');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const mcpClientInfo = typeof req.body?.params?.clientInfo?.name === 'string' ?
|
|
53
|
+
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
|
|
54
|
+
: undefined;
|
|
55
|
+
await initMcpServer({
|
|
56
|
+
server: server,
|
|
57
|
+
mcpOptions: effectiveMcpOptions,
|
|
58
|
+
clientOptions: {
|
|
59
|
+
...clientOptions,
|
|
60
|
+
...authOptions,
|
|
61
|
+
},
|
|
62
|
+
stainlessApiKey: stainlessApiKey,
|
|
63
|
+
upstreamClientEnvs,
|
|
64
|
+
mcpSessionId: req.mcpSessionId,
|
|
65
|
+
mcpClientInfo,
|
|
66
|
+
});
|
|
67
|
+
if (mcpClientInfo) {
|
|
68
|
+
getLogger().info({ mcpSessionId: req.mcpSessionId, mcpClientInfo }, 'MCP client connected');
|
|
27
69
|
}
|
|
28
70
|
return server;
|
|
29
71
|
};
|
|
30
72
|
const post = (options) => async (req, res) => {
|
|
31
|
-
const server = newServer({ ...options, req, res });
|
|
73
|
+
const server = await newServer({ ...options, req, res });
|
|
32
74
|
// If we return null, we already set the authorization error.
|
|
33
75
|
if (server === null)
|
|
34
76
|
return;
|
|
@@ -54,27 +96,87 @@ const del = async (req, res) => {
|
|
|
54
96
|
},
|
|
55
97
|
});
|
|
56
98
|
};
|
|
57
|
-
|
|
99
|
+
const redactHeaders = (headers) => {
|
|
100
|
+
const hiddenHeaders = /auth|cookie|key|token|x-stainless-mcp-client-envs/i;
|
|
101
|
+
const filtered = { ...headers };
|
|
102
|
+
Object.keys(filtered).forEach((key) => {
|
|
103
|
+
if (hiddenHeaders.test(key)) {
|
|
104
|
+
filtered[key] = '[REDACTED]';
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return filtered;
|
|
108
|
+
};
|
|
109
|
+
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
|
|
58
110
|
const app = express();
|
|
59
111
|
app.set('query parser', 'extended');
|
|
60
112
|
app.use(express.json());
|
|
113
|
+
app.use((req, res, next) => {
|
|
114
|
+
const existing = req.headers['mcp-session-id'];
|
|
115
|
+
const sessionId = (Array.isArray(existing) ? existing[0] : existing) || crypto.randomUUID();
|
|
116
|
+
req.mcpSessionId = sessionId;
|
|
117
|
+
const origWriteHead = res.writeHead.bind(res);
|
|
118
|
+
res.writeHead = function (statusCode, ...rest) {
|
|
119
|
+
res.setHeader('mcp-session-id', sessionId);
|
|
120
|
+
return origWriteHead(statusCode, ...rest);
|
|
121
|
+
};
|
|
122
|
+
next();
|
|
123
|
+
});
|
|
124
|
+
app.use(pinoHttp({
|
|
125
|
+
logger: getLogger(),
|
|
126
|
+
customProps: (req) => ({
|
|
127
|
+
mcpSessionId: req.mcpSessionId,
|
|
128
|
+
}),
|
|
129
|
+
customLogLevel: (req, res) => {
|
|
130
|
+
if (res.statusCode >= 500) {
|
|
131
|
+
return 'error';
|
|
132
|
+
}
|
|
133
|
+
else if (res.statusCode >= 400) {
|
|
134
|
+
return 'warn';
|
|
135
|
+
}
|
|
136
|
+
return 'info';
|
|
137
|
+
},
|
|
138
|
+
customSuccessMessage: function (req, res) {
|
|
139
|
+
return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
|
|
140
|
+
},
|
|
141
|
+
customErrorMessage: function (req, res, err) {
|
|
142
|
+
return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
|
|
143
|
+
},
|
|
144
|
+
serializers: {
|
|
145
|
+
req: pino.stdSerializers.wrapRequestSerializer((req) => {
|
|
146
|
+
return {
|
|
147
|
+
...req,
|
|
148
|
+
headers: redactHeaders(req.raw.headers),
|
|
149
|
+
};
|
|
150
|
+
}),
|
|
151
|
+
res: pino.stdSerializers.wrapResponseSerializer((res) => {
|
|
152
|
+
return {
|
|
153
|
+
...res,
|
|
154
|
+
headers: redactHeaders(res.headers),
|
|
155
|
+
};
|
|
156
|
+
}),
|
|
157
|
+
},
|
|
158
|
+
}));
|
|
159
|
+
app.get('/health', async (req, res) => {
|
|
160
|
+
res.status(200).send('OK');
|
|
161
|
+
});
|
|
61
162
|
app.get('/', get);
|
|
62
163
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
63
164
|
app.delete('/', del);
|
|
64
165
|
return app;
|
|
65
166
|
};
|
|
66
|
-
export const launchStreamableHTTPServer = async (
|
|
67
|
-
const app = streamableHTTPApp({ mcpOptions
|
|
167
|
+
export const launchStreamableHTTPServer = async ({ mcpOptions, port, }) => {
|
|
168
|
+
const app = streamableHTTPApp({ mcpOptions });
|
|
68
169
|
const server = app.listen(port);
|
|
69
170
|
const address = server.address();
|
|
171
|
+
const logger = getLogger();
|
|
70
172
|
if (typeof address === 'string') {
|
|
71
|
-
|
|
173
|
+
logger.info(`MCP Server running on streamable HTTP at ${address}`);
|
|
72
174
|
}
|
|
73
175
|
else if (address !== null) {
|
|
74
|
-
|
|
176
|
+
logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
75
177
|
}
|
|
76
178
|
else {
|
|
77
|
-
|
|
179
|
+
logger.info(`MCP Server running on streamable HTTP on port ${port}`);
|
|
78
180
|
}
|
|
79
181
|
};
|
|
80
182
|
//# sourceMappingURL=http.mjs.map
|
package/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAE3F,OAAO,MAAM,SAAS;
|
|
1
|
+
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAE3F,OAAO,MAAM,SAAS;OACtB,IAAI,MAAM,MAAM;OAChB,QAAQ,MAAM,WAAW;OACzB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE;OAC9C,EAAE,SAAS,EAAE;OAEb,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa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,CAAC,CAAC"}
|
package/index.js
CHANGED
|
@@ -5,22 +5,31 @@ const server_1 = require("./server.js");
|
|
|
5
5
|
const options_1 = require("./options.js");
|
|
6
6
|
const stdio_1 = require("./stdio.js");
|
|
7
7
|
const http_1 = require("./http.js");
|
|
8
|
+
const logger_1 = require("./logger.js");
|
|
8
9
|
async function main() {
|
|
9
10
|
const options = parseOptionsOrError();
|
|
11
|
+
(0, logger_1.configureLogger)({
|
|
12
|
+
level: options.debug ? 'debug' : 'info',
|
|
13
|
+
pretty: options.logFormat === 'pretty',
|
|
14
|
+
});
|
|
10
15
|
const selectedTools = await selectToolsOrError(options);
|
|
11
|
-
|
|
16
|
+
(0, logger_1.getLogger)().info({ tools: selectedTools.map((e) => e.tool.name) }, `MCP Server starting with ${selectedTools.length} tools`);
|
|
12
17
|
switch (options.transport) {
|
|
13
18
|
case 'stdio':
|
|
14
|
-
await (0, stdio_1.launchStdioServer)();
|
|
19
|
+
await (0, stdio_1.launchStdioServer)(options);
|
|
15
20
|
break;
|
|
16
21
|
case 'http':
|
|
17
|
-
await (0, http_1.launchStreamableHTTPServer)(
|
|
22
|
+
await (0, http_1.launchStreamableHTTPServer)({
|
|
23
|
+
mcpOptions: options,
|
|
24
|
+
port: options.socket ?? options.port,
|
|
25
|
+
});
|
|
18
26
|
break;
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
if (require.main === module) {
|
|
22
30
|
main().catch((error) => {
|
|
23
|
-
|
|
31
|
+
// Logger might not be initialized yet
|
|
32
|
+
console.error('Fatal error in main()', error);
|
|
24
33
|
process.exit(1);
|
|
25
34
|
});
|
|
26
35
|
}
|
|
@@ -29,7 +38,8 @@ function parseOptionsOrError() {
|
|
|
29
38
|
return (0, options_1.parseCLIOptions)();
|
|
30
39
|
}
|
|
31
40
|
catch (error) {
|
|
32
|
-
|
|
41
|
+
// Logger is initialized after options, so use console.error here
|
|
42
|
+
console.error('Error parsing options', error);
|
|
33
43
|
process.exit(1);
|
|
34
44
|
}
|
|
35
45
|
}
|
|
@@ -37,18 +47,13 @@ async function selectToolsOrError(options) {
|
|
|
37
47
|
try {
|
|
38
48
|
const includedTools = (0, server_1.selectTools)(options);
|
|
39
49
|
if (includedTools.length === 0) {
|
|
40
|
-
|
|
50
|
+
(0, logger_1.getLogger)().error('No tools match the provided filters');
|
|
41
51
|
process.exit(1);
|
|
42
52
|
}
|
|
43
53
|
return includedTools;
|
|
44
54
|
}
|
|
45
55
|
catch (error) {
|
|
46
|
-
|
|
47
|
-
console.error('Error filtering tools:', error.message);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
console.error('Error filtering tools:', error);
|
|
51
|
-
}
|
|
56
|
+
(0, logger_1.getLogger)().error({ error }, 'Error filtering tools');
|
|
52
57
|
process.exit(1);
|
|
53
58
|
}
|
|
54
59
|
}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;AAEA,wCAAuC;AACvC,0CAAwD;AACxD,sCAA4C;AAC5C,oCAAoD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;AAEA,wCAAuC;AACvC,0CAAwD;AACxD,sCAA4C;AAC5C,oCAAoD;AAEpD,wCAAsD;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,IAAA,wBAAe,EAAC;QACd,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;QACvC,MAAM,EAAE,OAAO,CAAC,SAAS,KAAK,QAAQ;KACvC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAExD,IAAA,kBAAS,GAAE,CAAC,IAAI,CACd,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,E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AC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,kBAAS,GAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,uBAAuB,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -3,22 +3,31 @@ import { selectTools } from "./server.mjs";
|
|
|
3
3
|
import { parseCLIOptions } from "./options.mjs";
|
|
4
4
|
import { launchStdioServer } from "./stdio.mjs";
|
|
5
5
|
import { launchStreamableHTTPServer } from "./http.mjs";
|
|
6
|
+
import { configureLogger, getLogger } from "./logger.mjs";
|
|
6
7
|
async function main() {
|
|
7
8
|
const options = parseOptionsOrError();
|
|
9
|
+
configureLogger({
|
|
10
|
+
level: options.debug ? 'debug' : 'info',
|
|
11
|
+
pretty: options.logFormat === 'pretty',
|
|
12
|
+
});
|
|
8
13
|
const selectedTools = await selectToolsOrError(options);
|
|
9
|
-
|
|
14
|
+
getLogger().info({ tools: selectedTools.map((e) => e.tool.name) }, `MCP Server starting with ${selectedTools.length} tools`);
|
|
10
15
|
switch (options.transport) {
|
|
11
16
|
case 'stdio':
|
|
12
|
-
await launchStdioServer();
|
|
17
|
+
await launchStdioServer(options);
|
|
13
18
|
break;
|
|
14
19
|
case 'http':
|
|
15
|
-
await launchStreamableHTTPServer(
|
|
20
|
+
await launchStreamableHTTPServer({
|
|
21
|
+
mcpOptions: options,
|
|
22
|
+
port: options.socket ?? options.port,
|
|
23
|
+
});
|
|
16
24
|
break;
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
if (require.main === module) {
|
|
20
28
|
main().catch((error) => {
|
|
21
|
-
|
|
29
|
+
// Logger might not be initialized yet
|
|
30
|
+
console.error('Fatal error in main()', error);
|
|
22
31
|
process.exit(1);
|
|
23
32
|
});
|
|
24
33
|
}
|
|
@@ -27,7 +36,8 @@ function parseOptionsOrError() {
|
|
|
27
36
|
return parseCLIOptions();
|
|
28
37
|
}
|
|
29
38
|
catch (error) {
|
|
30
|
-
|
|
39
|
+
// Logger is initialized after options, so use console.error here
|
|
40
|
+
console.error('Error parsing options', error);
|
|
31
41
|
process.exit(1);
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -35,18 +45,13 @@ async function selectToolsOrError(options) {
|
|
|
35
45
|
try {
|
|
36
46
|
const includedTools = selectTools(options);
|
|
37
47
|
if (includedTools.length === 0) {
|
|
38
|
-
|
|
48
|
+
getLogger().error('No tools match the provided filters');
|
|
39
49
|
process.exit(1);
|
|
40
50
|
}
|
|
41
51
|
return includedTools;
|
|
42
52
|
}
|
|
43
53
|
catch (error) {
|
|
44
|
-
|
|
45
|
-
console.error('Error filtering tools:', error.message);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.error('Error filtering tools:', error);
|
|
49
|
-
}
|
|
54
|
+
getLogger().error({ error }, 'Error filtering tools');
|
|
50
55
|
process.exit(1);
|
|
51
56
|
}
|
|
52
57
|
}
|