u/Revolutionary_Sir140

▲ 7 r/mcp

I got tired of watching LLMs make 30 sequential MCP tool calls, so I built Code Mode for Go

Quick context for anyone who missed it: Cloudflare made the case a while back that "function calling" is the wrong abstraction for tool-heavy LLM workloads. When a model needs to chain tools, you get this absurd round-trip dance: call one tool, read the result back into context, call another, read it back, repeat. Every hop burns tokens and pollutes the context window. Their pitch was simple: stop calling tools one at a time. Let the model write a small program, and expose the tools as functions inside that program.

Made too much sense to ignore. So I built it for Go + MCP.

Repo: https://github.com/Protocol-Lattice/codemode

It sits on top of mark3labs/mcp-go (the de facto Go MCP SDK) and uses Yaegi as a sandboxed Go interpreter to actually execute the generated snippets. The snippet runs inside an injected codemode helper that exposes the MCP toolset.

There's also a higher-level orchestrator (CodeModeMCP) that runs the full pipeline:

  1. Ask the LLM if a tool is even needed (skip everything if not)
  2. Ask it to pick the relevant tools from whatever's available
  3. Ask it to write a Go snippet that solves the task
  4. Run the snippet in Yaegi, return the value plus captured stdout/stderr
u/Revolutionary_Sir140 — 6 days ago