In review · not yet published
6 min readLaunchapp
Designing MCP servers agents can actually operate
Task-shaped tools, errors an agent can recover from, context budgets, scoped authority and safe writes, from running our own orchestrator over MCP.
The Model Context Protocol is the easy part of an MCP server. You can wrap an API in tool definitions in an afternoon, connect an agent, and watch it call the wrong tool with the wrong arguments, retry a write three times and fill its own context with a list it did not need.
We know this from the receiving end. Animus, our open-source orchestrator, exposes its whole control surface over MCP: tasks, workflows, queues and daemons. Agents use it every day to pick up work, run it and report back. We also built a worktree manager MCP server with 47 tools that lets agents create, run and clean up isolated git worktrees, so many agents can work on one codebase in parallel. What follows is how those servers are built, and why.
Shape tools around jobs, not endpoints
Mirroring every REST endpoint hands an agent hundreds of low-level calls and leaves it to work out the choreography. Agents are much better with fewer, task-shaped tools.
The Animus server names tools as animus.<group>.<verb>, and the verbs are things an agent wants to do. animus.subject.next returns the highest-priority ready item of a kind. animus.queue.enqueue asks for a piece of work to be dispatched. Neither maps to a single table operation, and neither needs the agent to understand the storage underneath.
The descriptions matter as much as the names. Every tool description in the server follows one template: purpose, prerequisites, an example call, and what to do next.
#[tool(
name = "animus.queue.hold",
description = "Hold one or more queued subject dispatches. Purpose: Prevent pending subjects from being selected for dispatch without removing them from the queue. Prerequisites: Subjects must be queued and pending. Example: {\"subject_id\": \"TASK-001\"} Sequencing: Use animus.queue.release to resume dispatch eligibility.",
input_schema = ao_schema_for_type::<QueueSubjectInput>()
)]
async fn ao_queue_hold(&self, params: Parameters<QueueSubjectInput>) -> Result<CallToolResult, McpError> {
self.queue_bulk_inproc("animus.queue.hold", crate::services::operations::QueueBulkVerb::Hold, params.0).await
}
The "Sequencing" line is the one people leave out. An agent reads a tool description at the moment it is deciding what to do. Telling it which tool comes next, in the same place, removes a whole class of wandering.
A tool description is a prompt. Write it for a reader who has never seen your system and will act on the first plausible interpretation.
Return errors an agent can act on
A human reads "Error: 500" and opens the logs. An agent reads it and tries again, or gives up, or invents a workaround. So every failure from the Animus server is structured, with a small fixed set of codes and, where we can, a remediation:
{
"tool": "animus.queue.enqueue",
"exit_code": 5,
"error": { "code": "unavailable", "message": "daemon is not running", "exit_code": 5 },
"remediation": { "kind": "daemon_not_running", "next_step": "animus daemon start" }
}
That is the shape of a real response, with example values. There are five codes: internal, invalid_input, not_found, conflict and unavailable. That is few enough for an agent to learn the difference between "fix your arguments", "this does not exist", "someone else changed it" and "wait". The remediation turns the most common failures into a next step, not a dead end.
Budget the context like memory
Every tool definition and every response takes room in the agent's context. A server with a hundred tools and unbounded list responses can spend most of a model's attention before any work starts. The Animus server has 95 tools by default, across sixteen groups, so this was not theoretical.
Three mechanisms keep it usable.
Bounded lists. List tools default to 25 items and cap at 200, and every response carries the same pagination block: how many were returned, the total, whether there is more, and where to resume.
A size guard. List responses also carry a token estimate against a budget, 3,000 by default. If a page would exceed it, the server degrades the response in steps: full items, then summary fields, then a digest. The agent always gets something that fits, and a flag that tells it the result was truncated.
Tool discovery. Two meta-tools let an agent search and list the tool surface, so a client does not need every schema loaded to find the right one.
Namespacing does quiet work here too. With dotted names, an agent looking for queue operations can see the whole group at once.
Decide whose authority the agent acts with
This is the decision that most often gets made by accident. An agent calling your server is acting for someone. The server has to know who, and has to enforce it, because the agent's own account of its identity is just text.
In the Animus portal, the team workspace built on Animus, the MCP endpoint is an OAuth 2.1 protected resource. The bearer token is verified, its audience must be the MCP endpoint, the user's membership is checked again on each request, and every tool checks its scope again before running. There are two scopes, read and write, and a third tier for administration: admin tools are not merely refused to other users, they are not registered, so those users' agents never see them.
The orchestrator itself has a stricter rule for agents it launches. The caller's identity is pinned by the transport when the server starts. It is never taken from agent output, workflow files or the content of a task. With an identity pinned, the tool surface shrinks to an allow-list of 32 tools.
One boundary is worth copying exactly. The tools that list and answer pending approvals are only available on a separate management surface, so an agent can never list or answer its own pending approvals. If an agent can approve its own request, you do not have an approval step.
On audit: each call the portal makes on a user's behalf is logged with that user's id, and each workflow run keeps a decision log that agents and people can read back. A general audit table for every MCP call is something we would add for a client with compliance needs; we have not needed it internally, and we would rather say so than imply it exists.
Make writes safe to repeat
Agents retry. A timeout, a context reset or a cautious model will send the same write twice. Write tools have to be built for that.
- Idempotency keys. Enqueueing work accepts a key. An exact retry returns the original receipt. The same key with different content fails closed, so a retry can never silently become a different request.
- Dry runs. Destructive tools take a
dry_runflag and return what would happen. The description for the environment cleanup tool tells the agent to run withdry_runfirst. - Confirmation that cannot be guessed. Cancelling a workflow requires a
confirmargument equal to the workflow's id. A model that hallucinatesconfirm: truegets an error that names the correct command and the dry-run option. - Bounded batches. Bulk create and update are capped at 100 items, with an explicit choice between stopping and continuing on error.
None of these is theoretical. Agents retry, and models do invent confirmations.
Keep instructions and data apart
Agents read untrusted content: a task body written by a customer, a web page, a file in a repository. Any of it can contain text that looks like an instruction. The defence is structural. Privileged tools stay behind explicit confirmation, identity comes from the transport and not from content, and nothing a tool returns is treated as a command to the server.
The same thinking applies in the other direction. When our agents call third-party MCP servers, they go through a local proxy that injects the credential. The token lives in the operating system's keychain, and the agent never holds it.
Test with real agents
Unit tests prove a tool does what its code says. They do not prove an agent can use it. The regression suite that matters is scripted tasks run by real agent clients against the server, with per-tool success rates tracked over time. When a rate drops, the fix is usually in a description or an error message, not in the logic.
That is the uncomfortable summary of this whole post. Most of the engineering in a good MCP server is writing, for a reader that takes you literally.
What we built
The work behind this post: Animus, the worktree manager MCP server, and the Animus portal. The cards below link to each.
Proof
The work behind this post
Built
Animus
Open-source orchestrator with a Rust core that runs teams of AI coding agents in parallel. Its whole control surface is exposed over MCP.
- commits on main since Feb 2026
- 1,700+
- commits on main since Feb 2026
Built
Worktree manager MCP server
An MCP server with 47 tools that lets AI agents create, run and clean up isolated git worktrees, so many agents can work on one codebase in parallel.
- agent-facing tools
- 47
- agent-facing tools
Built
Animus portal
A self-hosted business portal where a team and its AI agents work the same board. Each organization gets its own cloud container, so the agents are always on and not tied to anyone's laptop.
- container per organization
- 1
- container per organization
- commits on main since June 2026
- ~720
- commits on main since June 2026
Founder-led
Building something like this? A founder will reply personally.
Scope a project