Field report · Deep dive

Letting Claude sign in: OAuth for MCP servers in practice

A field report from VamiGRC, part 2

Getting an AI client to sign in to a remote MCP server took us longer than building the tools it calls. We connected Claude to VamiGRC, our agentic GRC platform, and went through all three ways a client can identify itself to an authorization server: a pre-registered client ID, dynamic client registration and Client ID Metadata Documents (CIMD). This field report covers what failed on the way, why we ended up making our own application the authorization server, and how we fetch a client's metadata from the internet without opening a server-side request forgery hole.

Who this is for: Teams that put business data behind a remote MCP server and want AI clients to sign in without a manual setup step.

Subject
OAuth sign-in of AI clients to the VamiGRC MCP server
Method
Three ways of client introduction, tested in practice
Verification
7 checks, all passed
Basis
MCP authorization (revision 2026-07-28) · OAuth 2.1 · CIMD
Context

Sign-in is the hard part

A local MCP server runs on the user's machine and needs no login. A remote one sits on the internet and holds other people's data, so the MCP specification makes it an OAuth 2.1 resource server.

Local or remote

Local MCP serverRuns on the user's own machine and needs no login.
Remote MCP serverSits on the internet, holds other people's data and requires a token issued for it alone.

What the specification covers

  • The client discovers the authorization server from the MCP server's protected resource metadata.
  • The user signs in with the authorization code flow and PKCE.
  • The client receives a token bound to that one MCP server as its audience.

Specification, Revision 2026-07-28: Authorization (July 2026) (opens external website) · RFC 9728: OAuth 2.0 Protected Resource Metadata (April 2025) (opens external website)

What remains open: who is this client?

The specification is clear about the flow. It is less clear about the first question every authorization server asks. An AI app is not a web app you registered yourself: it is the same client for thousands of organizations, and it arrives at your login page without having been introduced.

  • One client for many organizations
  • No prior arrangement
  • Found in directories
Client introduction

Three ways a client can introduce itself

Before the authorization server allows a sign-in, it needs to know who is asking. For AI clients there are three ways. Pick one to compare how it works, what it means for users and the risk for the server.

CIMDWhere we ended up

Client ID Metadata Document

How it works
The client ID is an HTTPS URL, and the server fetches a JSON document there that names the client and its callback addresses.
For the user
Automatic.
Risk for the server
The server fetches URLs it was given, so it must defend against request forgery.

Properties

  • Sign-in without setupYes
  • Usable from a public directoryYes
  • Anyone can create clientsNo
  • Server fetches external URLsYes

We started with the first, kept open registration switched off on purpose, and ended with the third. CIMD gives the user the automatic experience of dynamic registration without letting anyone create clients: trust comes from the HTTPS domain that publishes the document.

The MCP specification has recommended CIMD since revision 2025-11-25. Revision 2026-07-28 marks dynamic client registration as deprecated and keeps it only for backwards compatibility. Specification, Revision 2025-11-25: Key Changes (November 2025) (opens external website) · Specification, Revision 2026-07-28: Client Registration (July 2026) (opens external website)

What went wrong, part one

A failure before the login page

Our first live test ended in a generic “Authorization failed” message, before any login page appeared.

Ruled out first

  • The metadata path
  • The issuer
  • The token endpoint's authentication methods
  • The browser

Found, one after the other

  1. 1

    Registration was attempted

    The connector had been created with automatic registration selected, and our identity provider refuses anonymous registration.

    Fix: Set the pre-registered client ID. That fixed this path, but the error stayed.

  2. 2

    One missing scope

    The AI client requests offline_access so it can stay connected with refresh tokens. Our client did not allow that scope, so the authorization request was refused outright, and the client reported it as a generic failure.

    Fix: Allowed offline_access as an optional scope.

What settled it was checking the identity provider's side of the exchange, not the client's message. When a client fails before the login page, compare the scopes it requests with the scopes the client may receive.

What went wrong, part two

“Login expired” and moving the authorization server

Our first design kept the identity provider in the middle. That avoided token passthrough, but it made the connection depend on the user's session at the identity provider.

First design: identity provider in the middle

  1. Sign-inThe user signs in on an internal-looking identity domain, not on our product.
  2. MCP serverIt exchanges the user's token at the identity provider for a short-lived backend token, so the agent never holds a token the backend accepts directly.
  3. After a short idle periodThe identity provider's online session ends. The AI client keeps refreshing its own token with an offline refresh token that lasts for days.
  4. ExchangeThe identity provider refuses the exchange, and nothing is written to our logs. The user sees “login expired” until they disconnect and connect again.

The connection depended on the identity provider's online session.

