MCP authentication and authorization: a practical guide

MCP authentication proves who is calling an MCP server. MCP authorization decides what that verified identity may do on this particular call. Most explanations stop there. In production there is a third consideration, and it decides whether your audit log means anything: which credential does the MCP server use when it reaches the downstream system, such as GitHub, a database or Google Drive?

We maintain ToolHive, an open source MCP platform, and we have used it to deploy our own MCP servers on Kubernetes. This post addresses those three considerations. It covers the configuration, the failure modes and the rollout order we recommend to platform teams that are moving MCP servers off individual laptops and into shared use.

Why MCP raises the stakes on identity

The MCP specification defines how agents discover and invoke tools. It does not mandate authentication, role-based access control or audit logging at the platform level. That gap is yours to fill, and two things make it expensive.

First, MCP tool calls are the action surface where agents touch real systems: databases, APIs, internal services. Second, those calls now originate from AI agents rather than directly from your developers. A developer running a bad query shows up in your logs with a name attached. An agent running thousands of tool calls is invisible unless you have instrumented the MCP layer. These are the same systems, but they offer very different visibility.

This guide is for teams taking MCP servers from one developer’s machine to shared or production use, who need a design their security team will approve. Experimenting alone with a local server? Most of what follows is premature. Start with our guide to MCP server hosting for a team and come back when more people need access.

Authentication vs authorization: the two checks side by side

  • Core question. Authentication: who is this caller, and can we verify it? Authorization: given that verified identity, may it call this tool, right now?
  • When it runs. Authentication: whenever a token is presented and validated, ideally on every request rather than once per session. Authorization: on every tool invocation.
  • Mechanism. Authentication relies on tokens issued by your identity provider (IdP) and validated against its published signing keys. Authorization relies on policy evaluation, such as attribute-based rules, IdP group membership, and tool-level allow and deny.
  • What breaks without it. Without authentication, anyone who can reach the endpoint can call it. Without authorization, every authenticated user becomes a superuser for everything the server exposes.
  • Where it is enforced. Authentication: at the gateway or proxy that validates the token. Authorization: at a gateway or policy layer in front of the server, not scattered through each server’s own code.
  • What it writes to the audit log. Authentication: who authenticated, and every failure. Authorization: each tool call, the decision made, and every denial.

The failure modes point in opposite directions. Weak authentication lets the wrong identity in, while weak authorization lets the right identity do too much. You need both, enforced independently. Then you still need an answer for the downstream credential.

How one MCP request moves through the checks

Here is a single tool call in a governed setup, traced from the agent to the system it finally touches. The gateway in this example is a virtual MCP server (vMCP), which aggregates several MCP servers behind one endpoint.

  1. The user signs in once with the IdP. In practice that is your existing Okta, Entra ID or Google tenant, using SSO. The client receives a short-lived token.
  2. The gateway validates the token. Is the signature valid against the IdP’s published keys (the JWKS)? Was it issued by the expected issuer? Is it meant for this audience? Has it expired? Any failure ends the request here.
  3. The gateway checks authorization. Does this identity’s group claim allow access to this endpoint, and does policy allow this tool? In our vMCP, configured access policies are applied before tool calls reach MCP servers, and a token without the required group claim fails before the request reaches any MCP server.
  4. The MCP server runs the tool inside its own container, with only the network and filesystem access it was granted.
  5. The MCP server calls the downstream API. The credential it presents here is a separate authorization decision: the user’s own delegated access, or a service credential with its own scope.
  6. The decision and the call are recorded: identity, server, tool, parameters, result.

Local STDIO servers work differently. An MCP server is a process, and the protocol says nothing about where that process runs. A server launched on a developer’s machine talks to its client over standard input and output, so there is no network hop and no token to validate; it simply inherits that machine’s trust and whatever credentials sit in its environment. Convenient for one person. Once a team adopts it, every laptop turns into its own identity boundary with its own keys, and that is how sprawl starts.

Authentication: verify every caller against your identity provider

Use one IdP for every MCP server. If each server carries its own auth configuration, you fragment both identity and the audit trail, and every offboarding becomes a search.

Static API keys are where most teams start. They are also where many get stuck. Without a centralized authorization layer, developers configure MCP servers with locally stored API keys or service account tokens, and those credentials cannot be cleanly attributed to individual users, rotated across teams, or audited. Compliance turns this from a hygiene issue into a blocker, because SOC 2, HIPAA-adjacent and FedRAMP-adjacent requirements all expect centralized credential management and the ability to revoke access instantly when an employee leaves. A deployment where credentials live on developer laptops fails that by design.

