Harden an MCP client for the enterprise
For engineers
Take a working MCP client from pilot to company rollout: map the architecture, threat-model it, vet servers, harden the client, apply OWASP controls and delegate safely to a partner's agent.
An MCP client is safe for a company only when every connection it makes is mapped, vetted, pinned, limited and logged. A client that merely works is a pilot.
The case
Northwind Logistics built an ops assistant for 400 staff. It uses the Model Context Protocol (MCP), an open protocol that lets an AI application talk to tools and data through servers. The assistant connects to three servers: the company tracker, a PDF toolkit and a calendar. A pilot with ten users went well. Now security wants a hardening pass before rollout. The same pass applies to Claude, ChatGPT, Gemini or an open-weight model, because the risks sit in the client and the servers, not in one vendor.
Why it matters
A server's tool descriptions are read by the model. A server's output flows back into the model's context. Both can contain text that tries to steer the model, and a model that holds a sensitive tool may follow it. The client is the last place where a person or a rule can say no.
Step 1: Draw the architecture
Name the parts. The host is the application the user sees. It starts one client per server connection. The host owns user consent. Servers expose three kinds of capability: tools (the model decides to call them), resources (the application attaches them as context) and prompts (the user picks them). Choose the transport per server: stdio for a single-user local process, Streamable HTTP for a shared remote service.
Step 2: Threat-model the flows
List the assets: ticket data, contracts, the tracker token. Draw the data flows and mark every trust boundary. The one people forget is server output entering the model context. Then write abuse cases. A hidden instruction in a PDF that tells the assistant to export all tickets is one. It needs three things in one session: untrusted content, a sensitive tool and a way out. Remove one of the three and the attack fails.
Step 3: Vet and pin servers
Prefer a verified publisher, recent releases, narrow access and a local runtime for sensitive files. Read the install script and the tool descriptions. Replace floating versions with exact ones:
{
"tracker": { "command": "npx", "args": ["@northwind/tracker-mcp@1.8.2"] },
"pdf": { "command": "uvx", "args": ["docforge-mcp==2.4.1"] }
}
Keep an allowlist with a named owner for each server. When a version changes, diff the tool definitions and approve again.
Step 4: Harden the client
Prefix tool names with the server name so two search tools do not clash. Send the model only the tools a task needs and defer the rest to tool search. Gate every write tool behind approval in the host. Do not trust list_changed updates automatically. Set budgets for calls and tokens per session. A hosted connector in a provider API is simpler, but it runs from the provider's side, so an internal server needs your own client.
Step 5: Map to OWASP
Use the OWASP Top 10 for LLM Applications as a checklist against your flows. Excessive Agency points to scoped tokens and approvals. Supply Chain points to the allowlist and pinning. Prompt Injection points to treating tool output as data and separating sessions. Unbounded Consumption points to budgets. Improper Output Handling points to escaping server text before it reaches a page.
Step 6: Delegate safely to a partner's agent
Northwind's supplier runs its own agent. The Agent2Agent protocol (A2A) lets agents work as peers: read the agent card, send a task, follow its states, and answer input-required in the same task. MCP connects an agent to tools. A2A connects agents that keep their own reasoning private. Whatever the supplier's agent returns is outside text, so review it before it reaches a write tool.
Before and after
Before: floating latest tags, all tools loaded, writes run without a prompt, the PDF text reaches the model next to the export tool, and nothing limits a retry loop.
After: pinned servers, per-task tool sets, approval on writes, untrusted-content sessions that cannot export, budgets with an alert, and review of partner output.
What goes wrong
- A server updates its tool descriptions after approval, and the client uses them at once.
- A popular server with broad access is picked because it has many downloads.
- The team treats an OWASP list as proof of security instead of a map to controls.
- Approval is left to the server, so a hostile one never asks.
Steps
Draw the architecture
Label the host, one client per connection and the three servers. Put consent in the host, pick stdio for the laptop PDF server and Streamable HTTP for the shared tracker, and check each capability is the right primitive. Static style text becomes a resource, not a tool.
Northwind connections Server Run by Transport Shared or per user Tracker Northwind Streamable HTTP Shared PDF toolkit Third party stdio Per user Calendar Northwind Streamable HTTP Shared Threat-model the data flows
List assets and mark trust boundaries. The unmarked one is PDF output entering the model context. Write the abuse case as untrusted content plus a sensitive tool plus an outbound path in one session, then pick the control that breaks the chain.
Vet servers and pin versions
Compare publisher, last release, transport and access requested. Read install scripts and tool descriptions. Replace latest and unpinned entries with exact versions, name an owner for each server and diff tool definitions on every bump.
Harden the client loop
Namespace tools by server, load only the tools each task needs, put an approval check before every write call, and ignore list_changed definitions until they are reviewed. Run your own client for internal servers.
Approval gate before callTool if (!tool.annotations?.readOnlyHint) { const ok = await host.askUser(`Run ${call.name}?`, call.input); if (!ok) return denied(call.id);}const result = await client.callTool({ name, arguments: call.input });Map risks to controls
Walk the OWASP Top 10 for LLM Applications against each flow. Scope tokens, allowlist and pin, treat tool output as data, escape it before display and cap calls and tokens per session. Record each risk with its control and a test.
Delegate to the supplier's agent
Read the supplier's agent card, send the task, answer input-required inside the same task and treat the returned text as outside input. Review it before it reaches the tracker's write tool, and log the task id.
Skills this scenario uses
Where to study
- MCP architecture overview (opens in a new tab)DocsFree
Hosts, clients, servers and the primitives each exposes.
- MCP specification (opens in a new tab)StandardFree
The protocol text: transports, tools, and client features.
- MCP security best practices (opens in a new tab)DocsFree
Attacks on MCP deployments and the controls against them.
- MCP authorization specification (opens in a new tab)DocsFree
How remote servers and clients authenticate.
- About the MCP Registry (opens in a new tab)DocsFree
What the official registry lists and verifies about servers.
- A2A protocol documentation (opens in a new tab)DocsFree
Agent cards, tasks and how A2A relates to MCP.
- OWASP Top 10 for LLM Applications (opens in a new tab)DocsFree
The risk list used to review the client.
- OWASP Threat Modeling Cheat Sheet (opens in a new tab)ArticleFree
A step-by-step method for flows, boundaries and abuse cases.