Repository navigation
feat(mcp): add code mode to the Sim MCP server - #10204
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Critical impact] The PR appears safe to merge. SummaryAdds optional MCP code tools that run JavaScript or TypeScript against Sim’s API in an isolated sandbox.
|
There was a problem hiding this comment.
1 issue found across 20 files
Confidence score: 3/5
- In
apps/sim/lib/api/contracts/typescript.ts,allOfcan renderA & (B | C)asA & B | C, dropping shared fields from later variants. Parenthesize members with a top-level|.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/api/contracts/typescript.ts">
<violation number="1" location="apps/sim/lib/api/contracts/typescript.ts:55">
P2: The `allOf` join does not parenthesize union members, so `A & (B | C)` renders as `A & B | C`, which drops the shared fields from every variant after the first. Wrap members whose rendered type contains a top-level `|` in parentheses before joining with `&`.</violation>
</file>
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
… and type union bodies
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 22 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 23 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
execute_read_codeandexecute_write_coderun a JS/TS program that calls the v2 API throughsim.api.<operation>(input)and return only its value, plus a per-call trace (operation,status,durationMs) and captured logssearch+execute, Stainless, FastMCP); the call tools stay for single calls and clients that don't run codemodeargument, mirroring the read/write call tools: client approvals andreadOnlyHintare per tool, so amodearg would let an auto-approved read tool run writes. The read tool refuses write operations on the host, from the catalog's tool kindsim-api-codesandbox task in the existing isolated-vm pool: no bundles, nofetch(task mode never installs it), onesimApibroker. Every call goes throughdispatchMcpRequestwith the request's own credential, so auth, scopes, workspace permissions, refusals, rate limits and per-call logs are unchanged; the credential never enters the isolatedescribe_operationnow returns a TypeScriptsignaturerendered from the contract on demand (all 323 operations). The JSON Schema → TS emitter moved from the CLI generator intolib/api/contracts/typescript.tsand both use it; the generated CLI file is byte-identicalSimApiErrorcarries the v2 envelope (status,code,message,details,requestId)dispatchMcpRequestnow separates a call rejected before dispatch from one that ran but answered unreadably (non-JSON or too large), so a write program's trace never reports an executed write as not runapi:write(reuses therawRoutegate, so read-only keys andapi:readtokens get the step-up/403 before any program runs)mcp-code-modefeature flag (user or workspace rollout, off by default); the flag is only evaluated forinitialize,tools/list, and code-tool callsloadTypeScriptloader now used by both code mode and function executionmcp/tools.mdxType of Change
Testing
lib/api/mcp/__integration__/code-mode.integration.ts(9 tests, real Postgres + real isolate pool through/api/mcp): flag gating (listing and calls), write-then-paged-read through real routes, read program refused a write with no row change, read-only key refused the write tool with 403, v2 404 as a catchableSimApiError, nofetch/process/requireand no credential anywhere in a deep walk of isolate globals, uncaught error returns prior calls, TS stripping + syntax error line, timeout / call cap / result caplib/api/mcp/{route-handler,dispatch,catalog}.test.ts,lib/function-execution/execute-request.test.ts,scripts/generate-v2-{cli-api,mcp-operations}.test.tsgenerate-v2-cli-api.ts --check(unchanged output), type-check, biome,check:api-validation:strict,check:utils,check:boundaries,check:test-patterns, and other targeted audits; fullcheck:auditsin CIChecklist
test-auditauthoring gate)