by otikik · 1mo ago · 0 comments
1. Search: The server publishes its tools via a query interface and with gradual level of detail. This way an LLM can discover the tools it needs without loading the ones it doesn't into context. Saves context.
2. The LLM sends glue code when it needs to use multiple tools together. Said code gets executed by the MCP server itself, and it returns the result. Saves tool calls, which saves tokens.
On point 2: Imagine there's 2 tools in the server. One lists customers the other gives sales for a given customer. For a task like "add all the sales for the customers whose name begin with A".
With traditional MCP: the LLM has to use the MCP like a regular HTTP API: first get the customers (1 tool call). Then for every customer begining with A, get their sales (N tool cals). Then add all of the sales (potentially 1 tool call).
With code mode the LLM sends a single program. The program has code that does things like `customers = call_tool("get_customers"); for each c in customers do if customer.name.begins_with("A") then ...` etc etc. That code is sent to the server for execution. So for the LLM it counts as a single tool call.
On the downside, the "code execution" on the Server means that it is executing untrusted code coming directly from LLMs. In order to offer this confidently your MCP servers really needs a very tight sandbox in which to execute this "glue code".
Yes part: LLMs have had the capability to generate code, including glue code, to do several steps in a single program.
No part: until some months ago, MCP servers were not prepared to use that glue code at all.
Your LLM could generate the code it wanted, and you could execute that code wherever you wanted, including letting the LLM run it. but every call to any of the tools exposed by the LLM is meant to be consumed by your LLM in the old paradigm. If said program makes 80 tool calls, your LLm would still have to send them, and parse their responses, consuming tokens.
In code mode the glue code is sent to the server, which executes it, and returns the final result. It’s a single invocation and a single response, instead of 80 like before