Give the gateway an async JavaScript function body. It runs the workflow and returns the result and a call summary.
Enable the tool
tools:
- "demo__version"
enable_code_mode: true
credentials: {}The Quickstart enables Code Mode on demo. For another profile, set enable_code_mode: true, save, then refresh the client’s MCP catalog.
Run a workflow
Set the code argument on code_mode__execute. This example uses the quickstart.
const response = await tools.call("demo__version", {});
return { ok: !response.isError, output: response.content };Discover and call tools
| API | Returns |
|---|---|
tools.list() | Names and descriptions. |
tools.search(query) | Matching tools and schemas. |
await tools.call(name, args) | An MCP tool result. |
Use Promise.all to run independent reads concurrently. Check isError and use the backend’s actual response shape.
Sandbox and limits
| Resource | Limit |
|---|---|
| Input and final result | 64 KiB each |
| VM memory / stack | 16 MiB / 512 KiB |
| JS execution turn / workflow | 1 s / 30 s |
| Tool calls / concurrent calls | 50 / 4 |
| Tool response | 4 MiB |
The QuickJS runtime has no direct filesystem, network, process, module loader, or timers. Code Mode cannot invoke itself.
Simulate operations before execution
To configure preflight, run a trusted local simulator and a separate reviewer, then select the profiles that should use them. Preflight prepares each HTTP request, MCP call, or CLI command and obtains a fixture from the simulator. The reviewer receives the snippet and trace. In enforcement mode, the gateway checks each live operation against the approved trace before sending or running it.
SPLICEDOCK_CODE_MODE_PREFLIGHT=observe
SPLICEDOCK_CODE_MODE_PREFLIGHT_PROFILES=demo
SPLICEDOCK_CODE_MODE_MOCK_URL=http://127.0.0.1:18953/mock
SPLICEDOCK_CODE_MODE_REVIEW_URL=http://127.0.0.1:18953/reviewObserve mode stops at review. Use enforce mode with a trusted review service that independently enforces operation permissions. A model score alone cannot authorize an operation. Use a profile token. HTTP, fixed CLI, CLI passthrough, and already connected Streamable HTTP MCP are supported. CLI passthrough applies its ordinary live policy and approvals. SSE is unsupported. Traffic produced inside a CLI process or remote MCP backend is outside this check.
Errors, approvals, and retries
Check each tool result and await all started operations. A later failure, timeout, or a changed preflight trace cannot roll back a call that has already started. A separate retry for an approved operation must obey the original policy.