@withone/mcp 2.3.1 → 2.3.3

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 CHANGED
@@ -126,7 +126,7 @@ ONE_IDENTITY_TYPE=user
126
126
  | `ONE_IDENTITY` | The identifier for the entity (e.g., user ID, team ID) | Any string |
127
127
  | `ONE_IDENTITY_TYPE` | The type of identity | `user`, `team`, `organization`, `project` |
128
128
 
129
- When set, the MCP server will only return connections associated with the specified identity. This is useful for multi-tenant applications where you want to scope integrations to specific users or entities.
129
+ When set, the MCP server will only return connections associated with the specified identity, and `execute_one_action` will only run on those connections. This is useful for multi-tenant applications where you want to scope integrations to specific users or entities.
130
130
 
131
131
  ### Access Control
132
132
 
@@ -166,6 +166,8 @@ If you used `one init`, the configuration below is already done for you. These e
166
166
  npx @withone/mcp
167
167
  ```
168
168
 
169
+ Requires Node.js 22.23.4+, 24.22.1+ or 26.12.1+. Older Node trusts the compromised eMudhra CA certificates (October 2026), so a network attacker could intercept `ONE_SECRET`. On an older Node the server still starts, but every tool returns an error with the command that updates Node for how it was installed. If you can't update yet, `ONE_ALLOW_UNPATCHED_NODE=1` lets it call One anyway; you remain exposed while it is set.
170
+
169
171
  ### Claude Desktop / Cursor
170
172
 
171
173
  Add the following to your MCP config:
package/build/client.js CHANGED
@@ -9,10 +9,18 @@
9
9
  import axios from 'axios';
10
10
  import FormData from 'form-data';
11
11
  import { callerHeaders } from './caller.js';
12
- import { fetchPaginatedData, replacePathVariables } from './helpers.js';
12
+ import { describeError, fetchPaginatedData, replacePathVariables, summarizeErrorData } from './helpers.js';
13
13
  import { ToolError, oneApiError, oneRefusal } from './tool-error.js';
14
14
  /** Header names that only the server may set on an outgoing request. */
15
15
  const RESERVED_HEADER_PREFIX = 'x-one-';
16
+ /**
17
+ * Headers that control the connection to One rather than describe the request.
18
+ * Node also takes the TLS server name from `Host`, so a caller must not set it
19
+ * on a request carrying the secret.
20
+ */
21
+ const TRANSPORT_HEADERS = new Set(['host', 'connection', 'content-length', 'transfer-encoding', 'keep-alive', 'proxy-connection', 'te', 'trailer', 'upgrade']);
22
+ /** Headers an upstream may obey as the method in place of the request line. */
23
+ const METHOD_OVERRIDE_HEADERS = new Set(['x-http-method-override', 'x-http-method', 'x-method-override']);
16
24
  /** The prefix One renames every upstream response header to, so its presence marks a response the platform gave. */
17
25
  const PLATFORM_HEADER_PREFIX = 'x-passthrough-';
18
26
  /**
@@ -24,58 +32,20 @@ export function answeredByPlatform(headers) {
24
32
  }
25
33
  /**
26
34
  * Drops any caller-supplied header that One itself controls (`x-one-secret`,
27
- * `x-one-connection-key`, `x-one-action-id`, ...). Comparison is
28
- * case-insensitive because HTTP header names are.
35
+ * `x-one-connection-key`, `x-one-action-id`, ...) or that controls the
36
+ * connection (`Host`, `Content-Length`, ...). Comparison is case-insensitive
37
+ * because HTTP header names are.
29
38
  */
30
39
  export function stripReservedHeaders(headers) {
31
40
  if (!headers)
32
41
  return {};
33
42
  return Object.fromEntries(Object.entries(headers)
34
- .filter(([name]) => !name.toLowerCase().startsWith(RESERVED_HEADER_PREFIX))
43
+ .filter(([name]) => {
44
+ const normalized = name.trim().toLowerCase();
45
+ return !normalized.startsWith(RESERVED_HEADER_PREFIX) && !TRANSPORT_HEADERS.has(normalized);
46
+ })
35
47
  .map(([name, value]) => [name, String(value)]));
36
48
  }
37
- /**
38
- * Bounds an upstream error body before it is logged: small payloads pass
39
- * through, larger ones are truncated to a string, and an unserializable value
40
- * is replaced with a placeholder. Keeps a huge or odd error response from
41
- * bloating a single log line.
42
- */
43
- function summarizeErrorData(data) {
44
- if (data === undefined || data === null)
45
- return undefined;
46
- let serialized;
47
- try {
48
- serialized = typeof data === 'string' ? data : JSON.stringify(data);
49
- }
50
- catch {
51
- return '[unserializable response body]';
52
- }
53
- const MAX = 1000;
54
- return serialized.length <= MAX ? data : `${serialized.slice(0, MAX)}… (${serialized.length} chars, truncated)`;
55
- }
56
- /**
57
- * A log-safe summary of a failed request. Axios errors carry the full request
58
- * config, including the `x-one-secret` header, so they must never be logged
59
- * whole. Only the status, the upstream message, the route (query stripped), and
60
- * a bounded copy of the response body are kept.
61
- */
62
- export function describeError(error) {
63
- if (axios.isAxiosError(error)) {
64
- const url = error.config?.url;
65
- return {
66
- status: error.response?.status,
67
- statusText: error.response?.statusText,
68
- method: error.config?.method?.toUpperCase(),
69
- url: typeof url === 'string' ? url.split('?')[0] : undefined,
70
- message: error.message,
71
- data: summarizeErrorData(error.response?.data),
72
- };
73
- }
74
- if (error instanceof Error) {
75
- return { name: error.name, message: error.message };
76
- }
77
- return { error: String(error) };
78
- }
79
49
  /**
80
50
  * Client for interacting with the One API
81
51
  */
@@ -308,6 +278,13 @@ export class OneClient {
308
278
  const action = preloadedAction ?? await this.getActionDetails(actionId);
309
279
  const method = action.method;
310
280
  const contentType = isFormData ? 'multipart/form-data' : isFormUrlEncoded ? 'application/x-www-form-urlencoded' : 'application/json';
281
+ // The local filters judge the action's declared method, so a request must
282
+ // not ask the platform to perform a different one.
283
+ for (const [name, value] of Object.entries(stripReservedHeaders(headers))) {
284
+ if (METHOD_OVERRIDE_HEADERS.has(name.trim().toLowerCase()) && value.trim().toUpperCase() !== method.toUpperCase()) {
285
+ throw new ToolError(`Header ${name.trim()} asks for ${value.trim()}, but this action is a ${method.toUpperCase()} request. Remove the header, or use an action with that method.`);
286
+ }
287
+ }
311
288
  // Caller-supplied headers are merged first and may adjust things like
312
289
  // Content-Type, but they can never override One's own routing and auth
313
290
  // headers. Those are applied last, after the connection and action
@@ -329,6 +306,11 @@ export class OneClient {
329
306
  const finalActionPath = replacePathVariables(action.path, pathVariables ?? {});
330
307
  const normalizedPath = finalActionPath.startsWith('/') ? finalActionPath : `/${finalActionPath}`;
331
308
  const url = `${this.baseUrl}/v1/passthrough${normalizedPath}`;
309
+ // This request carries the secret, and the local filters only describe
310
+ // passthrough, so it must not resolve to any other route of the One API.
311
+ if (!new URL(url).pathname.startsWith(new URL(`${this.baseUrl}/v1/passthrough/`).pathname)) {
312
+ throw new ToolError(`Action path ${action.path} does not stay on One's passthrough route, so it was not sent.`);
313
+ }
332
314
  let requestData = data;
