Architecture note · Agent security

MCP security architecture

Model Context Protocol can provide a clean tool contract, but the protocol is not the authorization boundary. Secure agent access requires scoped identity, deterministic policy, constrained outputs and an audit record outside the model.

By Salah AwadUpdated 30 August 20267-minute read

The trust boundary

The model may propose a tool call. Deterministic application code must authenticate the caller, authorize the exact operation and target, validate arguments, control execution and record the resulting side effect.

An MCP server should expose curated domain capabilities such as get_incident_context or restart_approved_service, not generic primitives such as unrestricted HTTP requests, shell execution or arbitrary SQL.

Required security layers

Identity propagation

Carry an attributable workload or delegated user identity through every tool invocation.

Least-privilege scopes

Issue capability-specific authorization rather than inheriting the caller’s complete application access.

Schema validation

Reject unknown fields, invalid identifiers, unsafe ranges and oversized inputs before business logic runs.

Policy decision point

Evaluate subject, action, resource and environment independently of model-generated reasoning.

Result controls

Cap response size, classify fields and redact secrets before tool output enters model context.

Immutable audit

Record the normalized call, policy decision, executor identity and material outcome.

A defensible invocation flow

  1. The agent selects a named tool from an allowlisted manifest.
  2. The gateway binds the request to an authenticated user or workload identity.
  3. Strict schema validation normalizes and rejects malformed arguments.
  4. A policy service authorizes the exact action against the exact target.
  5. A deterministic executor performs the operation with narrowly scoped credentials.
  6. The response is bounded, classified and redacted before returning to the model.
  7. The complete decision and outcome are written to the audit trail.

Separation of duties

The model should not hold the credential that executes its proposal, and the executor should not infer authorization from natural-language reasoning.

Threats and corresponding controls

ThreatControlVerification
Prompt-injected privileged actionIndependent policy decision and operation allowlistAdversarial retrieval tests cannot expand scope
SSRF through a generic fetch toolDomain-specific connectors and destination allowlistsPrivate, link-local and unapproved destinations fail closed
Cross-tenant accessTenant-bound identity and datastore enforcementNegative authorization tests at tool and storage layers
Secret leakage in tool resultsField classification, redaction and result capsCanary secrets never enter model context
Replay of a destructive requestShort-lived authorization, nonce and idempotency keyRepeated requests do not duplicate side effects

Architecture review checklist

  • Can every tool be mapped to one business capability and one accountable owner?
  • Are write operations distinguishable from reads in both policy and telemetry?
  • Can a retrieved document alter authorization or only influence the proposal?
  • Are service credentials inaccessible to the model runtime?
  • Can investigators reconstruct the exact arguments and side effects months later?
  • Does the system fail closed when identity, policy or audit dependencies are unavailable?

Authorship and evidence scope

This is a first-party architecture note based on Salah Awad’s stated practice designing MCP tool surfaces and defense-in-depth systems. It is not a claim that MCP alone provides these controls, nor independent certification of a specific confidential implementation.