MCP execute_code vs Tool Calling: Why Code-Execution MCP Uses ~90% Fewer Tokens
In live financial markets, extra LLM round-trips do not just waste API tokens: they introduce price slippage between reading a ticker and placing a stop-loss. Here is the architectural breakdown behind Eterna's Deno sandbox model.
Traditional crypto MCP servers register 30 to 80 individual tool schemas, forcing 6 to 10 sequential LLM turns and dumping huge JSON market payloads into context for one trade. Eterna's execute_code architecture exposes only 3 MCP tools (search_sdk, search_examples, execute_code) and runs typed TypeScript inside a Deno sandbox, cutting token usage by roughly 90% and executing multi-step trade logic atomically.
https://mcp.eterna.exchange/mcpAnatomy of a single risk-sized trade: 8 tool calls vs 1 execute_code call
Compare what happens on the wire when a user asks: 'If BTC 1h RSI is under 35 and I have no open position, open a 5x long risking 1% of equity with a 2% stop.'
| Step | Per-Endpoint MCP Server | Eterna execute_code MCP |
|---|---|---|
| 0. Tool schema preload | 30 to 80 tool JSON schemas injected every turn | 3 tool schemas (search_sdk, search_examples, execute_code) |
| 1. Check balance | Turn 1: get_balance -> full wallet JSON into context | Inside same TypeScript script (Promise.all) |
| 2. Check open positions | Turn 2: get_positions -> full array into context | Inside same TypeScript script |
| 3. Fetch ticker & RSI | Turns 3-4: get_ticker + get_klines (100+ candles into context) | Inside same script (eterna.getTickers + eterna.getRsi) |
| 4. Fetch lot-size rules | Turn 5: get_instruments -> huge JSON spec into context | Inside same script (eterna.getInstruments) |
| 5. Compute qty & stop | LLM does mental arithmetic (prone to step-size bugs) | Exact Math.floor(rawQty / step) * step in Deno |
| 6. Set leverage & place order | Turns 6-7: set_leverage + place_order (stale price risk) | Executed milliseconds after ticker read in same worker |
| Total LLM round-trips | 7 to 8 sequential turns (15-40 seconds) | 1 execute_code call (<2 seconds total execution) |
Progressive disclosure with search_sdk and search_examples
A common question about code-execution MCP is: how does the LLM know the exact SDK methods if they are not listed as 30 separate MCP tools? Eterna solves this with progressive disclosure through search_sdk (supporting list, summary, full, params, and keywords detail levels) and semantic search_examples.
The model fetches only the exact signatures it needs for the current task, keeping base system context lean while guaranteeing zero invented parameters.
Frequently asked questions
Is executing LLM-generated TypeScript inside execute_code secure?
How much does execute_code save in LLM token costs?
References & verification links
- Anthropic Engineering: Code Execution with MCPIndustry architecture reference validating progressive discovery and sandboxed code execution over massive MCP tool sets.
- Eterna MCP Server CardDeclares Eterna's 3-tool surface: execute_code, search_sdk, search_examples.
Connect your AI agent in 30 seconds
One remote MCP URL. 800+ USDT perpetuals, 380+ spot pairs, 0.014% maker / 0.035% taker, no KYC.