333
315
  if (typeof requestData === 'string') {
334
316
  try {
@@ -425,6 +407,33 @@ export class OneClient {
425
407
  getUserConnections() {
426
408
  return [...this.connections];
427
409
  }
410
+ /**
411
+ * Refuses a connection key outside this server's scope, set by
412
+ * `ONE_CONNECTION_KEYS` or `ONE_IDENTITY`. The list is loaded once per
413
+ * process, so a key it lacks is checked against a fresh copy before being
414
+ * refused: it may be a connection made since, or the first load may have failed.
415
+ * @param connectionKey - The key the caller asked to run on
416
+ * @throws {ToolError} If the key is out of scope, or the list cannot be read
417
+ */
418
+ async ensureConnectionInScope(connectionKey) {
419
+ const keysRestricted = this.connectionKeys !== undefined && !this.connectionKeys.includes('*');
420
+ if (!keysRestricted && !this.identity)
421
+ return;
422
+ const isLoaded = () => this.connections.some((c) => c.key === connectionKey);
423
+ if (isLoaded())
424
+ return;
425
+ const loaded = this.connections;
426
+ try {
427
+ await this.fetchConnections();
428
+ }
429
+ catch (error) {
430
+ this.connections = loaded;
431
+ throw oneApiError('Could not confirm this connection is available to this server', error);
432
+ }
433
+ if (!isLoaded()) {
434
+ throw new ToolError(`Connection key "${connectionKey}" is not one this server may use. Use a connection key from list_one_integrations.`);
435
+ }
436
+ }
428
437
  /**
429
438
  * Gets available connectors/platforms
430
439
  * @returns Array of available connection definitions
@@ -1,7 +1,9 @@
1
1
  import { describe, it, before, after, beforeEach } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import http from 'node:http';
4
- import { OneClient, stripReservedHeaders, describeError, answeredByPlatform } from './client.js';
4
+ import { inspect } from 'node:util';
5
+ import { OneClient, stripReservedHeaders, answeredByPlatform } from './client.js';
6
+ import { describeError, fetchPaginatedData } from './helpers.js';
5
7
  import { ToolError } from './tool-error.js';
6
8
  // A passthrough call must never let the caller override One's own routing/auth
7
9
  // headers (the scoping bypass), and a failed call must never log the secret.
@@ -56,6 +58,31 @@ describe("executePassthroughRequest keeps One's headers authoritative", () => {
56
58
  assert.equal(h['x-custom-trace'], 't-1', 'a non-reserved custom header still passes through');
57
59
  assert.equal(h['content-type'], 'application/json', 'the default content type is kept');
58
60
  });
61
+ it('a caller cannot set the headers that control the connection', async () => {
62
+ const client = new OneClient(SECRET, base);
63
+ await client.executePassthroughRequest(exec({
64
+ data: { a: 1 },
65
+ headers: { Host: 'attacker.example', 'Content-Length': '1', Connection: 'close', 'x-custom-trace': 't-1' },
66
+ }), { ...ACTION, method: 'POST' });
67
+ const h = received[0].headers;
68
+ assert.equal(h.host, new URL(base).host);
69
+ assert.equal(h['content-length'], '7', 'the length comes from the body that is sent');
70
+ assert.notEqual(h.connection, 'close');
71
+ assert.equal(h['x-custom-trace'], 't-1', 'a custom header still passes through');
72
+ });
73
+ it('sends nothing when a method override differs from the action method', async () => {
74
+ const client = new OneClient(SECRET, base);
75
+ const post = { ...ACTION, method: 'POST' };
76
+ for (const name of ['X-HTTP-Method-Override', 'x-http-method', 'X-Method-Override', ' x-http-method-override ']) {
77
+ await assert.rejects(client.executePassthroughRequest(exec({ headers: { [name]: 'DELETE' } }), post), (e) => e instanceof ToolError && /DELETE/.test(e.message) && /POST/.test(e.message), name);
78
+ }
79
+ assert.equal(received.length, 0, 'nothing is sent upstream');
80
+ });
81
+ it('allows a method override that matches the action method, in any casing', async () => {
82
+ const client = new OneClient(SECRET, base);
83
+ await client.executePassthroughRequest(exec({ headers: { 'X-HTTP-Method-Override': ' post ' } }), { ...ACTION, method: 'POST' });
84
+ assert.equal(received.length, 1);
85
+ });
59
86
  it('names the expected path variables instead of sending an unfilled template', async () => {
60
87
  const client = new OneClient(SECRET, base);
61
88
  const templated = { ...ACTION, path: '/v1/things/{{thingId}}' };
@@ -64,6 +91,23 @@ describe("executePassthroughRequest keeps One's headers authoritative", () => {
64
91
  await client.executePassthroughRequest(exec({ pathVariables: { thing_id: 7 } }), templated);
65
92
  assert.equal(received.length, 1);
66
93
  });
94
+ it('sends nothing when a path variable would leave the action route', async () => {
95
+ const client = new OneClient(SECRET, base);
96
+ const templated = { ...ACTION, path: '/v0/{{a}}/{{b}}/{{c}}' };
97
+ await assert.rejects(client.executePassthroughRequest(exec({ pathVariables: { a: '..', b: '..', c: 'connections' } }), templated), ToolError);
98
+ assert.equal(received.length, 0, 'nothing is sent upstream');
99
+ });
100
+ it('sends nothing when an action path resolves outside passthrough', async () => {
101
+ const client = new OneClient(SECRET, base);
102
+ const encoded = { ...ACTION, path: '/%2e%2e/%2E%2e/connections' };
103
+ await assert.rejects(client.executePassthroughRequest(exec({}), encoded), ToolError);
104
+ assert.equal(received.length, 0, 'nothing is sent upstream');
105
+ });
106
+ it('keeps ordinary paths working under a base URL with a path prefix', async () => {
107
+ const client = new OneClient(SECRET, `${base}/prefix`);
108
+ await client.executePassthroughRequest(exec({}), ACTION);
109
+ assert.equal(received.length, 1);
110
+ });
67
111
  it('a caller may still set Content-Type, in any casing', async () => {
68
112
  const client = new OneClient(SECRET, base);
69
113
  await client.executePassthroughRequest(exec({ headers: { 'content-type': 'text/plain' } }), ACTION);
@@ -127,6 +171,128 @@ describe("executePassthroughRequest keeps One's headers authoritative", () => {
127
171
  assert.ok(message.includes('422') && message.includes('upstream said no'), "the tool error carries the status and One's reason");
128
172
  });
129
173
  });
174
+ describe('ensureConnectionInScope', () => {
175
+ let server;
176
+ let base = '';
177
+ let rows = [];
178
+ let listQueries = [];
179
+ let failLists = false;
180
+ const client = (options = {}) => new OneClient({ secret: SECRET, baseUrl: base, fetchConnectors: false, ...options });
181
+ before(async () => {
182
+ server = http.createServer((req, res) => {
183
+ listQueries.push(new URL(req.url ?? '', 'http://x').searchParams);
184
+ res.writeHead(failLists ? 500 : 200, { 'Content-Type': 'application/json' });
185
+ res.end(JSON.stringify(failLists ? { message: 'boom' } : { rows: rows.map((key) => ({ key, platform: 'test' })), total: rows.length }));
186
+ });
187
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', () => resolve()));
188
+ base = `http://127.0.0.1:${server.address().port}`;
189
+ });
190
+ after(() => {
191
+ server.close();
192
+ });
193
+ beforeEach(() => {
194
+ rows = ['key_a'];
195
+ listQueries = [];
196
+ failLists = false;
197
+ });
198
+ it('allows any key when the server has no scope, without listing', async () => {
199
+ const c = client();
200
+ await c.ensureConnectionInScope('key_b');
201
+ assert.equal(listQueries.length, 0);
202
+ });
203
+ it("allows the identity's own key without listing again", async () => {
204
+ const c = client({ identity: 'user_a' });
205
+ await c.initialize();
206
+ await c.ensureConnectionInScope('key_a');
207
+ assert.equal(listQueries.length, 1);
208
+ });
209
+ it("refuses another identity's key, using the identity-filtered list", async () => {
210
+ const c = client({ identity: 'user_a' });
211
+ await c.initialize();
212
+ await assert.rejects(c.ensureConnectionInScope('key_b'), (e) => e instanceof ToolError && /is not one this server may use/.test(e.message));
213
+ assert.equal(listQueries.at(-1)?.get('identity'), 'user_a', 'the check reads the same filtered list');
214
+ });
215
+ it('allows a connection made after the list was loaded', async () => {
216
+ const c = client({ identity: 'user_a' });
217
+ await c.initialize();
218
+ rows = ['key_a', 'key_new'];
219
+ await c.ensureConnectionInScope('key_new');
220
+ assert.deepEqual(c.getUserConnections().map((x) => x.key), ['key_a', 'key_new']);
221
+ });
222
+ const silenced = async (run) => {
223
+ const original = console.error;
224
+ console.error = () => { };
225
+ try {
226
+ return await run();
227
+ }
228
+ finally {
229
+ console.error = original;
230
+ }
231
+ };
232
+ it('recovers when the first load failed', async () => {
233
+ const c = client({ identity: 'user_a' });
234
+ failLists = true;
235
+ await silenced(() => c.initialize());
236
+ failLists = false;
237
+ await c.ensureConnectionInScope('key_a');
238
+ });
239
+ it('refuses when the list cannot be read, and keeps the loaded list', async () => {
240
+ const c = client({ identity: 'user_a' });
241
+ await c.initialize();
242
+ failLists = true;
243
+ await silenced(() => assert.rejects(c.ensureConnectionInScope('key_b'), (e) => e instanceof ToolError && /Could not confirm/.test(e.message)));
244
+ assert.deepEqual(c.getUserConnections().map((x) => x.key), ['key_a']);
245
+ });
246
+ it('still applies ONE_CONNECTION_KEYS', async () => {
247
+ const c = client({ connectionKeys: ['key_a'] });
248
+ await c.initialize();
249
+ await assert.rejects(c.ensureConnectionInScope('key_b'), ToolError);
250
+ await c.ensureConnectionInScope('key_a');
251
+ });
252
+ });
253
+ describe('a failed paginated fetch', () => {
254
+ // Rendered the way console.error renders its arguments, which is what prints
255
+ // a whole axios error's request headers.
256
+ const captureLog = async (run) => {
257
+ const logged = [];
258
+ const original = console.error;
259
+ console.error = (...args) => {
260
+ logged.push(args.map((a) => (typeof a === 'string' ? a : inspect(a, { depth: null }))).join(' '));
261
+ };
262
+ try {
263
+ await assert.rejects(run());
264
+ }
265
+ finally {
266
+ console.error = original;
267
+ }
268
+ return logged.join('\n');
269
+ };
270
+ it('never logs the secret when One answers with an error', async () => {
271
+ const server = http.createServer((_req, res) => {
272
+ res.writeHead(500, { 'Content-Type': 'application/json' });
273
+ res.end(JSON.stringify({ message: 'upstream said no' }));
274
+ });
275
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', () => resolve()));
276
+ const url = `http://127.0.0.1:${server.address().port}/v1/vault/connections`;
277
+ try {
278
+ const log = await captureLog(() => fetchPaginatedData(url, { 'x-one-secret': SECRET }));
279
+ assert.ok(!log.includes(SECRET), 'the secret never reaches the log');
280
+ assert.ok(log.includes('500') && log.includes('upstream said no'), 'the log still says what failed');
281
+ }
282
+ finally {
283
+ server.close();
284
+ }
285
+ });
286
+ it('never logs the secret when One cannot be reached', async () => {
287
+ const closed = http.createServer();
288
+ await new Promise((resolve) => closed.listen(0, '127.0.0.1', () => resolve()));
289
+ const port = closed.address().port;
290
+ await new Promise((resolve) => closed.close(() => resolve()));
291
+ const log = await captureLog(() => fetchPaginatedData(`http://127.0.0.1:${port}/v1/vault/connections`, { 'x-one-secret': SECRET }));
292
+ assert.ok(!log.includes(SECRET), 'the secret never reaches the log');
293
+ assert.ok(log.includes('ECONNREFUSED'), 'the log still says what failed');
294
+ });
295
+ });
130
296
  describe('answeredByPlatform', () => {
131
297
  it('reads a renamed upstream header, in any casing, as the platform answering', () => {
132
298
  assert.equal(answeredByPlatform({ 'x-passthrough-content-type': 'application/json' }), true);
@@ -140,6 +306,14 @@ describe('stripReservedHeaders', () => {
140
306
  assert.deepEqual(stripReservedHeaders({ n: 5 }), { n: '5' });
141
307
  assert.deepEqual(stripReservedHeaders(undefined), {});
142
308
  });
309
+ it('drops connection-level headers case-insensitively', () => {
310
+ for (const name of ['Host', 'host', 'CONNECTION', 'Content-Length', 'Transfer-Encoding', 'Keep-Alive', 'Proxy-Connection', 'TE', 'Trailer', 'Upgrade']) {
311
+ assert.deepEqual(stripReservedHeaders({ [name]: 'x', Accept: 'y' }), { Accept: 'y' }, name);
312
+ }
313
+ });
314
+ it('ignores surrounding whitespace in a header name', () => {
315
+ assert.deepEqual(stripReservedHeaders({ 'Host ': 'a', ' host': 'b', ' x-one-secret': 'c', Accept: 'y' }), { Accept: 'y' });
316
+ });
143
317
  });
144
318
  describe('describeError', () => {
145
319
  it('summarizes a plain error to its name and message', () => {
package/build/helpers.js CHANGED
@@ -9,6 +9,48 @@
9
9
  import axios from 'axios';
10
10
  import { ToolError } from './tool-error.js';
11
11
  import { parseSections, buildDigest, renderDigestBanner, renderDigestNotice, selectSections, flattenSections, parseSectionFlag, collapseSections, omittedSections, } from './knowledge-sections.js';
12
+ /**
13
+ * Bounds an upstream error body before it is logged: small payloads pass
14
+ * through, larger ones are truncated to a string, and an unserializable value
15
+ * is replaced with a placeholder. Keeps a huge or odd error response from
16
+ * bloating a single log line.
17
+ */
18
+ export function summarizeErrorData(data) {
19
+ if (data === undefined || data === null)
20
+ return undefined;
21
+ let serialized;
22
+ try {
23
+ serialized = typeof data === 'string' ? data : JSON.stringify(data);
24
+ }
25
+ catch {
26
+ return '[unserializable response body]';
27
+ }
28
+ const MAX = 1000;
29
+ return serialized.length <= MAX ? data : `${serialized.slice(0, MAX)}… (${serialized.length} chars, truncated)`;
30
+ }
31
+ /**
32
+ * A log-safe summary of a failed request. Axios errors carry the full request
33
+ * config, including the `x-one-secret` header, so they must never be logged
34
+ * whole. Only the status, the upstream message, the route (query stripped), and
35
+ * a bounded copy of the response body are kept.
36
+ */
37
+ export function describeError(error) {
38
+ if (axios.isAxiosError(error)) {
39
+ const url = error.config?.url;
40
+ return {
41
+ status: error.response?.status,
42
+ statusText: error.response?.statusText,
43
+ method: error.config?.method?.toUpperCase(),
44
+ url: typeof url === 'string' ? url.split('?')[0] : undefined,
45
+ message: error.message,
46
+ data: summarizeErrorData(error.response?.data),
47
+ };
48
+ }
49
+ if (error instanceof Error) {
50
+ return { name: error.name, message: error.message };
51
+ }
52
+ return { error: String(error) };
53
+ }
12
54
  /**
13
55
  * Paginates through API results by repeatedly calling a fetch function until all data is retrieved.
14
56
  * @param fetchFn - Function that fetches paginated data, takes skip and limit parameters
@@ -30,7 +72,7 @@ export async function paginateResults(fetchFn, limit = 100) {
30
72
  return allResults;
31
73
  }
32
74
  catch (error) {
33
- console.error("Error in pagination:", error);
75
+ console.error("Error in pagination:", describeError(error));
34
76
  throw error;
35
77
  }
36
78
  }
@@ -56,7 +98,7 @@ export async function fetchPaginatedData(baseUrl, headers, additionalParams) {
56
98
  return response.data;
57
99
  }
58
100
  catch (error) {
59
- console.error(`Failed to fetch from ${baseUrl}:`, error);
101
+ console.error(`Failed to fetch from ${baseUrl}:`, describeError(error));
60
102
  throw error;
61
103
  }
62
104
  };
@@ -209,7 +251,15 @@ export function replacePathVariables(path, variables) {
209
251
  return encodeURIComponent(value.toString());
210
252
  };
211
253
  // Double brackets first, so {{name}} is not read as {name} wrapped in braces.
212
- return path.replace(/\{\{([^}]+)\}\}/g, (_match, variable) => lookup(variable)).replace(/\{([^}]+)\}/g, (_match, variable) => lookup(variable));
254
+ const filled = path.replace(/\{\{([^}]+)\}\}/g, (_match, variable) => lookup(variable)).replace(/\{([^}]+)\}/g, (_match, variable) => lookup(variable));
255
+ // encodeURIComponent leaves dots alone, and a dot segment would move the
256
+ // request off the action's route. Checked on the filled path because
257
+ // adjacent variables can assemble one.
258
+ const route = filled.split(/[?#]/, 1)[0];
259
+ if (route.split('/').some((segment) => segment === '.' || segment === '..')) {
260
+ throw new ToolError(`Invalid pathVariables for ${path}: a path segment cannot be "." or "..".`);
261
+ }
262
+ return filled;
213
263
  }
214
264
  const PERMISSION_METHODS = {
215
265
  read: ["GET"],
package/build/index.js CHANGED
@@ -14,6 +14,7 @@ import { OneClient } from './client.js';
14
14
  import { isMethodAllowed, isActionAllowed, buildIntegrationsResponse, } from './helpers.js';
15
15
  import { findOneActions } from './find.js';
16
16
  import { ToolError, toolErrorResult } from './tool-error.js';
17
+ import { unpatchedNodeRefusal } from './node-check.js';
17
18
  import { listOneIntegrationsToolConfig, findOneActionsToolConfig, executeOneActionToolConfig } from './schemas.js';
18
19
  import { createRequire } from 'node:module';
19
20
  const SERVER_NAME = "one-mcp-server";
@@ -38,6 +39,12 @@ const ONE_ACTION_IDS = process.env.ONE_ACTION_IDS
38
39
  ? process.env.ONE_ACTION_IDS.split(",").map(s => s.trim()).filter(Boolean)
39
40
  : ["*"];
40
41
  const ONE_KNOWLEDGE_AGENT = process.env.ONE_KNOWLEDGE_AGENT === "true";
42
+ // eMudhra CA compromise: on a Node without the fix every tool answers this
43
+ // instead of calling One (see node-check.ts).
44
+ const NODE_REFUSAL = unpatchedNodeRefusal();
45
+ if (NODE_REFUSAL) {
46
+ console.error(NODE_REFUSAL);
47
+ }
41
48
  const oneClient = new OneClient({
42
49
  secret: ONE_SECRET,
43
50
  baseUrl: ONE_BASE_URL,
@@ -74,15 +81,21 @@ const server = new McpServer({
74
81
  version: SERVER_VERSION,
75
82
  });
76
83
  server.registerTool("list_one_integrations", listOneIntegrationsToolConfig, async (args) => {
84
+ if (NODE_REFUSAL)
85
+ return toolErrorResult(new ToolError(NODE_REFUSAL));
77
86
  await initializeOne();
78
87
  return await handleGetIntegrations(args);
79
88
  });
80
89
  server.registerTool("find_one_actions", findOneActionsToolConfig, async (args) => {
90
+ if (NODE_REFUSAL)
91
+ return toolErrorResult(new ToolError(NODE_REFUSAL));
81
92
  await initializeOne();
82
93
  return await handleFindOneActions(args);
83
94
  });
84
95
  if (!ONE_KNOWLEDGE_AGENT) {
85
96
  server.registerTool("execute_one_action", executeOneActionToolConfig, async (args) => {
97
+ if (NODE_REFUSAL)
98
+ return toolErrorResult(new ToolError(NODE_REFUSAL));
86
99
  await initializeOne();
87
100
  return await handleExecuteOneAction(args);
88
101
  });
@@ -150,12 +163,7 @@ async function handleExecuteOneAction(args) {
150
163
  if (!isActionAllowed(args.actionId, ONE_ACTION_IDS)) {
151
164
  throw new ToolError(`Action "${args.actionId}" is not one this server may run. Use an action listed in list_one_integrations or returned by find_one_actions.`);
152
165
  }
153
- if (!ONE_CONNECTION_KEYS.includes("*")) {
154
- const allowedKeys = oneClient.getUserConnections().map(c => c.key);
155
- if (!allowedKeys.includes(args.connectionKey)) {
156
- throw new ToolError(`Connection key "${args.connectionKey}" is not one this server may use. Use a connection key from list_one_integrations.`);
157
- }
158
- }
166
+ await oneClient.ensureConnectionInScope(args.connectionKey);
159
167
  const actionDetails = await oneClient.getActionDetails(args.actionId);
160
168
  if (!isMethodAllowed(actionDetails.method, ONE_PERMISSIONS)) {
161
169
  throw new ToolError(`Action "${args.actionId}" is a ${actionDetails.method.toUpperCase()} request, which this server's "${ONE_PERMISSIONS}" permission level does not allow, so it cannot be run here.`);
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Node.js TLS guard
3
+ *
4
+ * Eight eMudhra/emSign intermediate CAs were created with 8-bit private keys
5
+ * (October 2026, RUSTSEC-2026-0381), so anyone can compute them and sign a
6
+ * certificate for any domain, including api.withone.ai. Node.js blocks them
7
+ * inside the TLS handshake from 22.23.4, 24.22.1 and 26.12.1
8
+ * (nodejs/node#66871). On any older Node, a network attacker can intercept
9
+ * this server's traffic and the ONE_SECRET it sends.
10
+ *
11
+ * An MCP server that exits at startup only shows up as "failed to start" in
12
+ * the client, so on an unpatched Node the server still starts but every tool
13
+ * returns this refusal, before any request, for the agent to pass on.
14
+ *
15
+ * @fileoverview Refuses to call One from a Node without the eMudhra fix
16
+ * @author One
17
+ */
18
+ /** The first patch of each Node line that ships the blocklist. Odd lines (23, 25) are end-of-life and never got it. */
19
+ const FIXED_IN = {
20
+ 22: [23, 4],
21
+ 24: [22, 1],
22
+ 26: [12, 1],
23
+ };
24
+ /** The first Node line released after the fix, so it has it from .0. */
25
+ const FIRST_LINE_WITH_FIX = 27;
26
+ /** The line to move to from a Node line that never got the fix. */
27
+ const RECOMMENDED_LINE = 24;
28
+ export const REQUIRED_NODE = '22.23.4+, 24.22.1+ or 26.12.1+';
29
+ /** Set to 1 to call One from an unpatched Node anyway. */
30
+ export const ALLOW_UNPATCHED_ENV = 'ONE_ALLOW_UNPATCHED_NODE';
31
+ function parseVersion(version) {
32
+ const [major, minor, patch] = version.split('.').map((part) => Number.parseInt(part, 10));
33
+ return [major, minor, patch ?? 0];
34
+ }
35
+ /** True when this Node version rejects chains through the compromised eMudhra intermediates. */
36
+ export function nodeHasTlsFix(version = process.versions.node) {
37
+ const [major, minor, patch] = parseVersion(version);
38
+ if (!Number.isFinite(major))
39
+ return false;
40
+ if (major >= FIRST_LINE_WITH_FIX)
41
+ return true;
42
+ const fixed = FIXED_IN[major];
43
+ if (!fixed)
44
+ return false;
45
+ const [fixedMinor, fixedPatch] = fixed;
46
+ return minor > fixedMinor || (minor === fixedMinor && patch >= fixedPatch);
47
+ }
48
+ /**
49
+ * The command that updates Node for however it was installed, judged from the
50
+ * path of the running binary. A line that got the fix stays on its line; any
51
+ * other moves to the recommended one.
52
+ */
53
+ export function upgradeCommand(version = process.versions.node, execPath = process.execPath) {
54
+ const [major] = parseVersion(version);
55
+ const line = FIXED_IN[major] ? major : RECOMMENDED_LINE;
56
+ const path = execPath.replace(/\\/g, '/');
57
+ if (/\/\.nvm\/versions\/node\//.test(path))
58
+ return `nvm install ${line} && nvm alias default ${line}`;
59
+ if (/\/AppData\/(Roaming|Local)\/nvm\//i.test(path))
60
+ return `nvm install ${line} && nvm use ${line}`;
61
+ if (/\/\.?volta\//i.test(path))
62
+ return `volta install node@${line}`;
63
+ if (/fnm/i.test(path))
64
+ return `fnm install ${line} && fnm default ${line}`;
65
+ const brew = path.match(/\/Cellar\/(node(?:@\d+)?)\//);
66
+ if (brew) {
67
+ const formula = brew[1] === 'node' || FIXED_IN[major] ? brew[1] : `node@${line}`;
68
+ return formula === brew[1] ? `brew upgrade ${formula}` : `brew install ${formula}`;
69
+ }
70
+ return `download Node.js ${line} from https://nodejs.org`;
71
+ }
72
+ /**
73
+ * What every tool answers on an unpatched Node, or null when it may call One:
74
+ * the Node has the fix, or ONE_ALLOW_UNPATCHED_NODE=1.
75
+ */
76
+ export function unpatchedNodeRefusal(version = process.versions.node, execPath = process.execPath, env = process.env) {
77
+ if (nodeHasTlsFix(version) || env[ALLOW_UNPATCHED_ENV] === '1')
78
+ return null;
79
+ return (`The One MCP server is running on Node.js v${version}, which trusts the compromised eMudhra ` +
80
+ `certificates, so a network attacker could intercept its traffic and the user's One API key. ` +
81
+ `It will not call One until Node.js is updated to ${REQUIRED_NODE} (Node 18, 20, 23 and 25 never got the fix). ` +
82
+ `Don't retry: ask the user to run \`${upgradeCommand(version, execPath)}\`, then restart their MCP client.`);
83
+ }
@@ -0,0 +1,50 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { nodeHasTlsFix, unpatchedNodeRefusal, upgradeCommand } from './node-check.js';
4
+ describe('nodeHasTlsFix', () => {
5
+ it('knows the first fixed patch of each supported line', () => {
6
+ assert.equal(nodeHasTlsFix('22.23.4'), true);
7
+ assert.equal(nodeHasTlsFix('22.23.3'), false);
8
+ assert.equal(nodeHasTlsFix('22.24.0'), true);
9
+ assert.equal(nodeHasTlsFix('24.22.1'), true);
10
+ assert.equal(nodeHasTlsFix('24.22.0'), false);
11
+ assert.equal(nodeHasTlsFix('26.12.1'), true);
12
+ assert.equal(nodeHasTlsFix('26.12.0'), false);
13
+ });
14
+ it('treats end-of-life lines as unfixed and later lines as fixed', () => {
15
+ for (const v of ['18.20.8', '20.19.5', '23.11.1', '25.9.0']) {
16
+ assert.equal(nodeHasTlsFix(v), false, v);
17
+ }
18
+ assert.equal(nodeHasTlsFix('27.0.0'), true);
19
+ assert.equal(nodeHasTlsFix('garbage'), false);
20
+ });
21
+ });
22
+ describe('upgradeCommand', () => {
23
+ it('keeps a fixed line and moves an end-of-life one to 24', () => {
24
+ assert.equal(upgradeCommand('22.10.0', '/Users/me/.nvm/versions/node/v22.10.0/bin/node'), 'nvm install 22 && nvm alias default 22');
25
+ assert.equal(upgradeCommand('20.19.5', '/Users/me/.nvm/versions/node/v20.19.5/bin/node'), 'nvm install 24 && nvm alias default 24');
26
+ });
27
+ it('matches each version manager by the binary path', () => {
28
+ assert.equal(upgradeCommand('20.19.5', 'C:\\Users\\me\\AppData\\Roaming\\nvm\\v20.19.5\\node.exe'), 'nvm install 24 && nvm use 24');
29
+ assert.equal(upgradeCommand('20.19.5', '/Users/me/.volta/tools/image/node/20.19.5/bin/node'), 'volta install node@24');
30
+ assert.equal(upgradeCommand('20.19.5', '/Users/me/.local/share/fnm/node-versions/v20.19.5/installation/bin/node'), 'fnm install 24 && fnm default 24');
31
+ assert.equal(upgradeCommand('26.1.0', '/opt/homebrew/Cellar/node/26.1.0/bin/node'), 'brew upgrade node');
32
+ assert.equal(upgradeCommand('20.19.5', '/opt/homebrew/Cellar/node@20/20.19.5/bin/node'), 'brew install node@24');
33
+ assert.equal(upgradeCommand('20.19.5', '/usr/local/bin/node'), 'download Node.js 24 from https://nodejs.org');
34
+ });
35
+ });
36
+ describe('unpatchedNodeRefusal', () => {
37
+ it('is null on a patched Node', () => {
38
+ assert.equal(unpatchedNodeRefusal('24.22.1', '/usr/local/bin/node', {}), null);
39
+ });
40
+ it('tells the agent the version, the fix and the command to give the user', () => {
41
+ const refusal = unpatchedNodeRefusal('20.19.5', '/Users/me/.nvm/versions/node/v20.19.5/bin/node', {}) ?? '';
42
+ assert.match(refusal, /Node\.js v20\.19\.5/);
43
+ assert.match(refusal, /22\.23\.4\+, 24\.22\.1\+ or 26\.12\.1\+/);
44
+ assert.match(refusal, /`nvm install 24 && nvm alias default 24`/);
45
+ assert.match(refusal, /Don't retry/);
46
+ });
47
+ it('steps aside when ONE_ALLOW_UNPATCHED_NODE=1', () => {
48
+ assert.equal(unpatchedNodeRefusal('20.19.5', '/usr/local/bin/node', { ONE_ALLOW_UNPATCHED_NODE: '1' }), null);
49
+ });
50
+ });
@@ -1,6 +1,7 @@
1
1
  import { describe, it } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { replacePathVariables } from './helpers.js';
4
+ import { ToolError } from './tool-error.js';
4
5
  describe('replacePathVariables', () => {
5
6
  it('fills exact names in both bracket styles', () => {
6
7
  assert.equal(replacePathVariables('/tickets/{{ticketId}}/comments/{id}', { ticketId: 42, id: 'c 1' }), '/tickets/42/comments/c%201');
@@ -23,4 +24,21 @@ describe('replacePathVariables', () => {
23
24
  it('rejects empty values', () => {
24
25
  assert.throws(() => replacePathVariables('/x/{{id}}', { id: '' }), /Missing value for path variable: id/);
25
26
  });
27
+ it('refuses a value that would become a dot segment', () => {
28
+ for (const value of ['.', '..']) {
29
+ assert.throws(() => replacePathVariables('/a/{{id}}/b', { id: value }), ToolError, value);
30
+ }
31
+ });
32
+ it('refuses dot segments assembled from adjacent variables', () => {
33
+ assert.throws(() => replacePathVariables('/a/{{x}}{{y}}/b', { x: '.', y: '.' }), ToolError);
34
+ });
35
+ it('keeps values that only contain dots', () => {
36
+ assert.equal(replacePathVariables('/a/{{x}}/{{y}}/{{z}}', { x: '...', y: '..hidden', z: 'file.txt' }), '/a/.../..hidden/file.txt');
37
+ });
38
+ it('keeps a value with a slash inside one encoded segment', () => {
39
+ assert.equal(replacePathVariables('/a/{{x}}', { x: '../..' }), '/a/..%2F..');
40
+ });
41
+ it('allows dots in a variable after the query separator', () => {
42
+ assert.equal(replacePathVariables('/a?q={{q}}', { q: '..' }), '/a?q=..');
43
+ });
26
44
  });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@withone/mcp",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "A Model Context Protocol Server for One",
5
5
  "type": "module",
6
6
  "bin": {
7
- "mcp": "./build/index.js"
7
+ "mcp": "build/index.js"
8
8
  },
9
9
  "files": [
10
10
  "build"
@@ -35,7 +35,10 @@
35
35
  "license": "MIT",
36
36
  "repository": {
37
37
  "type": "git",
38
- "url": "https://github.com/withoneai/mcp"
38
+ "url": "git+https://github.com/withoneai/mcp.git"
39
+ },
40
+ "engines": {
41
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
39
42
  },
40
43
  "mcpName": "ai.withone/mcp"
41
44
  }