The credential types you will meet, and how we think about them:

  • Short-lived OAuth access tokens from your IdP. Scoped, expiring and revocable at the source. Aim for these wherever a person or agent is involved.
  • JWTs carrying claims. The format many IdP-issued tokens take. Group and role claims travel with the token, so policy can read them, but only if you validate the signature, issuer and audience every time.
  • Static API keys. Easy, long-lived and anonymous at team scale. Keep them for downstream systems that offer nothing better, held behind the gateway, never on laptops.

What token validation looks like in configuration

When we deployed our own knowledge-base MCP server with the ToolHive Kubernetes operator, the MCPServer resource carried an oidcConfig block with four fields. Each one closes a specific hole:

  • issuer: your IdP’s URL. Tokens minted by anyone else are rejected.
  • audience: the audience the token must be issued for. A token your IdP issued for some other application cannot be replayed against this server.
  • jwksUrl: where the proxy fetches the IdP’s public keys to check signatures. A forged or altered token fails here.
  • jwksAllowPrivateIP: we set this to false. As the name suggests, it governs whether that key URL may resolve to a private address, and false is the conservative choice.

With that in place, ToolHive gave us a layer of control and authentication over the server. Connections are protected by OAuth. We know exactly who is calling in.

How we approach authentication

ToolHive uses OIDC for authentication and keeps it separate from authorization, which lets one model cover both user authentication via SSO and service authentication in Kubernetes. We explain the reasoning in getting authentication right for MCP servers.

Our embedded authorization server supports OIDC and OAuth 2.0, with native integrations for Okta, Microsoft Entra ID and Google Workspace. It operates in-process within a proxy, exposing standard OAuth endpoints inside your cluster: users authenticate through their IdP, and Stacklok issues and validates tokens internally. No credentials are stored locally on developer machines. No authorization request routes through a vendor endpoint. That last point matters for data residency, and for keeping the whole auth path inside your own audit perimeter. Connecting your IdP is a configuration step, not a development project.

For worked examples, see deploying an Okta-authenticated BigQuery MCP server on Kubernetes and using Okta to authenticate remotely to a BigQuery MCP server.

Authorization: decide what each identity can call, on every request

Authorization comes in layers. OAuth scopes bound what a token can ever be used for, roles map people and agents to sets of permissions, tool-level controls decide which specific tools inside a server a role may invoke, and contextual policy adds conditions on top, such as the arguments or the resource being touched. Scopes alone are not enough. They describe the token, not the person or agent holding it on this call.

The distinction that matters most in practice is server-level versus tool-level access. Server-level access controls whether a user or agent can reach an MCP server at all. Tool-level access controls which tools within that server they can invoke, so read operations can be permitted while delete or export operations are denied within the same server, per role, without modifying the underlying server. If your platform only does server-level access, connecting a CRM server means everyone who can read records can also delete them.

Policy as code

ToolHive implements authorization with the Cedar policy language, which gives fine-grained access to MCP servers with attribute-based rules. We walk through it in secure-by-default authorization for MCP servers. Hand-written policies work for a handful of servers. Past that, you will want roles managed centrally rather than policy files edited one by one, which is why Stacklok Enterprise brings RBAC to ToolHive.

Segment by team before go-live

With vMCP, each virtual endpoint aggregates a specific subset of your MCP servers and enforces access using your IdP group membership. A typical layout looks like this: engineering gets one endpoint, marketing gets another, and a shared endpoint covers tools everyone needs, like Slack or Google Drive. Access is gated by Okta, Microsoft Entra ID or Google Workspace group membership. Platform admins define which tools are visible to which identities through VirtualMCPServer custom resources, deployed through existing GitOps workflows, so a policy change goes through the same review as any other infrastructure change.

Make the segmentation decisions with your security team before deployment. Finding out during incident response that marketing could reach an engineering metrics API is the expensive way to learn it.

Per-request evaluation solves stale sessions

A common worry is that permissions granted at the start of a session outlive a role change. They shouldn’t. Stacklok validates the identity token against the configured IdP on every request; there is no session-level ambient authority, and each tool invocation is independently authorized. Because access to each vMCP endpoint is evaluated per request, once someone’s group changes in the IdP and their token reflects it, the next call is judged on the new claims. Policy can be scoped per agent identity, per team, per MCP server or per tool.

The step most guides skip: authorization to downstream systems

Authenticating and authorizing the caller at the MCP layer does not settle what happens next. The server still has to reach downstream systems with the right credential. This is where attribution quietly disappears.