Today: the application is the authorization server

  1. Sign-inThe user signs in on the product's own page, with its usual login methods.
  2. ConsentOn the same page, they decide whether the assistant may read, or read and change.
  3. TokenThe application issues tokens for the MCP server directly.
  4. ResultThere is no exchange left to fail.

No exchange left to fail.

Token design

Short-lived tokens, firm responses to misuse

Every choice in the token design has a reason. The table shows our choices, the simulator below shows what happens in typical situations.

Token design of the VamiGRC MCP server
ElementOur choiceWhy
FlowAuthorization code with PKCE, S256 onlyNo secrets in the client, and a stolen code is useless without the verifier.
Authorization codeSingle use, and a replayed code ends the connection it createdA replay means someone else saw the code.
Access token10 minutes, audience bound to the MCP serverA leaked token expires quickly and works nowhere else.
Refresh tokenRotates on every use, and reusing an old one ends the whole connectionDetects a stolen refresh token the moment either side uses it twice.
Connection lifetimeEnds after 14 days unused, and after 90 days at the latestForgotten connections do not stay open forever.
ScopeRead, or read and change, chosen on the consent pageThe person decides how much the assistant may do.
What the token can reachThe public API only, never more than the person's own roleThe agent never gets more than the person.

What happens if …?

Pick a situation. The simulator shows how the authorization server responds under the design described above.

Situation

Response

Refused or ended

An old refresh token is used again after rotation

Refused, and the whole connection ends. It does not matter who used the token first: the second use gives the theft away.

PassedVerified: Old refresh token reused after rotation

CIMD in practice

Fetching a document without opening a door

A pre-registered client ID works, but a user who finds a connector in a public directory cannot be asked to type one. With CIMD, the client ID itself is an HTTPS URL: the authorization server fetches the JSON document behind it, checks it, and trusts the redirect addresses it names. That makes the authorization server fetch URLs chosen by whoever starts a login, which is the textbook setup for server-side request forgery (SSRF).

Seven rules for the fetch

  1. 01

    An allowlist of hosts

    Only documents from known AI clients are accepted. Anything else is an unknown client, not a fetch.

  2. 02

    No private addresses

    Private, loopback and link-local addresses are refused after DNS resolution, and the connection is pinned to the address that was checked, so a second DNS answer cannot swap it.

  3. 03

    HTTPS only, no redirects

    A redirect could point anywhere, so it is refused instead of followed.

  4. 04

    Small and fast

    A 5-second timeout and a 10 KB size cap.

  5. 05

    Checked strictly

    The document's client ID must equal its own URL, and it must declare no client secret.

  6. 06

    Exact redirect addresses

    Redirect addresses must match exactly. The only exception is a desktop client's loopback callback, where the port may vary.

  7. 07

    Named honestly

    The consent page shows the verified host the document came from, not only the name the document claims.

Cached, both ways

Accepted and refused documents are cached for a limited time, so a login does not trigger a fetch every time.

Off in one step

The feature sits behind a setting, so it can be switched off in one step, and clients registered the old way keep working when it is.

CIMD checker

Pick a request. The checker shows whether the authorization server accepts it or at which rule it refuses it. All hosts are examples.

Request

client_id=https://client.example/oauth/metadata.json

  1. An allowlist of hostspassed
  2. No private addressespassed
  3. HTTPS only, no redirectspassed
  4. Small and fastpassed
  5. Checked strictlypassed
  6. Exact redirect addressespassed
  7. Named honestlypassed

Accepted

All rules passed. The consent page names the verified host client.example.

Among other things, the IETF CIMD draft requires servers not to follow redirects automatically when fetching, not to fetch special-use addresses and to match redirect addresses exactly. It recommends showing the client ID's hostname on the consent page. OAuth Client ID Metadata Document (Internet-Draft, draft-ietf-oauth-client-id-metadata-document-03) (November 2026) (opens external website) · Server-Side Request Forgery Prevention Cheat Sheet (opens external website)

Verification

Seven checks, all passed

We checked the design against the cases that matter: replayed codes and tokens, real clients, mismatched certificates and unknown redirect addresses.

Checks of the OAuth sign-in
CheckExpectedResult
Authorization code used twiceRefused, and the connection it created is endedPassed
Old refresh token reused after rotationRefused, and the whole connection is endedPassed
Desktop client signing in through its metadata documentConnected without a client ID typed by handPassed
Hosted client's real metadata documents fetched liveBoth acceptedPassed
Certificate that does not match the hostRefusedPassed
Request with an unverified redirect addressRefused before any loginPassed
Malformed list of registered clientsA named configuration error, not a crashPassed

A test that passes for the wrong reason

