@withone/mcp 2.3.3 → 2.5.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
 
@@ -134,6 +134,7 @@ Fine-tune what the MCP server can see and do:
134
134
 
135
135
  ```bash
136
136
  ONE_PERMISSIONS=read
137
+ ONE_APPROVAL=write
137
138
  ONE_CONNECTION_KEYS=conn_key_1,conn_key_2
138
139
  ONE_ACTION_IDS=action_id_1,action_id_2
139
140
  ONE_KNOWLEDGE_AGENT=true
@@ -141,7 +142,8 @@ ONE_KNOWLEDGE_AGENT=true
141
142
 
142
143
  | Variable | Type | Default | Description |
143
144
  |---|---|---|---|
144
- | `ONE_PERMISSIONS` | `read` \| `write` \| `admin` | `admin` | Filter actions by HTTP method. `read` = GET only, `write` = GET/POST/PUT/PATCH, `admin` = all methods |
145
+ | `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 |
146
+ | `ONE_APPROVAL` | `off` \| `delete` \| `write` | `off` | Ask the user before an action runs. `delete` asks for `delete` actions, `write` asks for `write` and `delete` actions, and `read` actions never ask. An action with no classification is asked about at both levels. See [Approval](#approval) |
145
147
  | `ONE_CONNECTION_KEYS` | `*` or comma-separated keys | `*` | Restrict visible connections and platforms to specific connection keys |
146
148
  | `ONE_ACTION_IDS` | `*` or comma-separated IDs | `*` | Restrict visible and executable actions to specific action IDs |
147
149
  | `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,9 +155,17 @@ Whatever you configure here is surfaced back to the agent: `list_one_integration
153
155
  | `access` | When |
154
156
  |---|---|
155
157
  | `{ "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. |
158
+ | `{ "policy": "levels", "levels": ["read", ...] }` | No action allowlist, but `ONE_PERMISSIONS` is `read`/`write` — only actions classified at these access levels are runnable. |
157
159
  | `{ "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
160
 
161
+ ### Approval
162
+
163
+ An agent that has just read an email, a web page or another third-party document can be steered by what it read. With `ONE_APPROVAL` set, the person at the MCP client decides whether a change goes ahead, not the agent.
164
+
165
+ Before `execute_one_action` runs an action that needs approval, the server shows a prompt through [MCP elicitation](https://modelcontextprotocol.io/specification/latest/client/elicitation). It names the action, the platform, the connection and what will be sent, and the user ticks a box to run it. Declining, dismissing, leaving the box unticked or not answering within 10 minutes stops the action, and nothing is sent.
166
+
167
+ Your MCP client has to support elicitation. If it doesn't, every action that needs approval is refused, so check your client before turning this on.
168
+
159
169
  ## Manual Configuration
160
170
 
161
171
  If you used `one init`, the configuration below is already done for you. These examples are for reference or manual setups.
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Approval for actions that change data (`ONE_APPROVAL`).
3
+ *
4
+ * With approval on, `execute_one_action` asks the user before it runs a write
5
+ * or delete, through MCP elicitation: the protocol's way for a server to ask
6
+ * the person at the client a question. An agent that has just read
7
+ * third-party content (an email, a web page) can be steered by it, so the
8
+ * person, not the agent, decides whether a change goes ahead. A client that
9
+ * cannot ask is refused rather than run unapproved.
10
+ *
11
+ * @fileoverview When an action needs approval, and how it is asked for
12
+ * @author One
13
+ */
14
+ import { ToolError } from './tool-error.js';
15
+ export const APPROVAL_LEVELS = ['off', 'delete', 'write'];
16
+ /** How long the user has to answer before the action is refused. */
17
+ export const APPROVAL_TIMEOUT_MS = 10 * 60 * 1000;
18
+ /** How much of the request the prompt shows. */
19
+ export const APPROVAL_REQUEST_CHARS = 2_000;
20
+ /**
21
+ * Whether an action at `access` needs approval at `level`. An action with no
22
+ * level, or one this server does not know, is treated as a delete, since
23
+ * nothing says it is safer.
24
+ */
25
+ export function needsApproval(access, level) {
26
+ if (level === 'off')
27
+ return false;
28
+ if (level === 'delete')
29
+ return access !== 'read' && access !== 'write';
30
+ return access !== 'read';
31
+ }
32
+ /**
33
+ * Whether the client can show a form prompt. Per the spec, an `elicitation`
34
+ * capability naming neither mode means form, as clients declared it before
35
+ * modes existed.
36
+ */
37
+ export function supportsFormElicitation(capabilities) {
38
+ const elicitation = capabilities?.elicitation;
39
+ if (!elicitation)
40
+ return false;
41
+ return elicitation.form !== undefined || elicitation.url === undefined;
42
+ }
43
+ /** The form the user answers: one box to tick. */
44
+ export const APPROVAL_SCHEMA = {
45
+ type: 'object',
46
+ properties: {
47
+ approve: {
48
+ type: 'boolean',
49
+ title: 'Run this action',
50
+ description: 'Tick to run it now. Leave it unticked, decline or dismiss to stop it.',
51
+ default: false,
52
+ },
53
+ },
54
+ required: ['approve'],
55
+ };
56
+ /** What the user reads: what will run, where, and with what. */
57
+ export function approvalMessage(request) {
58
+ const kind = request.access === 'read' || request.access === 'write' || request.access === 'delete' ? request.access : 'unclassified';
59
+ const sent = {};
60
+ if (request.pathVariables !== undefined)
61
+ sent.pathVariables = request.pathVariables;
62
+ if (request.queryParams !== undefined)
63
+ sent.queryParams = request.queryParams;
64
+ if (request.data !== undefined)
65
+ sent.data = request.data;
66
+ let body = Object.keys(sent).length > 0 ? JSON.stringify(sent, null, 2) : '(no parameters)';
67
+ if (body.length > APPROVAL_REQUEST_CHARS) {
68
+ body = `${body.slice(0, APPROVAL_REQUEST_CHARS)}\n… (${body.length - APPROVAL_REQUEST_CHARS} more characters not shown)`;
69
+ }
70
+ return [
71
+ `Your AI agent wants to run ${kind === 'unclassified' ? 'an' : 'a'} ${kind} action on ${request.platform}.`,
72
+ '',
73
+ `${request.title}`,
74
+ `${request.method.toUpperCase()} ${request.path}`,
75
+ `Connection: ${request.connectionKey}`,
76
+ '',
77
+ 'Request:',
78
+ body,
79
+ ].join('\n');
80
+ }
81
+ /**
82
+ * Asks the user to approve `request` when `level` calls for it, and returns
83
+ * only once they have. Anything short of an explicit approval refuses.
84
+ * @throws {ToolError} When the user did not approve, or could not be asked
85
+ */
86
+ export async function requireApproval(request, level, deps) {
87
+ if (!needsApproval(request.access, level))
88
+ return;
89
+ if (!supportsFormElicitation(deps.capabilities)) {
90
+ throw new ToolError(`Action "${request.actionId}" was not run: this server asks the user to approve actions like it, and this MCP client cannot show an approval prompt. Tell the user the action needs their approval and their client does not support approval prompts.`);
91
+ }
92
+ let answer;
93
+ try {
94
+ answer = await deps.elicit({ message: approvalMessage(request), requestedSchema: APPROVAL_SCHEMA });
95
+ }
96
+ catch (error) {
97
+ throw new ToolError(`Action "${request.actionId}" was not run: the approval prompt failed or was not answered in time (${error instanceof Error ? error.message : 'unknown error'}). Ask the user whether to try again.`);
98
+ }
99
+ if (answer.action === 'accept' && answer.content?.approve === true)
100
+ return;
101
+ if (answer.action === 'decline' || answer.action === 'accept') {
102
+ throw new ToolError(`Action "${request.actionId}" was not run: the user did not approve it. Do not run it again unless the user asks you to.`);
103
+ }
104
+ throw new ToolError(`Action "${request.actionId}" was not run: the user dismissed the approval prompt. Do not run it again unless the user asks you to.`);
105
+ }
@@ -0,0 +1,125 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { APPROVAL_REQUEST_CHARS, APPROVAL_SCHEMA, approvalMessage, needsApproval, requireApproval, supportsFormElicitation, } from './approval.js';
4
+ import { ToolError } from './tool-error.js';
5
+ const request = (overrides = {}) => ({
6
+ actionId: 'act_1',
7
+ title: 'Send Email',
8
+ method: 'post',
9
+ path: '/v1/gmail/send-email',
10
+ platform: 'gmail',
11
+ connectionKey: 'live::gmail::default::k',
12
+ access: 'write',
13
+ data: { to: 'a@example.com', subject: 'Hi' },
14
+ ...overrides,
15
+ });
16
+ /** A session that answers `answer`, recording every prompt it was asked to show. */
17
+ function session(answer, ...declared) {
18
+ const capabilities = declared.length > 0 ? declared[0] : { elicitation: {} };
19
+ const asked = [];
20
+ const deps = {
21
+ capabilities,
22
+ async elicit(params) {
23
+ asked.push(params);
24
+ if (answer instanceof Error)
25
+ throw answer;
26
+ return answer;
27
+ },
28
+ };
29
+ return { deps, asked };
30
+ }
31
+ describe('needsApproval', () => {
32
+ const cases = [
33
+ ['read', 'off', false],
34
+ ['write', 'off', false],
35
+ ['delete', 'off', false],
36
+ [undefined, 'off', false],
37
+ ['read', 'delete', false],
38
+ ['write', 'delete', false],
39
+ ['delete', 'delete', true],
40
+ [undefined, 'delete', true],
41
+ ['execute', 'delete', true],
42
+ ['read', 'write', false],
43
+ ['write', 'write', true],
44
+ ['delete', 'write', true],
45
+ [undefined, 'write', true],
46
+ ];
47
+ for (const [access, level, expected] of cases) {
48
+ it(`${String(access)} at ${level} ${expected ? 'asks' : 'does not ask'}`, () => {
49
+ assert.equal(needsApproval(access, level), expected);
50
+ });
51
+ }
52
+ });
53
+ describe('supportsFormElicitation', () => {
54
+ it('reads an empty elicitation capability as form, and needs form when modes are named', () => {
55
+ assert.equal(supportsFormElicitation(undefined), false);
56
+ assert.equal(supportsFormElicitation({}), false);
57
+ assert.equal(supportsFormElicitation({ elicitation: {} }), true);
58
+ assert.equal(supportsFormElicitation({ elicitation: { form: {} } }), true);
59
+ assert.equal(supportsFormElicitation({ elicitation: { form: {}, url: {} } }), true);
60
+ assert.equal(supportsFormElicitation({ elicitation: { url: {} } }), false);
61
+ });
62
+ });
63
+ describe('requireApproval', () => {
64
+ it('runs a read without asking, even with approval on', async () => {
65
+ const s = session(new Error('should not ask'));
66
+ await requireApproval(request({ access: 'read' }), 'write', s.deps);
67
+ assert.equal(s.asked.length, 0);
68
+ });
69
+ it('runs anything without asking when approval is off', async () => {
70
+ const s = session(new Error('should not ask'), undefined);
71
+ await requireApproval(request({ access: 'delete' }), 'off', s.deps);
72
+ assert.equal(s.asked.length, 0);
73
+ });
74
+ it('runs once the user ticks the box', async () => {
75
+ const s = session({ action: 'accept', content: { approve: true } });
76
+ await requireApproval(request(), 'write', s.deps);
77
+ assert.equal(s.asked.length, 1);
78
+ assert.deepEqual(s.asked[0].requestedSchema, APPROVAL_SCHEMA);
79
+ });
80
+ for (const [label, answer] of [
81
+ ['declined', { action: 'decline' }],
82
+ ['accepted without ticking the box', { action: 'accept', content: { approve: false } }],
83
+ ['accepted with no content', { action: 'accept' }],
84
+ ['accepted with a truthy non-boolean', { action: 'accept', content: { approve: 'yes' } }],
85
+ ['dismissed', { action: 'cancel' }],
86
+ ]) {
87
+ it(`refuses when the prompt is ${label}`, async () => {
88
+ const s = session(answer);
89
+ await assert.rejects(requireApproval(request(), 'write', s.deps), (e) => e instanceof ToolError && /was not run/.test(e.message));
90
+ });
91
+ }
92
+ it('refuses when the prompt fails or times out', async () => {
93
+ const s = session(new Error('Request timed out'));
94
+ await assert.rejects(requireApproval(request({ access: 'delete' }), 'delete', s.deps), (e) => e instanceof ToolError && /Request timed out/.test(e.message));
95
+ });
96
+ it('refuses without asking when the client cannot show a prompt', async () => {
97
+ for (const capabilities of [undefined, {}, { elicitation: { url: {} } }]) {
98
+ const s = session({ action: 'accept', content: { approve: true } }, capabilities);
99
+ await assert.rejects(requireApproval(request(), 'write', s.deps), (e) => e instanceof ToolError && /cannot show an approval prompt/.test(e.message));
100
+ assert.equal(s.asked.length, 0);
101
+ }
102
+ });
103
+ it('asks for an unclassified action at the delete level', async () => {
104
+ const s = session({ action: 'accept', content: { approve: true } });
105
+ await requireApproval(request({ access: undefined }), 'delete', s.deps);
106
+ assert.ok(s.asked[0].message.includes('wants to run an unclassified action'));
107
+ });
108
+ });
109
+ describe('approvalMessage', () => {
110
+ it('names the action, where it runs and what it sends', () => {
111
+ const text = approvalMessage(request({ pathVariables: { id: '42' }, queryParams: { dry: false } }));
112
+ for (const part of ['write action on gmail', 'Send Email', 'POST /v1/gmail/send-email', 'live::gmail::default::k', '"to": "a@example.com"', '"id": "42"', '"dry": false']) {
113
+ assert.ok(text.includes(part), part);
114
+ }
115
+ });
116
+ it('shortens a large request and says so', () => {
117
+ const text = approvalMessage(request({ data: { body: 'x'.repeat(10_000) } }));
118
+ assert.ok(text.length < APPROVAL_REQUEST_CHARS + 500);
119
+ assert.match(text, /more characters not shown/);
120
+ });
121
+ it('says when there is nothing to send', () => {
122
+ const text = approvalMessage(request({ data: undefined }));
123
+ assert.ok(text.includes('(no parameters)'));
124
+ });
125
+ });
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
@@ -9,9 +9,10 @@
9
9
  */
10
10
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
11
11
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
12
- import { ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
12
+ import { ElicitResultSchema, ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
13
+ import { APPROVAL_LEVELS, APPROVAL_TIMEOUT_MS, requireApproval } from './approval.js';
13
14
  import { OneClient } from './client.js';
14
- import { isMethodAllowed, isActionAllowed, buildIntegrationsResponse, } from './helpers.js';
15
+ import { accessRefusal, isAccessAllowed, isActionAllowed, buildIntegrationsResponse, } from './helpers.js';
15
16
  import { findOneActions } from './find.js';
16
17
  import { ToolError, toolErrorResult } from './tool-error.js';
17
18
  import { unpatchedNodeRefusal } from './node-check.js';
@@ -32,6 +33,11 @@ if (!["read", "write", "admin"].includes(ONE_PERMISSIONS)) {
32
33
  console.error(`Invalid ONE_PERMISSIONS value: "${ONE_PERMISSIONS}". Must be one of: read, write, admin`);
33
34
  process.exit(1);
34
35
  }
36
+ const ONE_APPROVAL = (process.env.ONE_APPROVAL || "off");
37
+ if (!APPROVAL_LEVELS.includes(ONE_APPROVAL)) {
38
+ console.error(`Invalid ONE_APPROVAL value: "${ONE_APPROVAL}". Must be one of: ${APPROVAL_LEVELS.join(", ")}`);
39
+ process.exit(1);
40
+ }
35
41
  const ONE_CONNECTION_KEYS = process.env.ONE_CONNECTION_KEYS
36
42
  ? process.env.ONE_CONNECTION_KEYS.split(",").map(s => s.trim()).filter(Boolean)
37
43
  : ["*"];
@@ -93,20 +99,20 @@ server.registerTool("find_one_actions", findOneActionsToolConfig, async (args) =
93
99
  return await handleFindOneActions(args);
94
100
  });
95
101
  if (!ONE_KNOWLEDGE_AGENT) {
96
- server.registerTool("execute_one_action", executeOneActionToolConfig, async (args) => {
102
+ server.registerTool("execute_one_action", executeOneActionToolConfig, async (args, extra) => {
97
103
  if (NODE_REFUSAL)
98
104
  return toolErrorResult(new ToolError(NODE_REFUSAL));
99
105
  await initializeOne();
100
- return await handleExecuteOneAction(args);
106
+ return await handleExecuteOneAction(args, extra);
101
107
  });
102
108
  }
103
109
  async function handleGetIntegrations(args) {
104
110
  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
111
+ // Resolve the action allowlist to per-platform metadata (filtered by the
112
+ // permission level) once, so each connection can report the exact
107
113
  // actions it may run. Only needed when an action allowlist is set.
108
114
  const resolvedAllowed = (await oneClient.resolveAllowedActions(ONE_ACTION_IDS))
109
- .filter(action => isMethodAllowed(action.method, ONE_PERMISSIONS));
115
+ .filter(action => isAccessAllowed(action.access, ONE_PERMISSIONS));
110
116
  // Execute mode lists only connections: every connection carries its
111
117
  // access, and the full catalog (1000+ platforms) would sit in the agent's
112
118
  // context for the rest of the session. Knowledge/code-gen mode also lists
@@ -158,16 +164,38 @@ async function handleFindOneActions(args) {
158
164
  throw new McpError(ErrorCode.InternalError, `Failed to find actions: ${error instanceof Error ? error.message : 'Unknown error'}`);
159
165
  }
160
166
  }
161
- async function handleExecuteOneAction(args) {
167
+ async function handleExecuteOneAction(args, extra) {
162
168
  try {
163
169
  if (!isActionAllowed(args.actionId, ONE_ACTION_IDS)) {
164
170
  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.`);
165
171
  }
166
172
  await oneClient.ensureConnectionInScope(args.connectionKey);
167
173
  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.`);
174
+ if (!isAccessAllowed(actionDetails.access, ONE_PERMISSIONS)) {
175
+ throw new ToolError(accessRefusal(args.actionId, actionDetails.access, ONE_PERMISSIONS));
170
176
  }
177
+ await requireApproval({
178
+ actionId: args.actionId,
179
+ title: actionDetails.title,
180
+ method: actionDetails.method,
181
+ path: actionDetails.path,
182
+ platform: actionDetails.connectionPlatform ?? args.platform,
183
+ connectionKey: args.connectionKey,
184
+ access: actionDetails.access,
185
+ pathVariables: args.pathVariables,
186
+ queryParams: args.queryParams,
187
+ data: args.data,
188
+ }, ONE_APPROVAL, {
189
+ capabilities: server.server.getClientCapabilities(),
190
+ // Sent as a plain form request, not through elicitInput, which
191
+ // refuses clients that declare elicitation without naming a mode.
192
+ // Tied to the tool call so it travels on the same stream.
193
+ elicit: (params) => server.server.request({ method: "elicitation/create", params }, ElicitResultSchema, {
194
+ timeout: APPROVAL_TIMEOUT_MS,
195
+ relatedRequestId: extra.requestId,
196
+ signal: extra.signal,
197
+ }),
198
+ });
171
199
  const result = await oneClient.executePassthroughRequest(args, actionDetails);
172
200
  return {
173
201
  content: [
@@ -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.5.0",
4
4
  "description": "A Model Context Protocol Server for One",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "inspector": "npx @modelcontextprotocol/inspector build/index.js"
18
18
  },
19
19
  "dependencies": {
20
- "@modelcontextprotocol/sdk": "^1.12.1",
20
+ "@modelcontextprotocol/sdk": "^1.32.2",
21
21
  "axios": "^1.20.0",
22
22
  "form-data": "^4.0.3",
23
23
  "zod": "^3.23.0"