You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 82e19a3
Browse filesBrowse the repository at this point in the historyBrowse files
feat(mcp): enable code mode for every caller and remove the mcp-code-mode flag
- Every Sim MCP caller gets execute_read_code and execute_write_code; the sandbox owner key comes from the principal (person, or workspace for workspace keys)
- Default program timeout is 45s, under the 60s MCP client request default
- A null query value is left out, so the last page's null cursor ends paging
- The scope pre-check trims the operation name like the call tools do
- Docs state the 256 KB per-call input limit and drop the beta note
Copy file name to clipboardExpand all lines: apps/docs/content/docs/mcp/tools.mdx
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Tools
3
3
description: Discover an operation, inspect its request, and call it with the correct access.
4
4
---
5
5
6
-
Sim MCP exposes four tools for discovering and calling its supported JSON API operations. Search for an operation, inspect its inputs, then call the read or write tool named in its description.
6
+
Sim MCP exposes six tools for discovering and calling its supported JSON API operations. Search for an operation, inspect its inputs, then call the read or write tool named in its description, or run a program that makes many calls with a [code tool](#code-mode).
7
7
8
8
## Tools
9
9
@@ -72,13 +72,12 @@ correct its request.
72
72
73
73
`getWorkflowSource` returns a workflow as TypeScript source files with its `lock` and `base`. Edit the files and send them back, with the same `lock` and `base`, through `applyWorkflowSource`, first with `query: {"dryRun": true}`. One call replaces a batch of graph operations. Workflows as code is in preview; see [Workflows as code](/workflows/code).
74
74
75
-
## Code mode (beta)
75
+
## Code mode
76
76
77
77
For a task that takes many calls, such as paging through a list, filtering, or
78
78
updating every item that matches, the agent can write one program instead of
79
79
making each call itself. Only the program's return value comes back, so
80
-
intermediate results stay out of the model's context. Code mode is in beta and
81
-
appears only for accounts where it is enabled.
80
+
intermediate results stay out of the model's context.
82
81
83
82
| Tool | Does |
84
83
| --- | --- |
@@ -115,8 +114,10 @@ happened.
115
114
116
115
Each call runs through the API exactly as a call tool's would, with the same
117
116
credential, permissions, and rate limits. The program has no network access and
118
-
never sees your credential. A program runs for at most 60 seconds by default (up
117
+
never sees your credential. A program runs for at most 45 seconds by default (up
119
118
to 120 with `timeoutMs`), makes at most 200 calls, and returns at most 1 MiB.
119
+
One call's input may be at most 256 KB as JSON; send a larger body, such as a
'Query-string values by name, as the query schema from describe_operation lists them, e.g. { "limit": 50 } or the cursor from the previous page.'
47
+
'Query-string values by name, as the query schema from describe_operation lists them, e.g. { "limit": 50 } or the cursor from the previous page. A null value is left out, so the last page’s null cursor ends paging.'
Copy file name to clipboardExpand all lines: apps/sim/lib/api/mcp/code-mode.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,8 @@ import { SIM_API_CODE_MAX_TIMEOUT_MS } from '@/sandboxes/sim-api-code'
25
25
26
26
constlogger=createLogger('SimMcpCodeMode')
27
27
28
-
constDEFAULT_TIMEOUT_MS=60_000
28
+
/** Under the 60-second request timeout MCP clients default to, so a default run answers before its client gives up. */
29
+
constDEFAULT_TIMEOUT_MS=45_000
29
30
/** API calls one program may make; each is a full v2 request against the caller's rate limit. */
30
31
constMAX_CALLS_PER_RUN=200
31
32
/** Calls one program may have in flight at once, so a `Promise.all` cannot fan out a whole page of requests. */
@@ -40,7 +41,7 @@ export const codeModeInput = z
40
41
.min(1)
41
42
.max(MAX_CODE_CHARS)
42
43
.describe(
43
-
'The body of an async function. Call operations with `await sim.api.<operation>(input)`, where input is { params?, query?, body?, headers? } exactly as describe_operation’s signature declares, and `return` a JSON-serializable value: only that value comes back. TypeScript is accepted; types are stripped, not checked. A failed call throws SimApiError with status, code, message, and details.'
44
+
'The body of an async function. Call operations with `await sim.api.<operation>(input)`, where input is { params?, query?, body?, headers? } exactly as describe_operation’s signature declares, and `return` a JSON-serializable value: only that value comes back. TypeScript is accepted; types are stripped, not checked. A failed call throws SimApiError with status, code, message, details, and requestId. One call’s input may be at most 256 KB as JSON; send a larger body with call_write_operation.'
Copy file name to clipboardExpand all lines: apps/sim/lib/api/mcp/server.ts
+8-19Lines changed: 8 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,7 @@ const INSTRUCTIONS = `Sim is the AI workspace where teams build, deploy, and man
34
34
2. Read its input schemas with describe_operation.
35
35
3. Run it with the tool search_operations names: call_read_operation for operations that only read, call_write_operation for everything else.
36
36
37
-
Most operations take a workspaceId; listWorkspaces returns the workspaces you can use. Put path parameters in params, query-string values in query, and the JSON request body in body. Responses use the Sim API envelope ({ "data": ... }); list operations page with limit and cursor. Streaming options are not supported over MCP.`
38
-
39
-
constCODE_MODE_INSTRUCTIONS=`
37
+
Most operations take a workspaceId; listWorkspaces returns the workspaces you can use. Put path parameters in params, query-string values in query, and the JSON request body in body. Responses use the Sim API envelope ({ "data": ... }); list operations page with limit and cursor. Streaming options are not supported over MCP.
40
38
41
39
For a task that takes more than one or two calls (paging, filtering, joining, or changing many items), write one program instead: describe_operation returns each operation's TypeScript signature, and ${CODE_TOOL_NAMES.read} or ${CODE_TOOL_NAMES.write} runs an async function body that calls await sim.api.<operation>(input) and returns only what you need. Intermediate results stay out of your context. ${CODE_TOOL_NAMES.read} refuses every operation that needs write access.`
CHANGELOG: z.boolean().optional(),// Fallback for the `changelog` feature flag off AppConfig
627
627
SIM_LINKS: z.boolean().optional(),// Fallback for the `sim-links` feature flag off AppConfig
628
628
PEOPLE: z.boolean().optional(),// Fallback for the `people` feature flag off AppConfig
629
-
MCP_CODE_MODE: z.boolean().optional(),// Fallback for the `mcp-code-mode` feature flag off AppConfig
630
629
ORGANIZATION_ACTIVITY_ROLLUP_READS: z.boolean().optional(),// Fallback for the `organization-activity-rollup-reads` feature flag off AppConfig
631
630
ACTIVITY_ROLLUP_MAINTENANCE: z.boolean().optional(),// Fallback for the `activity-rollup-maintenance` feature flag off AppConfig
632
631
ACTIVITY_ROLLUP_BACKFILL_ROWS_PER_SECOND: z.coerce.number().int().positive().optional(),// Source rows the activity rollup backfill reads per second (default 20000)
0 commit comments