Skip to main content
Agentic AI
MCP
Security
Spec 2026-07-28

Running MCP Servers in Production

Transports, OAuth authorization, the attacks the spec warns about, and a deployment checklist for teams moving AI agents from demo to production. Based on the 2026-07-28 Model Context Protocol specification.

Published November 23, 2026 · HostingX Solutions LLC

Short answer

  • Pick the transport by who uses the server. Use stdio for a tool one person runs on their own machine. Use remote Streamable HTTP for anything a team or a hosted agent shares.

  • Scale it like a stateless API. The 2026-07-28 revision removed protocol sessions. Every request carries its own protocol version and client capabilities, so any replica can answer it.

  • Use the spec's OAuth model on remote servers. The server acts as an OAuth 2.1 resource server, publishes Protected Resource Metadata and accepts only tokens issued for it. It never forwards a client's token downstream.

  • Treat tool output as untrusted input. Keep scopes narrow and put a human approval step in front of write actions.

What Changed in the 2026-07-28 MCP Specification?

MCP is a JSON-RPC 2.0 protocol between hosts (LLM applications), the clients inside them, and servers that expose tools, resources and prompts. The revision modelcontextprotocol.io serves as current in November 2026 is dated 2026-07-28, and it changes how a remote server behaves on the wire. Guides written against 2025-11-25 or earlier get these points wrong:

  • No protocol sessions. The Mcp-Session-Id header and the initialize handshake are gone. Every request carries its protocol version and client capabilities in _meta.

  • A new required method. Servers must implement server/discover to advertise their supported versions, capabilities and identity.

  • No standalone GET stream. Change notifications arrive on a long-lived subscriptions/listen response stream that the client opts into.

  • No stream resumption. If a response stream breaks, the in-flight request is lost and the client must re-issue it with a new request ID.

  • Deprecations. Roots, Sampling and Logging are deprecated, along with the old HTTP+SSE transport and Dynamic Client Registration, which gives way to Client ID Metadata Documents.

Before you plan a rollout, check which protocol versions your SDK and your MCP clients support. A server that has to serve older clients also implements the older revision's behavior, sessions included.

Local stdio or Remote Streamable HTTP?

The spec defines two standard transports. Protocol semantics are identical on both; what differs is who can reach the server and how it gets credentials.

stdio: a subprocess of the client

The client launches the server as a subprocess and exchanges newline-delimited JSON-RPC over stdin and stdout. The server must not write anything to stdout that isn't a valid MCP message; logs go to stderr. The authorization spec says stdio implementations should not use its OAuth flow and should read credentials from the environment instead. In practice, the server runs with the privileges of whoever launched it.

Streamable HTTP: an independent service

The server exposes a single MCP endpoint. Each client message is its own HTTP POST, answered with one JSON object or a Server-Sent Events (SSE) stream scoped to that request. Every POST carries MCP-Protocol-Version and Mcp-Method headers; tool calls, resource reads and prompt requests also carry Mcp-Name. The server must reject a request whose headers don't match its body with HTTP 400 and a HeaderMismatch error, so a gateway routing on headers and a server executing the body can't be played against each other.

 stdioStreamable HTTP
Who starts itThe MCP client, as a subprocessYour platform, as an independent service
Who can reach itOnly the client that launched itAnything that can reach the endpoint, so authentication matters
CredentialsRead from the environmentOAuth 2.1 bearer tokens, per the MCP authorization spec
FramingNewline-delimited JSON-RPC on stdin and stdoutOne HTTP POST per message; JSON or a request-scoped SSE stream back
ScalingOne process per clientStateless replicas behind a load balancer
Good fitDeveloper tools and local files on one machineShared team tools, hosted agents, anything that touches company systems

Transport behavior from the MCP 2026-07-28 specification. The scaling and fit rows are our recommendations.

Check your hosting platform too. Google Cloud Run, for example, documents support for MCP servers that use Streamable HTTP but not for stdio servers, and by default its services require every caller to hold the Cloud Run Invoker role.

How Do You Host a Remote MCP Server on Containers or Kubernetes?

Scale it like a stateless API

Under 2026-07-28, servers must not rely on earlier requests on the same connection for context, and should not require a client to reuse a connection or process. For current-version traffic that means no sticky sessions: any replica can serve any request. State that spans calls, such as an open workflow, is an explicit handle the server returns and the model passes back as a tool argument. Keep that state in a shared store, not in one replica's memory.

Configure the path for streaming

  • Responses can be SSE streams. The spec says servers should send X-Accel-Buffering: no so reverse proxies such as nginx don't buffer events.

  • subscriptions/listen holds a stream open. The spec encourages periodic SSE comment lines as keep-alives; set ingress and load balancer idle timeouts with that stream in mind.

  • Closing a response stream cancels that request, and the server should stop work on it. Because a broken stream loses the request and the client retries with a new ID, we recommend making write tools safe to retry.