The certificate test deserves a note: a first attempt seemed to pass a mismatched host, but only because both hosts shared a content delivery network with valid certificates. Pointing the request at an unrelated server whose certificate could not match proved the check.

A security test that passes for the wrong reason is worse than one that fails.
Lessons

What we would do differently

Four things we would do differently. Below them: the report's key takeaways and its limits.

01

Start with the application as the authorization server

The detour through token exchange cost us weeks of “login expired” and a debugging session without logs.

02

Plan for CIMD from day one

A pre-registered client ID is fine for a pilot, but a public listing needs automatic sign-in.

03

Log every refusal before the first live test

A refused sign-in or exchange that writes nothing is the slowest kind of bug to find.

04

Test with the real AI client early

Our own test scripts passed while the real client failed on a scope it requests that the scripts never asked for.

Key takeaways

  1. 1Decide how clients introduce themselves first.It shapes the user experience, the attack surface and whether a public listing is possible at all.
  2. 2Prefer CIMD over open registration.Users get automatic sign-in, and nobody can create clients on your server.
  3. 3Treat every metadata fetch as untrusted.Allowlist hosts, refuse redirects and private addresses, pin the checked address, and cap time and size.
  4. 4Log the reason for every refused sign-in or exchange.Our hardest bug was invisible because a refusal wrote nothing.
  5. 5Watch the scopes.One scope the client requests but may not receive can fail the whole login before the user sees a page.
  6. 6Tell users where access really ends.Removing a connector in the AI app may leave its tokens alive, so say where to end it.

Limits

  • CIMD is young.Few authorization servers support it yet, and client support differs. We accept documents from a short allowlist of hosts and will widen it client by client, after testing each one.
  • Trust moves to a domain.With CIMD you trust whoever controls the domain that publishes the document. That is a reasonable trade for well-known AI clients, not for arbitrary ones.
  • Revocation depends on the client.If an AI app does not call the revocation endpoint when a user removes it, access lasts until the user ends it in the product or the connection expires.
  • Login security is only half the story.A valid sign-in still lets the agent act as the person. What it may do once signed in is the subject of our first field report.
Sign-in check

How safely do AI clients sign in to your MCP server?

Eleven questions from the field report. Answer all of them to get an assessment.

  1. 01Have you decided how AI clients introduce themselves to your authorization server: pre-registered, through dynamic registration or through CIMD?
  2. 02Is open dynamic registration switched off or limited by policies?
  3. 03Does your authorization server accept PKCE with S256 only?
  4. 04Are access tokens short-lived and bound to your MCP server as their audience?
  5. 05Is every authorization code single use, and does a replay end the connection it created?
  6. 06Do refresh tokens rotate on every use, and does reusing an old one end the whole connection?
  7. 07Do unused connections end after a fixed period, and all connections after a maximum lifetime?
  8. 08Does your authorization server fetch no external URLs at all, or only with a host allowlist, no redirects or private addresses, pinning to the checked address, and time and size caps?
  9. 09Does every refused sign-in and every refused exchange log a reason?
  10. 10Have you tested the sign-in with the real AI client, including the scopes it requests?
  11. 11Can users end connections in the product, and do you tell them that removing the connector in the AI app is not enough?

Answered: 0/11

The check does not replace an assessment or a penetration test. Your answers are neither stored nor transmitted.

Classification

What the standards require

The report builds on the MCP specification and the OAuth standards. This is how its decisions map to them.

MCP 2026-07-28

MCP authorization (opens external website)

The standard

Requires protected resource metadata, PKCE with S256 and tokens bound to the MCP server. Recommends CIMD; dynamic client registration is marked as deprecated.

Our implementation

Discovery through protected resource metadata, PKCE with S256 only, tokens bound to the MCP server, CIMD instead of open registration.

CIMD draft-03

OAuth Client ID Metadata Document (opens external website)

The standard

Client ID as an HTTPS URL, the document's client ID equal to that URL, no client secret, no automatically followed redirects, no special-use addresses, exact redirect addresses.

Our implementation

Seven rules for the fetch, including an allowlist of hosts and the verified host shown on the consent page.

RFC 7009

OAuth 2.0 Token Revocation (opens external website)

The standard

Defines how a client tells the authorization server that a token is no longer needed.

Our implementation

The AI app did not call the endpoint when it was removed, so the product names the place where access ends.

This classification summarizes the standards in brief and does not replace their wording. Basics: MCP and OAuth 2.1

Whitepaper · free

Letting Claude sign in – OAuth for MCP servers: a guide for CISOs

The field report prepared for decision-makers: registration paths and CIMD, two lessons from debugging, token design and revocation, seven rules for an SSRF-resistant metadata fetch, a test plan for acceptance, questions for vendors and a 30-60-90-day plan.

