Design a tool gateway that lets internal agents use about 200 MCP servers (CRM, ticketing, code search, data warehouse) on behalf of 5,000 employees. Cover authentication and permissions, scaling, prompt-injection containment and the context cost of so many tools.
Answer
Model answer, written in a candidate's voice
In short
- Per-user delegated OAuth credentials, per-team allow-lists, full audit logs — never a shared super-user account
- Tool outputs treated as untrusted input; confirmation or policy checks for writes; data egress limits
- Stateless 2026-07-28 MCP design: explicit state handles, horizontal scaling behind load balancers, per-tenant rate limits, OpenTelemetry trace propagation
- Progressive disclosure / tool search / code-execution-style APIs instead of loading all 200 tool definitions; deterministic tool ordering for prompt-cache hits
- Evaluation: tool-selection accuracy, task success, latency and cost per task, and graceful failure handling when a server is down
In full
The core principle is that the gateway is a thin, stateless enforcement layer, not a privileged proxy: every call carries the end user’s delegated OAuth-style credentials, so the CRM or warehouse sees the employee rather than a shared service account, and per-team allow-lists plus immutable audit logs govern what each agent may touch. Because tool outputs are untrusted input, the gateway treats them as data, not instructions — write actions require policy checks or explicit user confirmation, and egress is capped so a compromised or confused server cannot exfiltrate data. Scaling is straightforward under the stateless 2026-07-28 MCP design: servers run statelessly behind load balancers with explicit state handles passed per request, per-tenant rate limits protect shared backends, and OpenTelemetry trace context propagates end to end so a task can be traced from agent to server. To keep 200 servers out of every prompt, I would use tool search or progressive disclosure — or code-execution-style APIs — so only relevant tool definitions load, with deterministic tool ordering so prompt-cache hits stay high. Evaluation would track tool-selection accuracy, end-to-end task success, latency and cost per task, and graceful degradation — circuit-breaking and falling back when a server is down — rather than assuming all 200 servers are always healthy.
What a strong answer covers
- Acts with each user’s own permissions via OAuth-style delegated credentials, not a shared super-user account; allow-lists per team and full audit logs.
- Treats tool outputs as untrusted input; requires confirmation or policy checks for write actions and limits data egress.
- Uses the stateless 2026-07-28 MCP design (no sessions, explicit state handles) to scale servers horizontally behind load balancers, with per-tenant rate limits and OpenTelemetry trace propagation.
- Avoids loading every tool definition into every prompt: tool search or progressive disclosure, or code-execution style APIs, plus deterministic tool ordering for prompt-cache hits.
- Defines evaluation: tool-selection accuracy, task success, latency and cost per task, and failure handling when a server is down.
Common mistakes
- Putting all 200 servers’ tool schemas in the system prompt.
- Enforcing permissions only in the prompt.
Follow-ups
- How would you handle a long-running tool call that takes ten minutes?
- What changes if some MCP servers are third-party and not trusted?