Opsphere
← All articles

MCP Security: 5 Auth Checks for Devs (OAuth2.1 & RFC9728/8707)

MCP Security: 5 Auth Checks for Devs (OAuth2.1 & RFC9728/8707)

Isometric illustration of MCP security boundaries

MCP, the Model Context Protocol, is an open standard that lets AI models call external tools and data sources through a single, consistent interface instead of a custom integration for every system. Its core benefit is standardized, bidirectional access between models and the tools they need to act on. If you’re building or evaluating an integration today, start by reading the authorization specification and picking an official SDK for your language.


TL;DR:

  • A secure MCP implementation must enforce audience validation and never accept tokens from another server to prevent token reuse or misdirection attacks.
  • Use HTTPS and generate cryptographically secure session identifiers for HTTP transport, and rely on environment variables for credentials in STDIO setups to mitigate security risks.
  • Building an MCP client begins with registering a client ID, implementing PKCE, requesting resource-specific tokens, and validating the token’s audience claim before any tool execution.
  • The MCP ecosystem has official SDKs across multiple languages, but adoption is still consolidating, with many servers and SDKs in varying maturity stages.
  • Opsphere leverages MCP to enable cross-system, read-only context sharing for incident investigation, reducing manual effort and speeding up root cause analysis.

Opsphere
opsphere.io
Bring MCP Into Clearer Operations
Opsphere unifies MCP context across cloud, observability, security and engineering tools through more than 300 read-only operational tools.
Explore Opsphere

Table of Contents

What MCP Enables: Real Use Cases Beyond Retrieval

MCP shows up wherever an AI assistant needs to do something, not just know something. A coding assistant using MCP can read a repository, run a linter, and open a pull request in one session. A support agent can pull a customer record, check an order status, and issue a refund, all through the same protocol.

Common patterns include:

  • Calendar, email, and note-taking integrations for personal AI assistants
  • Code generation tools that read repositories and execute build or test commands
  • Design tools that pull assets and push updates back into a shared workspace
  • Enterprise workflows that touch multiple databases, ticketing systems, and internal APIs in one task

This is where MCP diverges from retrieval-augmented generation. RAG focuses on fetching text to feed into a model’s context window for better answers. MCP goes further, enabling bidirectional interactions including tool execution and structured context exchange, so the model doesn’t just read data, it can act on it. In a typical stack, MCP sits between your AI engine and the operational systems it needs to reach, often alongside the LLM integration layer that routes requests to the right model.

The Building Blocks: Hosts, Clients, Servers, and Transports

MCP’s architecture has three roles. The host is the application the user interacts with, like an IDE or a chat interface. The client lives inside the host and manages the connection to one or more MCP servers, handling requests and responses on the host’s behalf. The server exposes tools, resources, and prompts, tied to a specific system such as a database, a cloud API, or an internal service.

Transport determines how client and server talk to each other. STDIO transport runs the server as a local subprocess and communicates over standard input and output, ideal for local development and desktop tools. HTTP transport (usually Streamable HTTP) suits remote and multi-client deployments but introduces network exposure that STDIO never has to deal with.

MCP servers are designed to be largely stateless at the protocol level, though many implementations track session state for efficiency. Each server has a canonical resource identifier, typically a URI, that clients and authorization servers use to scope tokens correctly. When sessions are used over HTTP, servers pass a session identifier, often via an MCP-Session-Id header, that both sides must treat as sensitive and validate strictly on every request.

The Building Blocks: Hosts, Clients, Servers, and Transports — overview diagram

Authorization and Security: What the Spec Actually Requires

MCP’s authorization model isn’t optional guidance, it’s normative. The specification requires protected MCP servers to act as OAuth 2.1 resource servers, publish Protected Resource Metadata under RFC9728, and use Resource Indicators from RFC8707 so tokens are bound to a specific server rather than usable anywhere.

That last point matters more than it sounds. A token issued for one MCP server should never be accepted by another, and validating audience and resource indicators is the primary defense against token reuse and misdirection attacks in multiserver, multi-agent setups.

Before you ship an MCP server or client into production, walk through these checks:

  1. Confirm the server publishes RFC9728 Protected Resource Metadata and advertises its authorization server correctly.
  2. Require PKCE and HTTPS for every OAuth flow, including public clients that can’t hold a secret.
  3. Validate the token’s audience claim against the server’s own resource URI on every request, not just at connection time.
  4. Reject any request lacking a per-request authorization header, even within an otherwise authenticated session.
  5. Never pass a token received from a client through to an upstream API unchanged, issue a separate upstream token if the server needs to call out further.

Registries and vendors report growing SDK downloads and server counts as MCP adoption accelerates, but registry totals vary widely depending on curation policy, so treat any single “number of MCP servers” claim as directional, not definitive.

Pro Tip: Log every rejected token with the reason (audience mismatch, expired, missing scope) rather than a generic 403. That single change turns a security control into a debugging tool when a client integration breaks in staging.

The most common failure mode isn’t a missing OAuth flow, it’s a correctly implemented flow that skips audience validation, which quietly turns a per-server token into a bearer credential any connected server will accept.

Choosing Transports and Hardening for Production

STDIO and HTTP transports carry different security assumptions, and conflating them is a frequent source of misconfiguration. STDIO servers should pull credentials directly from the environment rather than implementing the HTTP-style OAuth flow, since the specification explicitly separates STDIO’s local trust model from HTTP’s network-facing one. Treat a STDIO server like any other local subprocess: trusted because it runs on the same machine under the same user, not because it authenticated itself.

