Protocol guide · Reviewed September 18, 2026

Model Context Protocol: Architecture & Security Guide

By AI Agent Hub Editorial Desk · Review method · Corrections

Scope: MCP standardizes context exchange between AI applications and external systems. It does not by itself make a tool safe, authorize a user, or decide how a model should use returned data.

The Model Context Protocol (MCP) is an open standard for connecting AI applications to data sources, tools, and reusable workflows. It reduces one-off integration work, but the protocol boundary should be understood before installing a server or exposing a production API.

The three participants

ParticipantResponsibilitySecurity question
HostThe AI application coordinating one or more connectionsWhich servers and actions may the user enable?
ClientA host component maintaining a dedicated connection to one serverHow are capabilities, messages, and approvals isolated?
ServerA local or remote program exposing context or actionsWhat identity, data, network, and operating-system authority does it hold?

A host can create multiple clients, each connected to a different server. This separation matters: permissions granted to a filesystem server should not silently become permissions for an unrelated remote service.

What servers can expose

Capability discovery tells the client what is available; it is not a reason to expose every capability to the model. A mature host can progressively disclose tools relevant to the task and apply policy before execution.

Data and transport layers

MCP uses JSON-RPC messages for lifecycle negotiation and protocol operations. Local servers commonly use standard input/output, while remote servers commonly use Streamable HTTP. Transport changes the threat model. A local process may inherit filesystem and user privileges; a remote service adds authentication, authorization, network, redirect, and server-side isolation concerns.

A minimal design exercise

Before writing code, describe one narrow server contract. For a read-only issue tracker server, for example:

Tool: get_issue
Input: { repository: string, issue_number: integer }
Output: { title, body, labels, updated_at }
Authority: read-only access to approved repositories
Errors: not_found | forbidden | rate_limited
Logging: tool name, repository, issue number, outcome

This contract is easier to secure and test than a generic “run API request” tool. Keep input schemas narrow, return structured errors, apply authorization outside the model, and avoid passing arbitrary URLs or shell fragments.

Local server checklist

  1. Inspect the package, repository, exact startup command, and transitive dependencies before execution.
  2. Run with the least operating-system privilege and limit filesystem and network access.
  3. Prefer a dedicated workspace; never assume localhost is inaccessible to malicious browser or process activity.
  4. Show the exact command and arguments before one-click installation.
  5. Require confirmation before writes, execution, deletion, deployment, or communication.
  6. Provide a clear uninstall and credential-revocation path.

Remote server checklist

  1. Authenticate the user and authorize each resource or action.
  2. Validate token audience; do not pass arbitrary upstream tokens through.
  3. Use exact redirect URI validation and CSRF protections in authorization flows.
  4. Protect OAuth discovery and redirects against SSRF and internal-network access.
  5. Separate tenants in storage, logs, caches, and queues.
  6. Rate-limit and audit actions without recording unnecessary sensitive content.

Testing an MCP integration

Test protocol success and policy failure. Verify capability negotiation, schema validation, cancellation, timeouts, malformed messages, permission denial, expired credentials, and a server that returns hostile instructions in otherwise valid data. Confirm that the host does not treat a tool result as higher-priority policy.

Common misconceptions

Worked threat model: a remote ticketing server

Illustrative review—not an assessment of a real server. A remote MCP server exposes ticket_get, ticket_search, and ticket_addComment. It exchanges data with a third-party ticketing API on behalf of signed-in users.

Asset or boundaryThreatRequired control
User authorizationA malicious client reuses another client's consentPer-client consent, exact redirect validation, CSRF protection
Access tokenToken intended for another audience is accepted or forwardedValidate issuer and audience; never use token passthrough
Ticket contentA ticket contains instructions to exfiltrate dataTreat tool results as untrusted content below host policy
Write toolThe model posts a comment without meaningful consentPer-call authorization and approval tied to exact arguments
Tenant boundarySearch leaks another organization's ticketsDerive tenant scope server-side and test isolation
Authorization discoveryAttacker-controlled metadata redirects internal requestsSSRF defenses, HTTPS policy, redirect and IP-range validation