Lock down the endpoint

The Streamable HTTP security rules are short. Servers must validate the Origin header on every incoming connection and return 403 when it is present and invalid, which blocks DNS rebinding. A server running locally should bind to 127.0.0.1, not 0.0.0.0. And servers should authenticate all connections.

On Kubernetes, we recommend running MCP servers under the restricted Pod Security Standard, with a NetworkPolicy that limits egress to the APIs the tools actually call. Our Kubernetes hardening guide covers enforcing that with policy. A minimal starting point:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcp-server                  # placeholder
spec:
  replicas: 2
  selector:
    matchLabels:
      app: mcp-server
  template:
    metadata:
      labels:
        app: mcp-server
    spec:
      automountServiceAccountToken: false
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001            # placeholder non-root UID
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: mcp-server
          image: REGISTRY/mcp-server:TAG   # placeholder
          ports:
            - containerPort: 8080   # placeholder
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: ["ALL"]

Names, image, UID and port are placeholders. The pod and container security settings satisfy the restricted profile; readOnlyRootFilesystem and automountServiceAccountToken: false are extra hardening on top of it.

How Does MCP Authorization Work?

Authorization is optional in the spec, but an HTTP implementation that supports it should follow the spec's model. Our recommendation: any remote server that touches company data requires it. The roles map onto OAuth you may already run:

  • The MCP server is an OAuth 2.1 resource server. It accepts and checks access tokens.

  • The MCP client is an OAuth 2.1 client making requests on the user's behalf.

  • The authorization server issues tokens. It can run with the MCP server or separately, so your existing identity provider can fill the role if it meets the spec's requirements.

The flow, step by step

  1. The client calls without a token. The server returns 401 with a WWW-Authenticate header pointing to its Protected Resource Metadata (RFC 9728), which MCP servers must publish.

  2. The client reads that document to find the authorization server, then that server's metadata through OAuth 2.0 Authorization Server Metadata or OpenID Connect Discovery.

  3. The client obtains a client ID through a Client ID Metadata Document, pre-registration, or the deprecated Dynamic Client Registration.

  4. The client uses PKCE with S256 and sends the resource parameter (RFC 8707), set to the MCP server's canonical URI, in the authorization and token requests. It checks the iss value in the response against the issuer it recorded (RFC 9207).

  5. Every HTTP request carries Authorization: Bearer <token>. Tokens never go in the query string.

What the server must enforce

  • Validate every token and confirm it was issued for this server as the audience. Invalid or expired tokens get a 401.

  • When a token lacks a scope, return 403 with error="insufficient_scope" and the scopes the operation needs, so the client can step up instead of failing.

  • Accept no other tokens. When a tool calls an upstream API, the server acts as an OAuth client to that API and uses a separate token from the upstream authorization server.

On the issuing side, the spec says authorization servers should issue short-lived access tokens, must rotate refresh tokens for public clients, and must serve every endpoint over HTTPS. Redirect URIs must be localhost or HTTPS. Clients support this flow today: Claude Code, for example, signs in to remote HTTP servers with OAuth 2.0 through its /mcp command.

Which MCP Server Security Risks Does the Spec Call Out?

The spec's Security Best Practices page lists specific attacks with required mitigations. These are the ones that matter most to a platform team running servers.

Token passthrough

Accepting a token issued for another service and forwarding it downstream is explicitly forbidden. It bypasses rate limits and validation tied to the token's audience, puts the wrong caller in audit logs, and lets anyone holding a stolen token use your server as a proxy for data exfiltration. The mitigation is one rule: MCP servers must not accept any token that was not explicitly issued for them.

Confused deputy in proxy servers

An MCP server that fronts a third-party API with one static OAuth client ID can be tricked into sending an authorization code to an attacker when the third party's consent cookie skips its consent screen. Proxy servers must run their own per-client consent before forwarding, match redirect URIs exactly, and use single-use, short-lived state values.

State handle hijacking

With sessions gone, cross-call state lives in handles passed as tool arguments. Servers must not treat possession of a handle as authentication. Generate handles randomly, let them expire, and key stored state by the user ID from the verified token, so a guessed handle is useless to anyone else.

Server-side request forgery

If your agents run on servers as MCP clients, a malicious MCP server can hand them OAuth discovery URLs that point at internal services or the cloud metadata endpoint. The spec recommends requiring HTTPS, blocking private and link-local ranges, and routing discovery through an egress proxy.

Local server compromise

A local server is code running with the user's privileges. Clients that offer one-click setup must show the exact command and require explicit approval before running it, and the spec recommends sandboxing local servers.

Over-broad scopes

A stolen token is only as dangerous as its scopes. Start with a minimal set for discovery and reads, request more through targeted scope challenges when a privileged tool is first used, and avoid wildcard scopes.

Prompt injection through tool output

