Code Mode MCP: three tools for thousands of business actions
How Code Mode keeps MCP context small while letting agents discover, read, and execute actions across broad integration workspaces.
By Weavz Team

The Model Context Protocol gives agents a common way to discover and call external capabilities. That standardization matters. It means a product can expose business actions to many AI clients without rebuilding the integration layer for each one.
But broad MCP servers create a practical problem: a useful workspace can have hundreds or thousands of actions. If every action appears as a separate tool with a full schema, the agent pays for all that context before it knows which action it needs.
Code Mode takes a different route. It exposes three MCP tools:
weavz_searchto discover apps, aliases, and actions.weavz_read_apito load the specific action details the agent needs.weavz_executeto run code that calls the selected actions.
The agent still gets broad reach. The initial tool surface stays small.
Why three tools work
Most business workflows follow a search, inspect, act pattern. A human developer does this constantly: search docs, read the relevant API shape, then write the call. Code Mode gives the agent the same workflow inside MCP.
Instead of loading every Slack, Gmail, HubSpot, Google Sheets, Linear, and storage action upfront, the agent can ask for the small subset that matches the task. Then it can write one short program that calls those actions in sequence.
That sequence matters. A weekly account summary might pull CRM records, fetch recent support conversations, write a CSV, store a durable copy, and send a Slack message. In Tool Mode, that can become a long chain of separate tool calls. In Code Mode, the agent can compose the work inside one execution.
The public MCP specification defines the protocol surface. Weavz Code Mode focuses on the product problem that sits above it: keeping agent context compact while still giving teams access to a large, governed action space.
A better shape for broad workspaces
Tool Mode is still useful when a server should expose a small, fixed set of actions. A narrowly scoped support bot might only need two or three tools.
Code Mode is better when the workspace is broad:
- Many integrations are available.
- A task may cross several systems.
- The agent needs to transform data between steps.
- The workflow benefits from files, state, or validation before final action.
The MCP Code Mode guide shows the full setup flow. The MCP servers concept page explains how servers, aliases, end-user access, and workspace integrations fit together.
Execution still needs product controls
Small context does not remove the need for control. Agents should run against the right workspace, use the right connected account, and receive clear validation errors when inputs are wrong. Teams also need a way to gate sensitive actions through Human Gates.
That is why Code Mode is tied to the same execution layer as the Actions API, sandboxes, and built-in state. The agent can discover and call thousands of business actions, but the product can still decide which actions are enabled, which defaults are enforced, and which requests require review.
Code Mode is not just a prompt trick
It is tempting to frame context efficiency as a prompting problem. Better instructions help, but they do not solve the structural issue of too many tools.
Code Mode changes the interface. It moves from "load every tool first" to "discover what is needed, read the exact shape, then execute." That is a smaller starting context, a clearer agent workflow, and a better fit for products that want to expose real business systems through MCP without turning the model's context window into an integration catalog.
Share this article
Send it to a teammate or save the link for later.