π The fast, Pythonic way to build MCP servers and clients.
Code Mode
CodeMode collapses an entire tool catalog into three meta-tools: search (keyword-based discovery), get_schema (parameter details), and execute (run Python scripts that chain tool calls in a sandbox). Instead of burning context tokens on every intermediate result, the LLM writes a script that runs server-side and returns only the final answer.
Run
uv run python server.py # in one terminal
uv run python client.py # in another
Example Output
ββββββββββββββββββ CodeMode Transform ββββββββββββββββββ
βββββββββββββββ list_tools() βββββββββββββββ
β Tool Description β
β search Search for available tools β
β get_schema Get parameter schemas β
β execute Chain `await call_tool(...)` β
βββ 8 backend tools collapsed into 3 βββββββ
βββββ search(query="math arithmetic") ββββββ
β # Tool Description β
β 1 add Add two numbers together. β
β 2 multiply Multiply two numbers. β
β 3 fibonacci Generate the first n ... β
βββ 3 results ββββββββββββββββββββββββββββββ
βββββββββββββββ execute ββββββββββββββββββββ
β a = await call_tool("add", {"a": 3 ... β
β b = await call_tool("multiply", ... β
β return b β
βββ result: 14.0 βββββββββββββββββββββββββββ
The key insight: with standard MCP, each call_tool is a round-trip through the LLM. With CodeMode, the LLM writes one script and all the tool calls happen server-side. Intermediate data never touches the context window.