Follow the lifecycle, not just the tool call

  1. Connect: establish the transport and authenticate the remote endpoint where required.
  2. Initialize: negotiate protocol version and capabilities; reject unsupported or inconsistent peers.
  3. Discover: list tools, resources, or prompts and apply host-side visibility policy.
  4. Present: show users which server supplies a capability and what authority it requires.
  5. Authorize: evaluate user identity, tenant, scope, target, and approval before each consequential call.
  6. Execute: send a bounded request with timeout, cancellation, and correlation identifiers.
  7. Validate: parse the result as untrusted structured data and enforce size and content limits.
  8. Close or revoke: terminate sessions, remove credentials, and invalidate cached capability state when trust changes.

Use a host-side permission manifest

The protocol describes capabilities; the host still needs a local policy. One possible manifest is:

{
  "server": "tickets.example",
  "tenant": "tenant_42",
  "visible_tools": ["ticket_get", "ticket_search", "ticket_addComment"],
  "automatic": ["ticket_get", "ticket_search"],
  "requires_approval": ["ticket_addComment"],
  "resource_allowlist": ["ticket://tenant_42/*"],
  "max_calls_per_run": 20,
  "credential_ref": "vault://mcp/tickets/user_7",
  "expires_at": "2026-08-10T12:00:00Z"
}

Do not let a server response expand this manifest. Approval should bind the tool name, normalized arguments, user, server identity, and a short validity window. If any of those change, ask again.

Transport-specific review

ConcernLocal stdioRemote HTTP
IdentityPackage, executable path, checksum, and launching userTLS endpoint, server metadata, OAuth client and resource identity
Primary authorityInherited files, environment, processes, and networkGranted scopes, tenant data, downstream APIs
Secret handlingSanitized environment or brokered credential accessAudience-bound tokens in a secure store
IsolationSandbox, dedicated workspace, OS permissionsTenant separation, egress controls, rate limits
RevocationStop process, remove package/config, rotate exposed secretsRevoke grant/token, disconnect client, invalidate sessions

Authorization review for remote servers

Reproducible integration test matrix

CaseInjected conditionExpected result
NegotiationUnsupported protocol versionClean failure with no tool exposure
SchemaExtra key, wrong type, or oversized valueRejected before server action
AuthorizationExpired token or wrong audienceDenied; token is not forwarded
ConsentArguments change after approvalApproval becomes invalid
InjectionTool result says to ignore host policyContent remains data, not instruction
IsolationUser requests another tenant identifierServer-side tenant scope wins
AvailabilityTimeout, cancellation, disconnectBounded retry or typed terminal failure
RevocationGrant removed during a sessionNext call reauthorizes or fails closed

Incident response and removal

  1. Disable the server connection or specific capability without waiting for a full application release.
  2. Revoke user grants and rotate any credentials available to the server process.
  3. Preserve a minimal audit trail: server identity, tool, normalized target, user, authorization result, and time.
  4. Search for related calls while avoiding unnecessary prompt or document disclosure.
  5. Invalidate cached tool definitions and authorization metadata.
  6. Patch or remove the server, rerun the adversarial suite, and document the new trust decision before reconnecting.

Primary references

Bottom line

MCP makes integrations portable. Safety still depends on narrow capabilities, real authorization, isolated execution, visible approvals, and testing that treats every external result as untrusted.

What MCP tool calls cost

Model Context Protocol makes it easy to attach tools, and each attachment adds context that is sent on every relevant call. The protocol is cheap; the context it carries is not free. Below: one tool-using request at 25K input, 15K cached, 2.5K output. Of the 25,000 input tokens, 15,000 are billed at the cache-read rate and 10,000 at full input rate.

Model Cost per request Monthly at 8,000 requests
GPT-5.6 Luna$0.0053$42.40
Gemini 3.8 Flash$0.018$144
Claude Sonnet 5$0.048$384

The interesting comparison is the two small models: they differ by a factor of two while both being far below the flagship, which suggests that for tool-heavy traffic the decision is mostly about how much context the server injects, not about the token rate.

Rates verified against provider documentation on September 18, 2026. Promotional rates expire, so re-check before budgeting: LLM API cost planning · September 2026 pricing update. Run your own numbers in the cost calculator.