STDIO and HTTP security comparison

HTTP transport needs the opposite posture. Bind local development servers to localhost explicitly, validate the Origin header on incoming requests to block DNS rebinding attacks, and never assume a request came from your intended client just because it has a valid session ID.

For session handling, generate session identifiers as cryptographically secure values, UUIDs or signed JWTs work well, and reject any request whose session header doesn’t match a server-side record. Production hardening checklists should include HTTPS everywhere, PKCE for every client type, and resource indicators binding every issued token to the specific MCP server it’s meant for. Skipping any one of these doesn’t just weaken security, it usually breaks interoperability with clients that assume spec-compliant behavior.

Where to Find SDKs, Registries, and Example Servers

The MCP ecosystem now spans official SDKs in Python, TypeScript, and several other languages, maintained under the protocol’s open governance. Since Anthropic’s original announcement describing MCP as a universal standard replacing fragmented custom integrations, community and vendor SDKs have expanded to cover Java, Kotlin, C#, and Rust, with varying levels of maturity.

Before building from scratch, check these resources:

  • Official SDK repositories for your language, which include working client and server examples
  • Public MCP server registries, keeping in mind that listed counts differ by curation bar and can overstate real-world adoption
  • Curated “awesome MCP” lists maintained by the developer community, useful for finding servers for specific systems like databases or cloud providers
  • IDE and editor extensions that bundle MCP client support, letting you test a server without writing a full host application

Adoption momentum is real, but the honest read is that the ecosystem is still consolidating around a smaller set of production-grade servers than the raw registry numbers suggest.

Building Your First MCP Client and Server

Getting a working integration running doesn’t require deep protocol expertise, but it does require following the security steps in order. Skip one and you’ll spend more time debugging auth failures than building the feature.

  1. Pick an official SDK for your language and install it, then identify the target server’s canonical resource URI.
  2. Register a client ID, using dynamic client registration if the authorization server supports it, or pre-registering manually if not.
  3. Implement PKCE in your authorization code flow, even if your client is confidential, since it costs little and closes an entire class of interception attacks.
  4. Request a token scoped explicitly to the server’s resource indicator rather than a generic access token.
  5. Validate the returned token’s audience claim client-side before your first tool call, catching misconfiguration before it reaches the server.
  6. Make a simple tool call and handle an insufficient_scope error by re-requesting authorization with the missing scope, not by retrying blindly.

Pro Tip: Build your first integration against a local STDIO server before touching HTTP transport at all. You’ll isolate protocol logic from network and auth concerns, which makes the eventual jump to a hardened HTTP deployment much easier to debug.

How Opsphere Puts MCP to Work in Operations Teams

Opsphere applies MCP as the connective layer between AI agents and the systems SRE and platform teams already run, AWS, Kubernetes, observability stacks, CI/CD, and security tooling, without requiring teams to replace anything. Every connector operates read-only, so an investigation can pull context across dozens of tools without ever risking a write action against production infrastructure.

That matters most during incidents, when engineers need cross-system context fast: a Kubernetes rollout correlated with a deploy event, correlated with an anomalous latency spike, all pulled through MCP-based tool calls into one investigation thread. Context persists across a session rather than resetting with every query, which shortens the loop between noticing a signal and understanding its cause.

If your team is piloting MCP-based tooling internally, track investigation time and the number of manual context switches per incident before and after. Opsphere’s platform engineering use cases walk through how teams structure that kind of pilot.

Specs and Docs Worth Bookmarking

Teams building agentic workflows on top of these specs often benefit from outside implementation experience. Partners like benchmarked work specifically on operationalizing agentic AI and MCP-based integrations for companies moving past proof-of-concept.

If you’re evaluating how MCP fits into a broader operational intelligence layer, Opsphere’s Developer plan starts at €19 per month, with Team and Enterprise tiers available for larger deployments, and a free Community tier for smaller-scale experimentation.

Sources

FAQ

What Does MCP Stand For?

MCP stands for Model Context Protocol, an open standard donated by Anthropic to the Agentic AI Foundation under the Linux Foundation for vendor-neutral governance. It defines how AI models connect to external tools and data sources in a standardized way.

What Is the Difference Between MCP and an API?

A traditional API is a fixed integration point built for one specific system, requiring custom code for every new connection. MCP is a protocol layer that standardizes how AI models discover and call tools and resources across many systems using the same client implementation, rather than a one-off integration.

What Is the Meaning of MCP in AI Systems?

In AI systems, MCP means giving a model structured, bidirectional access to real tools and live data instead of relying only on retrieved text for context. It replaces fragmented custom integrations with one open protocol that any compliant client or server can use.

Does ChatGPT Use MCP?

Multiple major AI platforms and IDE ecosystems have added MCP client support since Anthropic introduced the protocol, reflecting broad industry momentum around the standard. Specific platform support changes quickly, so check each vendor’s own developer documentation for the current state of MCP compatibility.

This article is provided for general informational purposes only and does not constitute professional, legal, security, or compliance advice. Please evaluate recommendations against your organization’s specific environment and requirements.

Opsphere
Discuss Your MCP Security Needs
Contact Opsphere to discuss operational context, governance and secure read-only access across your cloud and engineering tools.