MCP & ChatGPT apps guide
MCP server authentication: an OAuth 2.1 guide for SaaS teams
Updated 2026-10-26
Short answer: A remote MCP server is an OAuth resource server. It advertises its authorization server via protected resource metadata, returns 401 with a WWW-Authenticate header, and validates access tokens issued for it. The client handles the PKCE flow.
The flow
- The client calls your MCP endpoint without a token and gets 401 with a resource_metadata link.
- It reads /.well-known/oauth-protected-resource to find your authorization server.
- It reads the authorization server metadata and registers itself (client ID metadata document or dynamic client registration, depending on spec version and your provider).
- The user signs in and consents; the client exchanges the code with PKCE.
- Every MCP request carries Authorization: Bearer <token>; you validate issuer, audience (your resource URL), expiry and scopes.
Protected resource metadata
GET /.well-known/oauth-protected-resource
{
"resource": "https://mcp.acme.com/mcp",
"authorization_servers": ["https://auth.acme.com"],
"scopes_supported": ["invoices:read", "invoices:write"]
}
# Unauthenticated request to /mcp returns:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.acme.com/.well-known/oauth-protected-resource"Practical choices
- Reuse your existing identity provider (Auth0, Clerk, WorkOS, Cognito, Keycloak) if it supports the needed metadata and registration.
- Map scopes to tool groups, such as invoices:read for read tools and invoices:write for writes.
- Never pass the MCP access token straight through to your upstream API unless it was issued for it; exchange it or call with your own service credentials scoped to that user.
- Short-lived access tokens, refresh tokens, and a way for users to revoke the connection.
For a pilot
Use stdio and an API key in an env variable. It is fine for a developer audience and lets you validate tools before investing in OAuth.
Cofounderbase build service
Get a free 2-minute demo of your product in Claude
Besides running this directory, our team builds MCP servers and ChatGPT apps for small SaaS. Send your product URL and we'll record a short video of it working inside Claude, built only from your public API docs. Free, no call needed. Pilots start at $1,500. This service is separate from the agency rankings, which it never affects.
Prefer email? Write to us. Want an outside agency instead? See agencies that do MCP work.
Agencies in our index that mention MCP work
Listed in their normal directory order. Our own build service is not part of this list or the rankings.
- Teamvoy (Ukraine)
- AiAdvisors (Poland)
- Context Studios (Germany)
- AI Agency Manchester (United Kingdom)
- Focused (United States)
- Autor Technologies (Canada)
- Pentridge (United States)
- Hourglass AI (Australia)
- Enabled Minds (United States)
- AppStream Studio (United States)
Questions
Do I need dynamic client registration?
Clients need some way to register. Depending on the spec version, that is a client ID metadata document, dynamic client registration, or a pre-registered client. Check what your target clients support.
Can I use API keys for a remote server?
Technically yes, but users then paste secrets into an AI client. OAuth is the expected pattern for multi-user remote servers.
What is the most common bug?
Not checking the token audience, which lets tokens issued for another service work on yours.
More MCP guides
- How to build an MCP server for your SaaS product
- How to add a ChatGPT app to your SaaS
- MCP server development cost: what SaaS teams pay (estimates)
- MCP vs API: what SaaS teams actually need
- MCP server for a REST API: generate from OpenAPI or hand-write?
- MCP server security and rate limiting checklist
- How to publish an MCP server: official registry, Smithery and awesome lists
- MCP server for CRM SaaS: tools, risks and scope
- MCP server for billing and subscription SaaS
- MCP server for scheduling and booking SaaS
- MCP server for healthcare SaaS: what is safe to build first
- MCP server for helpdesk and support SaaS
- Open-source example: Canny MCP server
Cost and effort figures on this page are rough estimates, not quotes.