@withone/mcp 2.3.3 → 2.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/README.md CHANGED
@@ -60,7 +60,7 @@ The server exposes three MCP tools:
60
60
 
61
61
  | Tool | Description |
62
62
  |------|-------------|
63
- | `list_one_integrations` | List available platforms and active connections, each with the `access` it confers (full, methods, or specific actions) |
63
+ | `list_one_integrations` | List available platforms and active connections, each with the `access` it confers (full, access levels, or specific actions) |
64
64
  | `find_one_actions` | Find the action for every operation a task needs, across platforms, with its documentation, in one call; `load` fetches more of a document or an alternative's |
65
65
  | `execute_one_action` | Execute an API action on a connected platform |
66
66
 
@@ -141,7 +141,7 @@ ONE_KNOWLEDGE_AGENT=true
141
141
 
142
142
  | Variable | Type | Default | Description |
143
143
  |---|---|---|---|
144
- | `ONE_PERMISSIONS` | `read` \| `write` \| `admin` | `admin` | Filter actions by HTTP method. `read` = GET only, `write` = GET/POST/PUT/PATCH, `admin` = all methods |
144
+ | `ONE_PERMISSIONS` | `read` \| `write` \| `admin` | `admin` | Filter actions by One's `access` classification of what each one does, whatever its HTTP method. `read` = `read` actions only, `write` = `read` and `write` actions, `admin` = all actions including `delete`. Below `admin`, an action with no classification is refused |
145
145
  | `ONE_CONNECTION_KEYS` | `*` or comma-separated keys | `*` | Restrict visible connections and platforms to specific connection keys |
146
146
  | `ONE_ACTION_IDS` | `*` or comma-separated IDs | `*` | Restrict visible and executable actions to specific action IDs |
147
147
  | `ONE_KNOWLEDGE_AGENT` | `true` \| `false` | `false` | Remove the `execute_one_action` tool entirely, forcing knowledge-only mode. `find_one_actions` then returns each chosen action's whole document with how to call it from code, and an Integration Code Guide (passthrough URL, `x-one-*` headers, `ONE_SECRET` / `ONE_{PLATFORM}_CONNECTION_KEY` env vars, backend-only placement) for writing application code |
@@ -153,7 +153,7 @@ Whatever you configure here is surfaced back to the agent: `list_one_integration
153
153
  | `access` | When |
154
154
  |---|---|
155
155
  | `{ "policy": "full" }` | No action allowlist and `ONE_PERMISSIONS=admin` — every action is runnable. |
156
- | `{ "policy": "methods", "methods": ["GET", ...] }` | No action allowlist, but `ONE_PERMISSIONS` is `read`/`write` — only these HTTP methods are runnable. |
156
+ | `{ "policy": "levels", "levels": ["read", ...] }` | No action allowlist, but `ONE_PERMISSIONS` is `read`/`write` — only actions classified at these access levels are runnable. |
157
157
  | `{ "policy": "actions", "actions": [{ "actionId", "title", "method" }] }` | `ONE_ACTION_IDS` is set — exactly these actions (the ones on that connection's platform) are runnable, so no search is needed. |
158
158
 
159
159
  ## Manual Configuration
package/build/client.js CHANGED
@@ -255,6 +255,7 @@ export class OneClient {
255
255
  actionId,
256
256
  title: action.title,
257
257
  method: action.method,
258
+ access: action.access,
258
259
  platform: action.connectionPlatform
259
260
  };
260
261
  }
@@ -278,7 +279,7 @@ export class OneClient {
278
279
  const action = preloadedAction ?? await this.getActionDetails(actionId);
279
280
  const method = action.method;
280
281
  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
+ // An action's access level describes its declared method, so a request must
282
283
  // not ask the platform to perform a different one.
283
284
  for (const [name, value] of Object.entries(stripReservedHeaders(headers))) {
284
285
  if (METHOD_OVERRIDE_HEADERS.has(name.trim().toLowerCase()) && value.trim().toUpperCase() !== method.toUpperCase()) {
package/build/find.js CHANGED
@@ -13,7 +13,7 @@
13
13
  * @author One
14
14
  */
15
15
  import { ToolError } from './tool-error.js';
16
- import { buildKnowledgeResponse, isActionAllowed, isMethodAllowed, platformEnvSegment } from './helpers.js';
16
+ import { buildKnowledgeResponse, isAccessAllowed, isActionAllowed, platformEnvSegment } from './helpers.js';
17
17
  /** How many intents one find answers. Core enforces the same cap. */
18
18
  export const FIND_MAX_INTENTS = 10;
19
19
  /** How many documents one load returns. */
@@ -47,7 +47,7 @@ export function actionHeading(title, method, path, actionId) {
47
47
  return `${title} · \`${method.toUpperCase()} ${path}\` · actionId: \`${actionId}\``;
