CodeMode is an experimental transform that replaces a large tool surface with two meta-tools:
search: inspect tool metadata by writing Python codeexecute: run tool calls from Python code viacall_tool(...)
Install Monty (Optional)
CodeMode defaults to MontySandboxProvider, which requires the optional Monty dependency.
Basic Transform Usage
CodeMode is a transform-first API. Attach it with mcp.add_transform(...).
Backend tools are hidden from listings, while execute can still call them.
OpenAPI + Code Mode
You can placeCodeMode on top of an OpenAPI-backed provider so clients only see search and execute while the backing tools come from your API spec.
Default Prompt Behavior
searchreceivestools: list[dict]with metadata fields includingname,key,parameters, andoutput_schema. Usekeywhen tools have versions — it uniquely identifies a specific tool version.executeexposes a single callable:call_tool(tool_name_or_key, params). Prefer passingkeyfor versioned tools.executeis intended for chaining multipleawait call_tool(...)steps in one block and returning the final value.
Custom Tool Names and Descriptions
Custom Sandbox Providers
Third-party sandbox providers (including remote providers) can integrate by implementing theSandboxProvider protocol.
CodeMode treats the sandbox provider as a pluggable execution backend, so provider-specific security and isolation can evolve independently.
