mcp authentication oauth is the set of identity and access controls that lets an MCP client call remote tools without handing those tools an unrestricted user credential. For enterprise deployments, the key design is OAuth for the MCP connection, a separate and restricted credential for each downstream API, and policy checks on every sensitive action. If you are designing an MCP service, our MCP server development team can help map that design to your identity provider and backend systems.
The hard part is not adding a login screen. It is preserving the right identity as a request moves from a person, through an agent and MCP server, to a business system. This guide answers the architecture questions that matter, including how to avoid token leakage, how to handle automated agents and where OAuth scopes stop being enough.
How does the MCP OAuth authentication handshake work?
The MCP OAuth authentication handshake lets a client discover an MCP server’s identity requirements, obtain a token for that specific server and present it on subsequent requests. For remote HTTP deployments, the MCP authorisation framework describes OAuth-based access using protected resource metadata and an authorisation server. The MCP authorisation specification is the reference to check when implementing a particular protocol version.
A typical connection works like this:
- The client sends a request to the remote MCP server without an access token.
- The server responds with an unauthorised status and advertises where the client can find its protected resource metadata. This follows the discovery approach in RFC 9728.
- The client reads that metadata to find the relevant authorisation server, then reads the authorisation server’s metadata to learn its endpoints and supported capabilities.
- The client starts an OAuth authorisation code flow. For a public client, it uses PKCE, a mechanism that binds the token exchange to the client that started the login.
- The user signs in and approves the requested access. The authorisation server issues an access token for the MCP resource.
- The client sends that token in the HTTP Authorization header when making MCP requests.
The resource audience matters. The audience identifies the service that may accept a token. RFC 8707 resource indicators give a client a way to identify the intended resource during authorisation. A token for one MCP server should not be accepted by a different tool server simply because both are part of the same organisation.
This is a protocol-level connection, not proof that every tool action is safe. A valid token tells the server that the caller is authorised to connect under certain conditions. The MCP server still needs to check what the caller may do, which data it may access and whether the requested action is allowed in the current context.
Why must an MCP server not pass through a user token?
An MCP server must not forward the access token it received from an MCP client to a downstream API as if that token were a general-purpose credential. The MCP security considerations warn against token passthrough because it crosses security boundaries and can expose credentials to unintended services. See the MCP security considerations.
A token is meant for a particular audience. If a user token was issued for the MCP server, a downstream system such as a CRM, ticketing service or data warehouse should not treat it as a token issued for that system. Forwarding it also creates a serious exposure if the MCP server is compromised, misconfigured or manipulated by malicious tool output. The token may carry more authority than the downstream action needs.
This is sometimes called token laundering: a credential issued for one boundary is reused across another boundary without the right checks. A prompt injection attack might persuade an agent to call a legitimate tool with harmful parameters. If the tool server also holds or forwards a broad user token, the attacker may gain access beyond the intended tool action.
The safer rule is straightforward: accept a token only for the MCP resource it is intended for, validate it, and obtain a separate credential for the backend API. That credential should be limited to the API, user and action where possible. Do not put access tokens in query parameters, logs, model prompts or tool results. Keep tokens out of error messages and telemetry unless the value is securely redacted.
There are cases where an MCP server uses its own service identity to access a backend, but that is not the same as forwarding a user token. If the action needs to reflect a person’s permissions, the server must preserve that person’s identity through an explicit and auditable mechanism, rather than pretending a shared service account is the person.
How does OAuth token exchange preserve user identity?
OAuth token exchange lets a trusted server trade an incoming token for a new token with a narrower audience or permission set. RFC 8693 defines the token exchange framework. In an MCP architecture, an MCP gateway or server can submit the validated inbound user token to an enterprise Security Token Service and request a token for a specific backend API.
The exchange usually identifies the incoming token as the subject token and asks for a new access token as the requested token type. It also identifies the target audience, such as a particular internal API. The exact fields and claims depend on the authorisation server and the organisation’s identity design.
The result should be a token that is useful only for the intended backend, not a copy of the original credential. If the target API supports delegated identity, the token can represent the human user as the subject while also recording the software acting for that user. In some token profiles, the actor claim can identify the service or agent. Downstream services can then apply user permissions while logging both the human initiator and the machine actor.
A practical flow looks like this:
- The MCP server validates the incoming token’s issuer, signature or introspection status, expiry and audience.
- It checks that the requested tool call is permitted for that user and agent.
- It asks the token service for a credential scoped to the downstream API and operation.
- It calls that API with the exchanged credential, not the original MCP token.
- It records the user, agent, tool, target system, decision and outcome in an audit trail.
Token exchange does not magically make an unsafe authorisation model safe. The token service must be configured to trust only appropriate callers and claims. The backend must understand the exchanged token and enforce its own authorisation rules. If the downstream system cannot accept delegated identity, document the limitation and add compensating controls, such as a narrow service identity and detailed application-level audit records.
For teams building agents that span several systems, our AI agents and automation service can help design the execution path, identity boundaries and operational controls together.
Why does Dynamic Client Registration cause problems for enterprise MCP?
Dynamic Client Registration can cause problems because it lets software register an OAuth client with an authorisation server at runtime, while enterprise identity teams usually want to approve and manage which applications can request access. RFC 7591 defines a registration mechanism, but an organisation does not have to expose open registration to every client.
An MCP client may need a client ID before it can start an OAuth flow. If the client expects to create its own registration and the enterprise identity provider blocks that option, setup fails. Broadly enabling registration to make a single client work can create a new attack surface. The organisation may lose control over which clients are registered, which redirect addresses they use and how registrations are reviewed or revoked.
Enterprises have several options, and they are not interchangeable in every identity platform:
| Approach | How it works | Best fit | Main trade-off |
|---|---|---|---|
| Administrator pre-registration | An identity administrator creates and approves the client in the organisation’s identity provider | Approved clients and managed deployments | Requires an onboarding and change process |
| Client ID Metadata Documents | A client points to a hosted metadata document that describes the client | Environments where the identity provider and client support the approach | Support and validation rules vary; a document does not replace governance |
| Enterprise MCP gateway | A gateway handles the enterprise connection and mediates access to internal MCP servers | Many tools, central policy needs or varied client support | Adds a platform component that must be operated and secured |
| Open dynamic registration | Clients register themselves automatically | Controlled environments where the identity team accepts the risk | Less central control and more need for registration protections |
Client ID Metadata Documents, or CIMD, are an emerging alternative that lets a client identify itself through a document hosted at a verifiable address. Treat this as a deployment option to validate with your identity provider, not a universal replacement for pre-registration. The exact specification status and implementation support can change, so confirm the current details before relying on it.
For most enterprise teams, start by asking the identity owner which registration methods are approved. Then test the chosen client against a non-production identity tenant. Confirm redirect URI validation, consent behaviour, client revocation and what happens when the client’s metadata changes. Do not enable open registration simply to get past a setup error.
What is the difference between local stdio and remote HTTP authentication?
Local stdio and remote HTTP transports have different security models because one runs as a local process and the other receives network requests. Stdio connects an MCP client to a process on the same machine, often through standard input and output. Remote HTTP connects across a network and needs a defined way to identify and authorise callers.
For a local stdio server, credentials are generally supplied and protected by the host environment rather than by an OAuth exchange between the MCP client and a remote resource server. Use an operating system credential manager or another secure local secret store where available. Avoid placing long-lived credentials in configuration files that are checked into source control, exposed to other local users or captured in diagnostic output.
For remote HTTP servers, implement the authorisation behaviour required by the MCP version and transport you support. Validate the access token and its relevant claims or use the identity provider’s supported introspection mechanism. Check at least the issuer, audience, expiry and required permissions. Enforce TLS, protect the token from logs and apply rate limits and abuse controls.
Do not assume that a local transport is safe just because it has no network listener. A malicious local process, unsafe package or compromised developer machine can still access local secrets. Conversely, do not expose a local tool over a network without adding proper authentication and authorisation. The MCP documentation on authorisation explains the protocol’s concepts, while the implementation still needs to match your runtime and threat model.
A useful design decision is whether a tool should run locally at all. A filesystem or developer utility may belong on a user’s machine. A shared enterprise data service is more likely to need a centrally managed remote endpoint, where identity, policy and audit controls can be consistently applied.
Are OAuth scopes enough to control an AI agent?
OAuth scopes are not enough to control every agent action because scopes usually describe broad capabilities, not the full context of a particular request. A scope such as tickets:write may indicate permission to write tickets, but it does not necessarily say which ticket, which fields, which project or whether the requested change is safe now.
That difference matters when an agent interprets untrusted content. An email, document or web page might contain instructions designed to steer the model. The agent may have a legitimate scope and still attempt an action the user did not intend. Authentication answers who is calling. A scope gives a broad boundary. An authorisation policy must decide whether this specific request is allowed.
A stronger design places a policy enforcement point in front of sensitive tools. The enforcement point asks a policy decision point to evaluate the request using relevant attributes. Attributes can include:
- The human user and the agent or service acting for them.
- The tool name and requested operation.
- The target record, account, project or data partition.
- Parameters such as transaction amount, recipient or query type.
- Device, network, environment or time-based conditions.
- Whether the operation is read-only, reversible or destructive.
For example, an agent may be permitted to prepare a payment for review but not submit it. Another policy might allow a user to update records in their own region but deny changes to records outside it. A database tool might permit approved read queries while routing write queries through a human approval step.
A policy engine such as Open Policy Agent or Cerbos can centralise some of these decisions, but the product choice matters less than the control design. Keep the policy close enough to the execution path that the agent cannot bypass it by selecting a different tool or calling the backend directly. Make denials clear to the agent without revealing sensitive policy internals. Test policies against both normal and adversarial inputs.
How should headless agents authenticate without a human login?
A headless agent should authenticate with a workload identity and an application-level OAuth flow, not by relying on an employee’s interactive session. A workload identity is a verifiable identity assigned to a running service, such as a cloud workload or a Kubernetes service. OAuth client credentials can be appropriate when there is no user present to approve an interactive authorisation code flow.
The key distinction is whether the job acts for a particular person or operates as an autonomous service. A scheduled agent that processes a queue may have no human subject for each request. It should use a dedicated workload identity with narrow permissions. An agent completing a task on behalf of a named employee needs a way to preserve that user’s delegation and record which agent performed the action.
Avoid one shared credential for every agent, environment and tool. Create separate identities for production and development, and separate identities for materially different workloads. Use short-lived credentials where the platform supports them. Restrict which workloads may obtain credentials, rotate or revoke credentials through managed processes, and log identity issuance as well as tool execution.
Workload identity options can include a cloud provider’s role mechanism, Kubernetes service account tokens or a SPIFFE-based identity system. These are examples, not a one-size-fits-all recommendation. Choose based on the infrastructure you operate and the identity provider’s trust model. Confirm how the identity is bound to the running workload, how it is revoked and how credentials are protected from other processes.
For a human-delegated task, do not silently substitute a service account and claim the action was performed by the user. If the system cannot carry delegated identity to the backend, make that limitation visible in audit records and restrict what the agent can do. The enterprise architecture and platform engineering team can help assess how workload identity fits into your existing platform.
What does an enterprise MCP gateway do?
An enterprise MCP gateway provides a managed control point between MCP clients and internal tools. It can centralise token validation, routing, policy enforcement, rate limits, logging and token exchange instead of implementing a separate version of each control in every backend service.
A gateway is useful when many clients need access to many tools, when identity providers differ across systems or when security teams need a consistent view of agent activity. It can also help teams expose a curated set of tools rather than giving every agent direct access to every backend. The gateway may route requests to private MCP servers over a protected connection such as mutual TLS, where both sides authenticate the connection.
A gateway does not remove the need to secure the tools behind it. Backend services still need to validate their own trust boundaries, prevent direct bypass where required and enforce business permissions. The gateway itself becomes a high-value component. Protect its configuration, credentials and administrative interface. Monitor availability, capacity and policy changes. Plan for what happens if it is unavailable.
A sensible gateway design separates responsibilities:
- The client handles its user-facing login and requests the correct MCP resource.
- The gateway validates the incoming token and maps it to a user or workload identity.
- A policy layer checks the tool, parameters and context before execution.
- A token service exchanges credentials for a target-specific backend token where delegated access is needed.
- The backend enforces its own permissions and returns only the data the caller needs.
- Central logging records enough context to investigate actions without storing bearer tokens or unnecessary personal data.
Avoid making the gateway a single, opaque place where every identity becomes a shared service account. The gateway should preserve useful identity context, constrain access and produce records that explain who initiated an action and which component executed it. Our AI strategy and solutioning service can help determine whether a gateway is justified, or whether a smaller deployment can meet the same control requirements.
Why does my MCP client keep getting a 401 response?
A repeated 401 usually means the client is not presenting a token the MCP server accepts, or it cannot complete the discovery and authorisation flow. Start by checking the full exchange rather than changing server permissions at random.
Check these items in order:
- Metadata discovery: Does the unauthorised response advertise the protected resource metadata address, and can the client fetch it?
- Authorisation server metadata: Does the metadata point to reachable authorisation and token endpoints that the client supports?
- Redirect configuration: Is the client’s redirect address registered or otherwise accepted by the identity provider?
- Audience: Was the token issued for this MCP server, rather than another API or a general application audience?
- Issuer and signature: Does the server trust the token issuer and validate the signature or introspection result correctly?
- Expiry and clock: Is the token still valid, and are the client, server and identity provider clocks sufficiently aligned?
- Scopes and consent: Did the authorisation flow request the permissions the server expects, and did the user or administrator grant them?
- Header handling: Is the access token sent in the Authorization header, and is a proxy stripping or rewriting that header?
Use a test account and a test MCP resource. Inspect metadata, status codes and token claims in a secure environment. Never paste a live access token into a ticket, chat or public debugging tool. If a token’s audience is wrong, requesting broader permissions usually will not fix the problem. Correct the resource identifier or authorisation configuration instead.
Also distinguish a 401 from a 403. A 401 generally indicates that authentication is missing or unacceptable. A 403 generally indicates that the caller has been authenticated but is not permitted to perform the requested action. Exact responses depend on the implementation, so use server-side logs to confirm the actual failure reason without recording the bearer token itself.
Can I use an OpenAI or Anthropic API key to authenticate an MCP server?
No, an OpenAI or Anthropic API key authenticates an application to a model provider, not a user or workload to an MCP tool server. The MCP server needs a credential that authorises access to the systems and data exposed through its tools.
Keep these credentials separate. A model-provider key belongs in the model runtime or a managed secret store used by that runtime. An MCP access token belongs to the client-to-MCP connection. A downstream API token belongs to the MCP server or gateway when it calls that backend. Each credential should have a clear owner, purpose, audience and revocation path.
This separation helps avoid accidental credential exposure. Do not include provider keys in a prompt, tool argument, server response or client-side bundle. Do not let a model choose which credential to attach to a request. The host application should manage credentials outside the model’s control and expose only approved tool operations.
If you are evaluating an integration, ask the vendor or internal team to show where each credential is stored, which component can read it, what it can access and how it is rotated. A diagram that labels one box simply as API key is not enough for an enterprise security review.
How should MCP authentication support audit and Australian compliance?
MCP authentication supports audit when the architecture records who initiated a tool call, which agent or service executed it, what resource was targeted and what decision was made. Authentication alone does not establish that the system meets an Australian regulatory or privacy obligation. That depends on the data, business activity, control environment and applicable rules.
For teams subject to APRA requirements, including CPS 234 or CPS 230 where applicable, treat MCP as part of the information and operational technology environment. Work with your risk and compliance owners to map the relevant controls to identity, access, third-party dependencies, incident response and change management. This article is technical guidance, not legal or regulatory advice.
For a useful audit record, capture the user or workload identity, agent identity, MCP server, tool name, policy decision, target system, timestamp, correlation identifier and outcome. Record the reason for a denial where it helps investigation. Avoid storing full prompts or returned records by default. Logs should contain enough information to investigate a sensitive action while limiting unnecessary exposure of personal or confidential information.
Test the end-to-end path, not just the login screen. Verify that a user who loses access to a source system also loses the ability to perform the corresponding action through the agent. Check that revoked credentials stop working, that a backend does not accept a token for another audience and that audit records still identify the human initiator when a gateway is involved.
For regulated financial services or insurance teams, our pages on AI for financial services and AI for insurance provide more context on applying AI controls in those settings.
What should an enterprise MCP authentication checklist include?
An enterprise MCP authentication checklist should cover identity, token boundaries, action policy, operations and failure testing. Treat these as design gates before exposing production tools to agents.
Identity and registration
- Identify each human client, automated workload, MCP server and backend system.
- Confirm whether the client uses pre-registration, supported metadata documents or an approved registration process.
- Use an interactive user flow for user-delegated access and a workload identity for unattended jobs.
- Separate development, test and production identities.
Token handling
- Validate issuer, audience, expiry and required permissions.
- Use a token intended for the MCP resource, not an unrelated API.
- Do not forward inbound tokens to downstream services.
- Use token exchange or another explicitly approved mechanism for delegated backend access.
- Keep credentials out of prompts, tool outputs, logs and URLs.
Tool authorisation
- Define which users and workloads may call each tool.
- Evaluate sensitive parameters and target records, not just broad scopes.
- Require human confirmation for actions that are destructive, high impact or difficult to reverse.
- Apply least privilege to backend credentials as well as MCP tokens.
Operations and evidence
- Centralise audit events with identity and action context.
- Monitor failed authentication, unusual call volume and policy denials.
- Define credential rotation, revocation and incident response procedures.
- Test direct backend access, gateway failure and token expiry paths.
- Review the MCP specification and identity-provider support when upgrading clients or servers.
A useful first implementation is a read-only tool with one known user group, one backend and a narrow data boundary. Prove identity propagation, revocation, audit and policy enforcement before adding write operations or more systems. Then expand by repeating the same control pattern rather than copying credentials and configuration ad hoc.
Where PADISO fits: We help teams design and build MCP servers, gateways and agent workflows with identity boundaries that match the systems they connect to. The first step is to map one high-value tool call from user or workload identity through to the backend, then identify where authorisation, token exchange and audit need to sit.
Next step: If you are planning a production agent, review your current controls with our MCP server development team or contact PADISO to discuss the architecture.