Library

Volume 2 · MCP (Model Context Protocol) & Skills

Notebook
Sign in

Section 47

Enterprise MCP Deployment & Security

803 words · about 4 min

47.1 Authentication & Authorization

MCP Host → MCP Client ──OAuth 2.0──▶ MCP Server
                                       │
                                  Check user permissions
                                  per tool/resource

Per-user identity should flow through to the server (not just a shared service credential), so tool/resource-level authorization can be enforced per caller, not just per deployed server.

47.2 Sandboxing

  • Run MCP servers in isolated containers.
  • Apply network policies that restrict what each server can reach.
  • Limit file-system access to explicitly allowed paths.
  • Enforce resource limits — CPU, memory, execution timeout — per server.

47.3 Audit Trail

Log every tool invocation with user, tool name, arguments, result, and timestamp. Alert on suspicious patterns (unusual query volume, apparent privilege-escalation attempts — e.g., chaining several low-risk tools to reach a high-risk outcome). Set retention aligned with compliance requirements.

47.4 Data Classification-Aware Access

@server.tool()
async def access_data(resource_id: str, user_context: "UserContext"):
    """Access data with classification-aware controls."""
    resource = await get_resource(resource_id)

    if resource.classification == "CONFIDENTIAL":
        if not user_context.has_clearance("confidential"):
            raise AuthorizationError("Insufficient clearance")
        audit_log.record(user_context, resource, "access")

    return resource.content

47.5 Rate Limiting

Per-server and per-tool rate limits prevent both accidental runaway agent loops and deliberate abuse; a common pattern is a token-bucket limiter keyed by (user, tool_name) enforced at the gateway before the request reaches the server.

47.6 Enterprise Deployment Architecture

┌──────────────────────────────────────────────┐
│           Enterprise AI Platform              │
│                                                │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐   │
│  │AI App 1  │  │AI App 2  │  │AI App 3  │   │
│  │(Chat)    │  │(Agent)   │  │(Analysis)│   │
│  └──┬───────┘  └──┬───────┘  └──┬───────┘   │
│     │MCP          │MCP          │MCP         │
│     └─────────────┼─────────────┘            │
│                   │                           │
│  ┌────────────────▼───────────────────────┐  │
│  │        MCP Gateway / Registry           │  │
│  │  - Server discovery                     │  │
│  │  - Authentication proxy                 │  │
│  │  - Rate limiting                        │  │
│  │  - Audit logging                        │  │
│  └──────┬─────────┬────────────┬──────────┘  │
│         │         │            │              │
│    ┌────▼───┐ ┌──▼─────┐ ┌──▼──────┐       │
│    │MCP:    │ │MCP:    │ │MCP:     │       │
│    │Database│ │CRM     │ │Docs     │       │
│    │Server  │ │Server  │ │Server   │       │
│    └────────┘ └────────┘ └─────────┘       │
└──────────────────────────────────────────────┘

47.7 Security Risks and Mitigations

Risk Description Mitigation
Tool misuse AI calls a destructive tool inappropriately Human approval for write operations, action allowlisting, dry-run mode
Data exfiltration AI reads sensitive data via resources and leaks it in a response Data classification, output filtering, user-scoped resource access
Prompt injection via resources Malicious content embedded in a resource manipulates the AI Content sanitization, explicit instruction hierarchy in the system prompt
Server impersonation A rogue MCP server offers malicious tools Server authentication, signed server manifests, allow-listed servers only
Privilege escalation AI chains multiple low-risk tools to reach a high-risk outcome Session-level risk scoring, multi-tool action review before execution

Section 47 — Interview Q&A

Q1: How would you design an MCP-based integration layer for an enterprise with 20+ backend systems? A central MCP Gateway handling authentication, routing, rate limiting, and audit logging; one dedicated MCP server per backend system (CRM, ERP, ticketing, etc.), each with its own least-privilege service credentials; a server registry catalog listing available servers and their capabilities; and a security layer providing an OAuth2 proxy plus tool-level RBAC (not every user gets every tool on every server). Roll out in phases — build servers for the highest-value systems first, add the rest incrementally, and eventually offer a self-service MCP server SDK so system-owning teams can build and maintain their own servers rather than a central team owning all 20+.

Q2: Explain the security risks of MCP and how you’d mitigate each one. Tool misuse (destructive calls) — mitigate with human approval on writes, an action allowlist, and dry-run support. Data exfiltration via resources — mitigate with data classification enforced server-side and output filtering before results reach the model or the user. Prompt injection through resource content — mitigate with content sanitization and a clear instruction hierarchy so injected text in a resource can’t override the system prompt. Server impersonation — mitigate with server authentication and signed manifests, connecting only to an explicit allowlist of servers. Privilege escalation via tool-chaining — mitigate with session-level risk scoring that looks at the cumulative effect of a sequence of calls, not just each call in isolation, and requires review when the cumulative risk crosses a threshold.

Q3: What does “least privilege” mean concretely for an MCP server’s own backend credentials? The server’s own service account/API key should carry only the permissions its declared tools actually need — e.g., a “search contacts” tool needs read-only CRM access, not write access, even if the underlying CRM API key technically could write. Per-user identity should also flow through the server (via OAuth token pass-through or a similar mechanism) so authorization decisions can be made per calling user, not just once at the server level — otherwise every user of the server effectively inherits the server’s full backend permission set.