Cover of the whitepaper “Letting Claude sign in – OAuth for MCP servers: a guide for CISOs”
PDF · 25 pagesGerman & EnglishAuthor: Houssem Bouarada
  • Ten key messages for the board and internal audit
  • Decision guide: pre-registration, CIMD or dynamic registration
  • Token design and seven rules for fetching client metadata
  • Test plan, vendor questions and a 30-60-90-day plan
Free Download

Request Whitepaper

Letting Claude sign in – OAuth for MCP servers: a guide for CISOs

Language version *
Support

From the field report to your MCP server

We review sign-in to MCP servers the way this report describes: client introduction, token design, metadata fetch and tests with real clients.

Houssem Bouarada
Author

Houssem Bouarada

Security Researcher, Vami Research

Houssem Bouarada is a security researcher at Vami Research. He focuses on offensive security and on securing AI-assisted tools such as MCP servers.

Ask the author
Keep exploring

Related research

Deep dives 7

Securing an MCP server in practicePart 1 shows what the agent may do once signed in: approvals, autonomy and tenant boundaries in the backend.Zero Trust for AI AgentsAutonomous AI agents act with legitimately granted privileges at machine speed. Zero Trust transfers proven principles — verify instead of trust, Least Privilege, assume breach — to agentic systems.OWASP Agentic Top 10The ten key security risks of autonomous AI agents – from Agent Goal Hijack to Rogue Agents – based on the official OWASP publication (version 2026, December 2025).Privileged Access ManagementPrivileged accounts are the shortest path to compromising entire environments. PAM governs their provisioning, use and monitoring across governance, architecture and operations - VamiSec supports design, rollout and ongoing operation.MCP & OAuth 2.1Since the June 2025 specification revision, a protected MCP server is an OAuth 2.1 resource server with clearly separated roles. This deep dive explains the discovery chain, client registration, token rules and audience binding – and shows where implementations fail in practice.Best PracticesThe Security Best Practices of the official MCP specification are not a menu of options but concrete requirements. We translate them into a verifiable security architecture for your MCP-Servers and -Clients.Secure Server DevelopmentMCP-Servers connect AI assistants to tools and data sources and thereby become an attack target themselves. We support architecture, Tool design, authentication, and deployment along established security guidelines.

Frequently asked questions

Short answers

What is a Client ID Metadata Document (CIMD)?

A JSON document that an OAuth client publishes at an HTTPS URL. That URL is also its client ID. The authorization server fetches the document during sign-in, checks that the client ID in it equals the URL, and takes the name and redirect addresses from it. This lets a client introduce itself without prior registration. The IETF is developing the mechanism as an Internet-Draft, and the MCP specification has recommended it since revision 2025-11-25.

Why not simply use dynamic client registration?

Because it lets anyone create clients on your authorization server, which stays safe only with additional policies. CIMD offers the same automatic sign-in without letting anyone create clients on your server: trust comes from the domain that publishes the document. MCP revision 2026-07-28 marks dynamic client registration as deprecated and keeps it only for backwards compatibility.

Does the application have to be the authorization server itself?

No, the MCP specification also allows a separate authorization server. We chose the application because the token exchange through the identity provider depended on its online session and users saw “login expired”. It also means users sign in on the product's own page. The application now issues tokens for the MCP server directly, so there is no exchange left to fail.

Why did sign-in fail before the login page?

For two reasons: the connector attempted automatic registration, which our identity provider refuses for anonymous clients, and the AI client requested the offline_access scope, which our client was not allowed to receive. The authorization request was therefore refused outright, and the client only reported “Authorization failed”. What settled it was the identity provider's side of the exchange, not the client's message.

Does access end when I remove the connector in the AI app?

Not necessarily. In our case the AI app kept its tokens, reconnected silently the next time it was added and did not call our revocation endpoint. End access in the product instead. In VamiGRC, a connection also ends after 14 days unused and after 90 days at the latest.

How do you prevent server-side request forgery when fetching metadata documents?

By treating every fetch as untrusted: allowlisted hosts only, HTTPS only, no redirects, no private, loopback or link-local addresses after DNS resolution, the connection pinned to the checked address, a short timeout and a size cap. Among other things, the IETF CIMD draft requires servers not to follow redirects automatically and not to fetch special-use addresses.

Does this only apply to Claude?

No. The report describes connecting Claude to VamiGRC, but the mechanisms come from the MCP specification and the OAuth standards. They apply to every MCP client that signs in to a remote MCP server with OAuth. We add new clients to our allowlist only after testing each one.

Let AI clients sign in without opening new doors

We review the authorization, token design and metadata fetch of your MCP server like an attacker and show where a sign-in allows more than it should.