The spec treats tools as arbitrary code execution, and tool descriptions and annotations as untrusted unless they come from a trusted server. There should always be a human in the loop who can deny a tool call, and clients should validate tool results before passing them to the model. Servers must validate inputs, enforce access controls, rate-limit calls and sanitize outputs. Anthropic's Claude Code documentation is direct: servers that fetch external content can expose you to prompt injection.

Our recommendation: keep read-only tools that pull in outside content separate from tools that write or send data, and require approval on the write side, so an instruction hidden in a web page or ticket can't move data out unseen.

What Should You Log and Trace?

  • Logs. The MCP Logging feature is deprecated; the spec says to log to stderr on stdio or use OpenTelemetry.

  • Traces. _meta reserves traceparent, tracestate and baggage for OpenTelemetry context, so one trace can follow a request from the agent through the MCP server to the downstream API.

  • Gateway metrics. The Mcp-Method and Mcp-Name headers let gateways count calls, errors and latency per tool without parsing bodies.

  • Audit. Clients should log tool usage; servers should log scope elevation events with correlation IDs.

  • What not to trust or keep. clientInfo and serverInfo are self-reported, so don't base security decisions on them. Never log tokens; the spec names logged tokens as a theft path.

On the client side, Claude Code can export OpenTelemetry events with MCP server and tool names when OTEL_LOG_TOOL_DETAILS=1 is set. Our OpenTelemetry rollout guide covers the collector side.

How Do You Control Which MCP Servers Engineers Connect?

Servers you host are half the picture; the other half is what engineers connect on their own machines. Anthropic's documentation says that by default anyone running Claude Code can connect any MCP server, and that Anthropic doesn't security-audit or manage MCP servers. Administrators can deploy managed-mcp.json to fix the server set, or enforce an approved catalog with allowedMcpServers and allowManagedMcpServersOnly: true, matching remote servers by URL and local servers by command. Matching by server name is not a security control, because users choose the name.

Any user on the machine can read managed-mcp.json, so keep credentials out of it and let each user sign in with OAuth. Server-side credentials belong in a secret manager; our Vault vs AWS SSM guide compares two options.

MCP Server Production-Readiness Checklist

  1. Transport. stdio only for single-user local tools; Streamable HTTP for anything shared.

  2. Protocol version. Confirmed for your SDK and clients, including whether you still serve 2025-11-25 clients.

  3. Statelessness. server/discover implemented, replicas interchangeable, cross-call state in a shared store keyed by user and handle.

  4. Endpoint. Origin validated, TLS on, local servers bound to 127.0.0.1.

  5. Authorization. Protected Resource Metadata published, audience checked on every request, scope challenges on 403.

  6. No token passthrough. Upstream APIs called with their own tokens.

  7. Scopes. Minimal to start, no wildcards, step-up for write tools.

  8. Human approval. Write tools behind approval and kept apart from tools that read outside content.

  9. Tool hygiene. Inputs validated, outputs sanitized, calls rate-limited and time-limited.

  10. Runtime. Restricted Pod Security Standard, egress allowlist, secrets from a secret manager.

  11. Streaming. No proxy buffering on SSE; idle timeouts that fit subscriptions/listen.

  12. Observability. Trace context in _meta, tool calls audited, tokens never logged.

  13. Client governance. An approved server list for the MCP clients your engineers use.

Frequently Asked Questions

Do remote MCP servers still need sticky sessions?

Not for traffic on the 2026-07-28 revision, which removed protocol sessions. Revisions 2025-03-26 through 2025-11-25 let servers assign a session with Mcp-Session-Id. If you still serve clients on those versions, you implement that revision's session behavior alongside the new one.

Can an MCP server pass the user's token to a downstream API?

No. The spec forbids token passthrough. The server accepts only tokens issued for itself and uses a separate token from the upstream authorization server for each upstream API.

Is the HTTP+SSE transport still supported?

It has been deprecated since protocol version 2025-03-26 and is now formally in the Deprecated state; new implementations should use Streamable HTTP. Claude Code's documentation also marks SSE as deprecated in favor of HTTP.

Moving an AI agent from demo to production?

We help US businesses put MCP servers and the agents that call them into production: hosting, OAuth with your identity provider, approval steps on write tools, and tracing. The first 30-minute consultation is free.

Sources

See also: Automation services · Agent workflows on n8n

HostingX Solutions LLC logo

HostingX Solutions LLC

FinOps, DevOps, and automation for US businesses.

info@hostingx.solutions

Subscribe to our newsletter

Get monthly email updates about improvements.


© 2026 HostingX Solutions LLC. All Rights Reserved.

LLC No. 0008072296 | Est. 2026 | New Mexico, USA

Legal

Terms of Service

Privacy Policy

Acceptable Use Policy

Security & Compliance

Security Policy

Service Level Agreement

Compliance & Certifications

Accessibility Statement

Privacy & Preferences

Cookie Policy

Manage Cookie Preferences

Data Subject Rights (DSAR)

Unsubscribe from Emails