48
48
  }
49
49
  function allows(settings, action) {
50
- return isActionAllowed(action.systemId, settings.actionIds) && isMethodAllowed(action.method, settings.permissions);
50
+ return isActionAllowed(action.systemId, settings.actionIds) && isAccessAllowed(action.access, settings.permissions);
51
51
  }
52
52
  function reaches(settings, platform) {
53
53
  return settings.platforms === null || (platform !== undefined && settings.platforms.includes(platform));
@@ -278,7 +278,7 @@ async function load(loads, deps, settings) {
278
278
  catch {
279
279
  return refused;
280
280
  }
281
- if (!isMethodAllowed(details.method, settings.permissions) || !reaches(settings, details.connectionPlatform)) {
281
+ if (!isAccessAllowed(details.access, settings.permissions) || !reaches(settings, details.connectionPlatform)) {
282
282
  return refused;
283
283
  }
284
284
  const text = renderAction({
@@ -9,13 +9,14 @@ const LARGE = [
9
9
  '## Request Body\n### Required Request Body Fields\n- to: string',
10
10
  `## Response Fields\n${Array.from({ length: 400 }, (_, i) => `- field ${i}: a described response field`).join('\n')}`,
11
11
  ].join('\n\n');
12
- const action = (id, method = 'POST', tags = []) => ({
12
+ const action = (id, method = 'POST', tags = [], access = method === 'GET' ? 'read' : 'write') => ({
13
13
  systemId: id,
14
14
  title: `Action ${id}`,
15
15
  key: `key-${id}`,
16
16
  method,
17
17
  path: `/v1/${id}`,
18
18
  tags,
19
+ access,
19
20
  knowledge: 'a digest core rendered for its own route',
20
21
  });
21
22
  const answer = (overrides = {}) => ({
@@ -54,6 +55,7 @@ function deps(answers, knowledge = {}) {
54
55
  _id: id,
55
56
  title: `Action ${id}`,
56
57
  method: id === 'c' ? 'GET' : 'POST',
58
+ access: id === 'unclassified' ? undefined : id === 'c' ? 'read' : id === 'gone' ? 'delete' : 'write',
57
59
  path: `/v1/${id}`,
58
60
  tags: id === 'custom' ? ['custom'] : [],
59
61
  knowledge: knowledge[id] ?? `# Action ${id}\n\nSmall doc for ${id}.`,
@@ -100,6 +102,30 @@ describe('find_one_actions', () => {
100
102
  assert.ok(text.indexOf('actionId: `d`') < text.indexOf('actionId: `c`'), 'the runner-up stands in first, the companion after it');
101
103
  assert.ok(!text.includes('use this one instead'), 'the promoted runner-up is not also offered as a substitute');
102
104
  });
105
+ it('judges an action by its access level, not its HTTP method', async () => {
106
+ const text = await findOneActions({ requests: intent }, deps([answer({ selected: [action('post-read', 'POST', [], 'read')], alternatives: [action('get-write', 'GET', [], 'write')] })]), settings({ permissions: 'read' }));
107
+ assert.ok(text.includes('actionId: `post-read`'), 'a POST that only reads is offered at the read level');
108
+ assert.ok(!text.includes('actionId: `get-write`'), 'a GET that writes is not');
109
+ });
110
+ it('keeps delete actions from the write level, whatever their method', async () => {
111
+ const text = await findOneActions({ requests: intent }, deps([answer({ selected: [action('post-delete', 'POST', [], 'delete')], alternatives: [action('delete-write', 'DELETE', [], 'write')] })]), settings({ permissions: 'write' }));
112
+ assert.ok(!text.includes('actionId: `post-delete`'));
113
+ assert.ok(text.includes('actionId: `delete-write`'));
114
+ });
115
+ it('offers an action with no access level only at the admin level', async () => {
116
+ const unclassified = () => answer({ selected: [action('none', 'GET', [], null)], alternatives: [] });
117
+ const refused = await findOneActions({ requests: intent }, deps([unclassified()]), settings({ permissions: 'read' }));
118
+ assert.ok(!refused.includes('actionId: `none`'));
119
+ const offered = await findOneActions({ requests: intent }, deps([unclassified()]), settings());
120
+ assert.ok(offered.includes('actionId: `none`'));
121
+ });
122
+ it('refuses a load by access level, the same as an action it does not know', async () => {
123
+ const text = await findOneActions({ load: [{ action_id: 'c' }, { action_id: 'a' }, { action_id: 'unclassified' }, { action_id: 'missing' }] }, deps([]), settings({ permissions: 'read' }));
124
+ assert.ok(text.includes('Small doc for c.'));
125
+ for (const id of ['a', 'unclassified', 'missing']) {
126
+ assert.ok(text.includes(`\`${id}\`: ${REFUSED_LOAD}`), id);
127
+ }
128
+ });
103
129
  it('serves the first document a load actually returns, however large, even after a refused entry', async () => {
104
130
  const huge = `# Huge\n\n${'x'.repeat(450_000)}`;
105
131
  const text = await findOneActions({ load: [{ action_id: 'missing' }, { action_id: 'a', full: true }] }, deps([], { a: huge }), settings());
package/build/helpers.js CHANGED
@@ -261,16 +261,27 @@ export function replacePathVariables(path, variables) {
261
261
  }
262
262
  return filled;
263
263
  }
264
- const PERMISSION_METHODS = {
265
- read: ["GET"],
266
- write: ["GET", "POST", "PUT", "PATCH"],
264
+ const PERMISSION_LEVELS = {
265
+ read: ["read"],
266
+ write: ["read", "write"],
267
267
  admin: null,
268
268
  };
269
- export function isMethodAllowed(method, permissions) {
270
- const allowed = PERMISSION_METHODS[permissions];
269
+ /**
270
+ * Whether the permission level allows an action classified at `access`. Below
271
+ * `admin`, an action with no level or one this server does not know is refused,
272
+ * since nothing says it is safe at that level.
273
+ */
274
+ export function isAccessAllowed(access, permissions) {
275
+ const allowed = PERMISSION_LEVELS[permissions];
271
276
  if (allowed === null)
272
277
  return true;
273
- return allowed.includes(method.toUpperCase());
278
+ return allowed.includes(access);
279
+ }
280
+ /** What an agent is told when the permission level refuses an action. */
281
+ export function accessRefusal(actionId, access, permissions) {
282
+ return access
283
+ ? `Action "${actionId}" is classified as ${access}, which this server's "${permissions}" permission level does not allow, so it cannot be run here.`
284
+ : `Action "${actionId}" has no access level, so this server's "${permissions}" permission level does not allow it and it cannot be run here.`;
274
285
  }
275
286
  export function isActionAllowed(actionId, allowedActionIds) {
276
287
  return allowedActionIds.includes("*") || allowedActionIds.includes(actionId);
@@ -280,9 +291,9 @@ export function isActionAllowed(actionId, allowedActionIds) {
280
291
  * `platform`, so `list_one_integrations` can surface it without a search.
281
292
  * Mirrors the One core `resolve_connection_access` precedence:
282
293
  * an action allowlist wins (report the enumerated actions on this platform),
283
- * else a non-`admin` permission level reports its method set, else full.
294
+ * else a non-`admin` permission level reports its access levels, else full.
284
295
  * `resolvedAllowed` is the allowlisted actions already resolved to their
285
- * metadata and method-filtered by the permission level.
296
+ * metadata and filtered by the permission level.
286
297
  */
287
298
  export function computeConnectionAccess(platform, permissions, allowedActionIds, resolvedAllowed) {
288
299
  if (!allowedActionIds.includes("*")) {
@@ -291,9 +302,9 @@ export function computeConnectionAccess(platform, permissions, allowedActionIds,
291
302
  .map(({ actionId, title, method }) => ({ actionId, title, method }));
292
303
  return { policy: "actions", actions };
293
304
  }
294
- const methods = PERMISSION_METHODS[permissions];
295
- if (methods !== null) {
296
- return { policy: "methods", methods };
305
+ const levels = PERMISSION_LEVELS[permissions];
306
+ if (levels !== null) {
307
+ return { policy: "levels", levels };
297
308
  }
298
309
  return { policy: "full" };
299
310
  }
package/build/index.js CHANGED
@@ -11,7 +11,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
12
12
  import { ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
13
13
  import { OneClient } from './client.js';
14
- import { isMethodAllowed, isActionAllowed, buildIntegrationsResponse, } from './helpers.js';
14
+ import { accessRefusal, isAccessAllowed, isActionAllowed, buildIntegrationsResponse, } from './helpers.js';
15
15
  import { findOneActions } from './find.js';
16
16
  import { ToolError, toolErrorResult } from './tool-error.js';
17
17
  import { unpatchedNodeRefusal } from './node-check.js';
@@ -102,11 +102,11 @@ if (!ONE_KNOWLEDGE_AGENT) {
102
102
  }
103
103
  async function handleGetIntegrations(args) {
104
104
  try {
105
- // Resolve the action allowlist to per-platform metadata (method-filtered by
106
- // the permission level) once, so each connection can report the exact
105
+ // Resolve the action allowlist to per-platform metadata (filtered by the
106
+ // permission level) once, so each connection can report the exact
107
107
  // actions it may run. Only needed when an action allowlist is set.
108
108
  const resolvedAllowed = (await oneClient.resolveAllowedActions(ONE_ACTION_IDS))
109
- .filter(action => isMethodAllowed(action.method, ONE_PERMISSIONS));
109
+ .filter(action => isAccessAllowed(action.access, ONE_PERMISSIONS));
110
110
  // Execute mode lists only connections: every connection carries its
111
111
  // access, and the full catalog (1000+ platforms) would sit in the agent's
112
112
  // context for the rest of the session. Knowledge/code-gen mode also lists
@@ -165,8 +165,8 @@ async function handleExecuteOneAction(args) {
165
165
  }
166
166
  await oneClient.ensureConnectionInScope(args.connectionKey);
167
167
  const actionDetails = await oneClient.getActionDetails(args.actionId);
168
- if (!isMethodAllowed(actionDetails.method, ONE_PERMISSIONS)) {
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.`);
168
+ if (!isAccessAllowed(actionDetails.access, ONE_PERMISSIONS)) {
169
+ throw new ToolError(accessRefusal(args.actionId, actionDetails.access, ONE_PERMISSIONS));
170
170
  }
171
171
  const result = await oneClient.executePassthroughRequest(args, actionDetails);
172
172
  return {
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { buildIntegrationsResponse } from './helpers.js';
3
+ import { accessRefusal, buildIntegrationsResponse, isAccessAllowed } from './helpers.js';
4
4
  const conn = (platform, active = true) => ({ key: `live::${platform}::default::k`, platform, tags: [], active });
5
5
  const def = (platform, extra = {}) => ({ platform, name: platform.toUpperCase(), category: 'Test', active: true, deprecated: false, ...extra });
6
6
  const FULL = { permissions: 'admin', actionIds: ['*'], resolvedAllowed: [] };
@@ -13,11 +13,13 @@ describe('buildIntegrationsResponse', () => {
13
13
  });
14
14
  it('keeps the per-connection access', () => {
15
15
  const r = buildIntegrationsResponse([conn('gmail')], { permissions: 'read', actionIds: ['*'], resolvedAllowed: [] });
16
- assert.deepEqual(r.connections[0].access, { policy: 'methods', methods: ['GET'] });
16
+ assert.deepEqual(r.connections[0].access, { policy: 'levels', levels: ['read'] });
17
+ const writer = buildIntegrationsResponse([conn('gmail')], { permissions: 'write', actionIds: ['*'], resolvedAllowed: [] });
18
+ assert.deepEqual(writer.connections[0].access, { policy: 'levels', levels: ['read', 'write'] });
17
19
  const scoped = buildIntegrationsResponse([conn('gmail')], {
18
20
  permissions: 'admin',
19
21
  actionIds: ['act_1'],
20
- resolvedAllowed: [{ actionId: 'act_1', title: 'Send Email', method: 'POST', platform: 'gmail' }],
22
+ resolvedAllowed: [{ actionId: 'act_1', title: 'Send Email', method: 'POST', access: 'write', platform: 'gmail' }],
21
23
  });
22
24
  assert.deepEqual(scoped.connections[0].access, {
23
25
  policy: 'actions',
@@ -38,3 +40,35 @@ describe('buildIntegrationsResponse', () => {
38
40
  assert.deepEqual(r.summary, { connectedCount: 1, availableCount: 2 });
39
41
  });
40
42
  });
43
+ describe('isAccessAllowed', () => {
44
+ const cases = [
45
+ ['read', 'read', true],
46
+ ['write', 'read', false],
47
+ ['delete', 'read', false],
48
+ ['read', 'write', true],
49
+ ['write', 'write', true],
50
+ ['delete', 'write', false],
51
+ ['read', 'admin', true],
52
+ ['write', 'admin', true],
53
+ ['delete', 'admin', true],
54
+ [undefined, 'read', false],
55
+ [undefined, 'write', false],
56
+ [null, 'write', false],
57
+ ['READ', 'read', false],
58
+ ['execute', 'write', false],
59
+ [undefined, 'admin', true],
60
+ ];
61
+ for (const [access, level, expected] of cases) {
62
+ it(`${String(access)} at ${level} is ${expected ? 'allowed' : 'refused'}`, () => {
63
+ assert.equal(isAccessAllowed(access, level), expected);
64
+ });
65
+ }
66
+ });
67
+ describe('accessRefusal', () => {
68
+ it('names the action, its level and the server level', () => {
69
+ assert.equal(accessRefusal('act_1', 'delete', 'write'), `Action "act_1" is classified as delete, which this server's "write" permission level does not allow, so it cannot be run here.`);
70
+ });
71
+ it('says so when the action has no level', () => {
72
+ assert.equal(accessRefusal('act_1', undefined, 'read'), `Action "act_1" has no access level, so this server's "read" permission level does not allow it and it cannot be run here.`);
73
+ });
74
+ });
package/build/schemas.js CHANGED
@@ -67,8 +67,8 @@ const connectionAccessSchema = z.union([
67
67
  policy: z.literal("full")
68
68
  }),
69
69
  z.object({
70
- policy: z.literal("methods"),
71
- methods: z.array(z.string())
70
+ policy: z.literal("levels"),
71
+ levels: z.array(z.enum(["read", "write", "delete"]))
72
72
  }),
73
73
  z.object({
74
74
  policy: z.literal("actions"),
@@ -78,7 +78,7 @@ const connectionAccessSchema = z.union([
78
78
  method: z.string()
79
79
  }))
80
80
  })
81
- ]).describe("What the access config lets you run on this connection: `full`, an allowed `methods` set, or a specific `actions` list. When `actions`, those are exactly what may run, so no search is needed.");
81
+ ]).describe("What the access config lets you run on this connection: `full`, the access `levels` you may run (`read`, `write`, `delete`), or a specific `actions` list. When `actions`, those are exactly what may run, so no search is needed.");
82
82
  export const listOneIntegrationsOutputSchema = {
83
83
  connections: z.array(z.object({
84
84
  platform: z.string(),
@@ -111,7 +111,7 @@ const READ_ONLY_ANNOTATIONS = {
111
111
  */
112
112
  export const listOneIntegrationsToolConfig = {
113
113
  title: "List One Integrations",
114
- description: "List the platforms the user has connected on One. ALWAYS call this tool first in any workflow. Each connection has the kebab-case `platform` name (e.g., 'ship-station', 'shopify') and the `key` (the connectionKey for execute_one_action) you'll need for subsequent tool calls. Each connection carries an `access` field describing what you may run on it: `full`, a set of allowed HTTP `methods`, or a specific list of `actions` (each with `actionId`, `title`, `method`). When a connection is action-scoped, its `actions` are exactly what may run, so you need not search.",
114
+ description: "List the platforms the user has connected on One. ALWAYS call this tool first in any workflow. Each connection has the kebab-case `platform` name (e.g., 'ship-station', 'shopify') and the `key` (the connectionKey for execute_one_action) you'll need for subsequent tool calls. Each connection carries an `access` field describing what you may run on it: `full`, a set of allowed access `levels` (`read`, `write`, `delete`), or a specific list of `actions` (each with `actionId`, `title`, `method`). When a connection is action-scoped, its `actions` are exactly what may run, so you need not search.",
115
115
  inputSchema: listOneIntegrationsInputSchema,
116
116
  outputSchema: listOneIntegrationsOutputSchema,
117
117
  annotations: READ_ONLY_ANNOTATIONS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/mcp",
3
- "version": "2.3.3",
3
+ "version": "2.4.0",
4
4
  "description": "A Model Context Protocol Server for One",
5
5
  "type": "module",
6
6
  "bin": {