codeMode
codeMode(
options?):McpCodeModeProvider
Defined in: mcp-code/src/lib/code-mode.ts:83
MCP code mode: instead of one tool per service method, the agent gets a typed TypeScript API
of the exposed services plus two tools — search_api (load declarations piece by piece) and
execute (run a script against the API in a sandbox) — and the mantle://code/api.d.ts
resource. Pass the result as mcp({ codeMode: codeMode() }).
Every mantle.<path>.<method>() call inside a script dispatches through the exact runner
tool mode uses (createServiceMethodRunner from @mantlejs/mcp) with the session’s params,
provider: "mcp", and params.mcp set (see CodeModeCallMetadata) — so the service’s full
hook pipeline, including authorizeAgent() and @mantlejs/audit, applies to each call. The
expose map is the hard boundary: only exposed methods exist in the sandbox.
Parameters
Section titled “Parameters”options?
Section titled “options?”CodeModeOptions = {}
Returns
Section titled “Returns”McpCodeModeProvider