Most MCP gateways authenticate the user at the front door and then call every backend with a single credential. The gateway’s own log knows who asked. The backend only sees the service principal. As we put it in an earlier post, if your MCP gateway calls backends as one service principal, your audit log names nobody. There is a second cost too: the backend enforces the service principal’s permissions rather than the user’s, so a user can reach data through an agent that they could not reach directly.

Token delegation fixes this. With RFC 8693 token exchange, the server exchanges the caller’s token for one that lets it act for that specific user at the backend, with the right scope, so accountability survives the hop. Our guide to token delegation for multi-user AI systems covers the pattern.

A lesson from our own build

When we built an internal knowledge assistant, we connected Onyx, an open source knowledge management tool, to Google Drive, GitHub repositories and Discord channels, and exposed it to agents through an MCP server we ran with ToolHive. The default approach suggested for Onyx required domain-wide delegation access across the full Google Drive Workspace. Had we granted that, the index would have had access to every document in our domain, including sensitive documents with PII. Indexed fragments would have landed in a vector database that may or may not be secured to the same standard. The authorization boundary would have fragmented.

We declined. Instead we used a normal account with OAuth access and standard permissions, holding the same access a typical employee has to documents teams have explicitly shared for broad internal access. That gives us confidence every piece of information in the vector database belongs there intentionally. It was not the end state, and we said so: passing the user’s OIDC token through the MCP server to the backend for proper authorization was still on our roadmap when we wrote the project up in our knowledge silos post.

The lesson is simple. Authorization at the MCP layer means little if the downstream credential is broader than the user’s own access. For every backend, decide explicitly between a delegated user token and a narrowly scoped service credential, and write down why.

Agents change the identity question

Bearer tokens issued at session start were designed for a person who logs in and does a bounded set of things. Hand one to an agent and a single token creates ambient authority: the agent can do anything the token permits, at any point, for any reason.

Delegation chains make it worse. When an orchestrator spawns a sub-agent, teams usually reach for one of three patterns, and none holds up:

  • Pass the parent’s token. The sub-agent now holds full ambient authority, with no scoping to the delegated task, and the audit trail shows the parent.
  • Give the sub-agent a static credential in configuration. Static credentials in configuration are a persistent supply chain risk, typically rotated by humans on a quarterly cycle rather than by the runtime per task.
  • Use a shared service account, or no credential at all. Expect that one to surface as a compliance finding.

Per-request identity is the practical answer available today. Every tool invocation carries an independently validated identity, which is what makes tool-level audit records possible. Agents that run unattended raise a related problem, because the identity on an action should never resolve to a person who was not there. We cover that in identity for the agents that work without you and what agent identity is.

An honest limit: native SPIFFE/SVID integration is on our roadmap, not shipped. When it ships, Stacklok will be able to receive SVID-attested workload identities directly from SPIRE, without an OIDC bridge. Today, per-request identity at the MCP gateway layer is enforced with tokens from your existing IdP. For the target architecture, see how to apply SPIFFE and relationship-based authorization to AI agents.

After the yes: limit what an authorized tool can do

Authentication and authorization control who can call which tools. Container isolation controls what those tools can do once called. These are different threat surfaces, and an authorization decision is not the last line of defence.

Run each MCP server with minimum permissions. A GitHub MCP server needs outbound HTTPS access to the GitHub API; it does not need your internal database subnet, your Slack API credentials, or the local filesystem beyond what its process requires. Define network egress rules per server. Restrict outbound connections to the hosts and ports it legitimately needs, and set filesystem access to read-only unless a specific write requirement exists.

In ToolHive, every MCP server runs in an isolated container with minimal permissions, and network access and filesystem scope are configurable via JSON profiles. On Kubernetes, the operator automatically creates a dedicated ServiceAccount, Role and RoleBinding for each MCPServer resource, namespace-scoped, with no manual ClusterRole configuration. It also creates network policies that restrict communication and handles secret management for OAuth credentials.

Supply chain belongs here too. MCP servers are software dependencies, and an attacker who compromises an upstream MCP server package gains the permissions you granted it. Minimal permissions limit that blast radius. Provenance checks help you avoid running a tampered server in the first place: ToolHive integrates Sigstore and GitHub Attestations for MCP server provenance verification, as described in solving the MCP server trust problem.

Log every decision so you can prove it later

A useful audit record for an MCP call answers six things: when it happened, the resolved identity, the MCP server, the tool, the parameters, and the authorization decision. In Stacklok, every tool call generates an OTel trace that includes the resolved agent identity, the MCP server invoked, the tool called, the parameters passed, and the authorization result.

Before go-live, instrument three signals:

  1. Request volume per MCP server and per access group, so anomalous usage stands out.
  2. Authentication failures. An unexpected spike means either a misconfigured policy or an access attempt outside normal patterns.
  3. Full request metadata for tool calls that touch sensitive systems, structured and exported to your SIEM.

