Code mode or code execution with MCP is a concept that was more broadly shared late last year:
https://www.anthropic.com/engineering/code-execution-with-mcp
https://blog.cloudflare.com/code-mode/
I was wondering how this concept could be applied to WebMCP so I was tinkering with it over at GoogleChromeLabs/webmcp-tools#287
The idea is simple: instead of (or in addition to) exposing every single WebMCP tool to an agent, there's a single execute_tools tool that allows the agent to execute N tools in one go.
Let's take this Pizza Maker demo as an example. To create a pizza, you'd normally call tools such as set_pizza_size, set_pizza_style, and add_topping one after the other. That's a lot of roundtrips and a lot of tokens. The same task with execute_batch could be accomplished with a single tool call execute_tools([set_pizza_size, set_pizza_style, add_topping]).
Early testing shows greatly reduced number of roundtrips, token usage, and increased speed. Which is why I think this could be really interesting for both website developers as well as the agent developers. Such an execute_tools function could be implemented on either side.
Of course this works best for more deterministic scenarios that don't involve dynamic tool additions or page navigations. So it made me wonder how the WebMCP spec could help in this case. For example with a new ToolAnnotation to mark tools suitable for this kind of batching. (See also #176). Or a way to define meta tools such as make_pizza, which under the hood would be execute_tools([set_pizza_size, set_pizza_style, add_topping])
Code mode or code execution with MCP is a concept that was more broadly shared late last year:
https://www.anthropic.com/engineering/code-execution-with-mcp
https://blog.cloudflare.com/code-mode/
I was wondering how this concept could be applied to WebMCP so I was tinkering with it over at GoogleChromeLabs/webmcp-tools#287
The idea is simple: instead of (or in addition to) exposing every single WebMCP tool to an agent, there's a single
execute_toolstool that allows the agent to execute N tools in one go.Let's take this Pizza Maker demo as an example. To create a pizza, you'd normally call tools such as
set_pizza_size,set_pizza_style, andadd_toppingone after the other. That's a lot of roundtrips and a lot of tokens. The same task withexecute_batchcould be accomplished with a single tool callexecute_tools([set_pizza_size, set_pizza_style, add_topping]).Early testing shows greatly reduced number of roundtrips, token usage, and increased speed. Which is why I think this could be really interesting for both website developers as well as the agent developers. Such an
execute_toolsfunction could be implemented on either side.Of course this works best for more deterministic scenarios that don't involve dynamic tool additions or page navigations. So it made me wonder how the WebMCP spec could help in this case. For example with a new
ToolAnnotationto mark tools suitable for this kind of batching. (See also #176). Or a way to define meta tools such asmake_pizza, which under the hood would beexecute_tools([set_pizza_size, set_pizza_style, add_topping])