conductor-node-mcp 14.24.2 → 14.24.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node-mcp",
3
- "version": "14.24.2",
3
+ "version": "14.24.4",
4
4
  "description": "The official MCP Server for the Conductor API",
5
5
  "author": "Conductor <support@conductor.is>",
6
6
  "types": "./index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "fix": "eslint --fix ."
28
28
  },
29
29
  "dependencies": {
30
- "conductor-node": "^14.24.2",
30
+ "conductor-node": "^14.24.4",
31
31
  "ajv": "^8.18.0",
32
32
  "@cloudflare/cabidela": "^0.2.4",
33
33
  "@hono/node-server": "^1.19.10",
package/server.d.mts CHANGED
@@ -3,7 +3,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { ClientOptions } from 'conductor-node';
4
4
  import { McpOptions } from "./options.mjs";
5
5
  import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.mjs";
6
- export declare const VERSION = "14.24.2";
6
+ export declare const VERSION = "14.24.4";
7
7
  export declare const newMcpServer: ({ stainlessApiKey, customInstructionsPath, }: {
8
8
  stainlessApiKey?: string | undefined;
9
9
  customInstructionsPath?: string | undefined;
package/server.d.ts CHANGED
@@ -3,7 +3,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { ClientOptions } from 'conductor-node';
4
4
  import { McpOptions } from "./options.js";
5
5
  import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.js";
6
- export declare const VERSION = "14.24.2";
6
+ export declare const VERSION = "14.24.4";
7
7
  export declare const newMcpServer: ({ stainlessApiKey, customInstructionsPath, }: {
8
8
  stainlessApiKey?: string | undefined;
9
9
  customInstructionsPath?: string | undefined;
package/server.js CHANGED
@@ -17,10 +17,10 @@ const docs_search_tool_2 = require("./docs-search-tool.js");
17
17
  const local_docs_search_1 = require("./local-docs-search.js");
18
18
  const instructions_1 = require("./instructions.js");
19
19
  const methods_1 = require("./methods.js");
20
- exports.VERSION = '14.24.2'; // x-release-please-version
20
+ exports.VERSION = '14.24.4'; // x-release-please-version
21
21
  const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }) => new mcp_js_1.McpServer({
22
22
  name: 'conductor_node_api',
23
- version: '14.24.2', // x-release-please-version
23
+ version: '14.24.4', // x-release-please-version
24
24
  }, {
25
25
  instructions: await (0, instructions_1.getInstructions)({ stainlessApiKey, customInstructionsPath }),
26
26
  capabilities: { tools: {}, logging: {} },
package/server.mjs CHANGED
@@ -8,10 +8,10 @@ import { setLocalSearch } from "./docs-search-tool.mjs";
8
8
  import { LocalDocsSearch } from "./local-docs-search.mjs";
9
9
  import { getInstructions } from "./instructions.mjs";
10
10
  import { blockedMethodsForCodeTool } from "./methods.mjs";
11
- export const VERSION = '14.24.2'; // x-release-please-version
11
+ export const VERSION = '14.24.4'; // x-release-please-version
12
12
  export const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }) => new McpServer({
13
13
  name: 'conductor_node_api',
14
- version: '14.24.2', // x-release-please-version
14
+ version: '14.24.4', // x-release-please-version
15
15
  }, {
16
16
  instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),
17
17
  capabilities: { tools: {}, logging: {} },
package/src/http.ts CHANGED
@@ -50,23 +50,42 @@ const newServer = async ({
50
50
  let effectiveMcpOptions = mcpOptions;
51
51
  const clientPermissionsHeader = req.headers['x-stainless-mcp-client-permissions'];
52
52
  if (typeof clientPermissionsHeader === 'string') {
53
- try {
54
- const parsed = JSON.parse(clientPermissionsHeader);
55
- if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
56
- effectiveMcpOptions = {
57
- ...mcpOptions,
58
- ...(typeof parsed.allow_http_gets === 'boolean' && { codeAllowHttpGets: parsed.allow_http_gets }),
59
- ...(Array.isArray(parsed.allowed_methods) && { codeAllowedMethods: parsed.allowed_methods }),
60
- ...(Array.isArray(parsed.blocked_methods) && { codeBlockedMethods: parsed.blocked_methods }),
61
- };
62
- getLogger().info(
63
- { clientPermissions: parsed },
64
- 'Overriding code execution permissions from x-stainless-mcp-client-permissions header',
65
- );
66
- }
67
- } catch (error) {
68
- getLogger().warn({ error }, 'Failed to parse x-stainless-mcp-client-permissions header');
53
+ const clientPermissions = parseClientPermissions(clientPermissionsHeader);
54
+ // Fail closed (conductor patch): clients send this header only to limit themselves, so a
55
+ // malformed value, such as one whose quotes a Windows shell stripped, must not leave the
56
+ // connection with full access.
57
+ if (clientPermissions === null) {
58
+ getLogger().warn(
59
+ { clientPermissionsHeader },
60
+ 'Rejected malformed x-stainless-mcp-client-permissions header',
61
+ );
62
+ res.status(400).json({
63
+ jsonrpc: '2.0',
64
+ error: {
65
+ code: -32600,
66
+ message:
67
+ 'Invalid x-stainless-mcp-client-permissions header. It must be exact JSON, such as {"allow_http_gets":true}. See https://docs.conductor.is/usage/mcp#read-only-mode',
68
+ },
69
+ id: null,
70
+ });
71
+ return null;
69
72
  }
73
+ effectiveMcpOptions = {
74
+ ...mcpOptions,
75
+ ...(clientPermissions.allow_http_gets !== undefined && {
76
+ codeAllowHttpGets: clientPermissions.allow_http_gets,
77
+ }),
78
+ ...(clientPermissions.allowed_methods !== undefined && {
79
+ codeAllowedMethods: clientPermissions.allowed_methods,
80
+ }),
81
+ ...(clientPermissions.blocked_methods !== undefined && {
82
+ codeBlockedMethods: clientPermissions.blocked_methods,
83
+ }),
84
+ };
85
+ getLogger().info(
86
+ { clientPermissions },
87
+ 'Overriding code execution permissions from x-stainless-mcp-client-permissions header',
88
+ );
70
89
  }
71
90
 
72
91
  const mcpClientInfo =
@@ -125,6 +144,34 @@ const del = async (req: express.Request, res: express.Response) => {
125
144
  });
126
145
  };
127
146
 
147
+ type ClientPermissions = {
148
+ allow_http_gets?: boolean;
149
+ allowed_methods?: string[];
150
+ blocked_methods?: string[];
151
+ };
152
+
153
+ // Returns null unless the header is a JSON object holding only known keys of the right types, so a
154
+ // typo such as {"allow_http_gets":"true"} or {"read_only":true} is refused instead of ignored.
155
+ const parseClientPermissions = (header: string): ClientPermissions | null => {
156
+ let parsed: unknown;
157
+ try {
158
+ parsed = JSON.parse(header);
159
+ } catch {
160
+ return null;
161
+ }
162
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
163
+ return null;
164
+ }
165
+ const isStringArray = (value: unknown) =>
166
+ Array.isArray(value) && value.every((item) => typeof item === 'string');
167
+ const isValid = Object.entries(parsed).every(([key, value]) =>
168
+ key === 'allow_http_gets' ? typeof value === 'boolean'
169
+ : key === 'allowed_methods' || key === 'blocked_methods' ? isStringArray(value)
170
+ : false,
171
+ );
172
+ return isValid ? (parsed as ClientPermissions) : null;
173
+ };
174
+
128
175
  const redactHeaders = (headers: Record<string, any>) => {
129
176
  const hiddenHeaders = /auth|cookie|key|token|x-stainless-mcp-client-envs/i;
130
177
  const filtered = { ...headers };