Stacklok exports OpenTelemetry metrics aligned with the OTel MCP semantic conventions, and structured JSON audit logs compatible with Splunk, Datadog, New Relic and Elastic. The records land in the tools your security team already queries.

Mistakes we see teams make

  • Credential sprawl. Each developer managing their own tokens, each server configured separately per client, credentials stored locally with no rotation policy. It has been the most operationally painful mistake in early MCP deployments.
  • Treating a valid token as permission for everything the server exposes, instead of evaluating each tool call.
  • Gateways that call every backend as one service principal, which erases the user from the backend’s logs.
  • Skipping authorization for internal servers because they sit behind the network boundary. Anyone with internal network access then has every tool.
  • Accepting default setup instructions that ask for broad delegated access, as in our Onyx example.
  • Retrofitting controls. IdP integration, tool segmentation, isolation profiles and observability are all significantly harder to add after a deployment is live and teams depend on it.
  • No revocation plan. Know in advance how you will cut off a user, token or server fast. Our post on why you need a kill switch for MCP servers covers the scenarios.

A rollout order that works

  1. Connect the IdP before anyone connects a real MCP server to a real client.
  2. Agree on tool segments per team with your security team, and map them to IdP groups.
  3. Set per-server isolation profiles: egress allow-lists and read-only filesystems by default.
  4. Decide the downstream credential for each backend: delegated user token or narrowly scoped service credential.
  5. Turn on audit export and alerts for the three signals above.
  6. Test revocation: remove a user from a group, disable a token, stop a server, and confirm each takes effect.

There is a real trade-off here. Front-load heavy security on a prototype that does not work yet, and it can die in review. Bolt it on at the end, and you are touching every integration. The way out is to route tool calls through one shared runtime from the start, so adding a permission rule or an audit log later is a configuration change rather than a refactor. We explain how that priority shifts over an agent’s life in accuracy, cost, security: what to prioritize.

How Stacklok handles MCP authentication and authorization

ToolHive is our open source MCP platform, and its Apache 2.0 codebase can be audited directly on GitHub. The pieces covered in this guide fit together like this:

  • Authentication: an embedded authorization server with native Okta, Microsoft Entra ID and Google Workspace integrations, running in-process inside your cluster.
  • Authorization: Cedar-based, attribute-based rules, plus vMCP endpoints segmented by IdP group and evaluated per request. See our MCP gateway.
  • Isolation: each MCP server in its own container with configurable network and filesystem permissions. See the MCP runtime.
  • Audit: OTel traces and metrics aligned with the MCP semantic conventions, plus structured JSON audit logs.

Our platform secures 20M+ tool calls every month. Craig McLuckie (CEO) and Joe Beda (CTO) co-created Kubernetes, and Joe is a co-author of the SPIFFE specification, which shapes where our identity work is heading.

Who it is not for: the full enterprise feature set (the Kubernetes operator, vMCP gateway, embedded authorization server and portal) requires Kubernetes. If your team cannot run container infrastructure, weigh that before anything else. Our comparison of MCP platforms for access control and audit logs covers other options fairly.

Want to try the pattern yourself? Start with ToolHive from our projects page, then read MCP security best practices for Kubernetes teams and the MCP platform buyers guide for platform teams. If you would rather walk through your IdP and segmentation design with us, book a demo. More on how we work with platform teams is on our platform engineering page and the platform overview.

Frequently asked questions

What is the difference between MCP authentication and authorization?

Authentication verifies who is calling the MCP server, usually by validating a token issued by your identity provider. Authorization decides which tools and data that verified identity may use on each call.

Can you have authorization without authentication?

No. Policy needs a verified identity to evaluate. In our vMCP, a request whose token lacks the required group claim fails before it reaches any MCP server.

Which comes first?

Authentication. The token is validated first, then policy is evaluated against the identity and claims it carries. Both should run on every request, not once per session.

Are OAuth scopes enough?

Scopes bound what a token can ever do. Tool-level policy and group-based roles decide what this person or agent may do on this call, and that is where read versus delete gets decided.

How do you stop one team reaching another team’s tools?

Use segmented vMCP endpoints, each gated by IdP group membership and evaluated per request, and agree the segments with your security team before go-live.

November 16, 2026

Insights

Scott Buchanan

CMO

Scott Buchanan is the Chief Marketing Officer at Stacklok. Scott leads the company's first-party research efforts that define benchmarks for AI agent and MCP adoption. He's also an example of how a non-developer can lean into MCP and agentic workflows to increase productivity.

More by Scott Buchanan