Aller au contenu principal

Add sign-in to your MCP server

Your MCP server exposes tools to AI assistants. When those tools act on a user's data, the assistant must sign the user in. SyAuth does that part: assistants identify themselves, your users sign in on your hosted login page and approve access, and your MCP server receives a short-lived JWT access token it verifies on its own.

Authorization server (issuer)https://api.syauth.com/e/v1/mcp
Metadatahttps://api.syauth.com/e/v1/mcp/.well-known/oauth-authorization-server
Public keys (JWKS)https://api.syauth.com/e/v1/.well-known/jwks.json
Access tokensRS256 JWT, 1 hour, audience = your MCP server URL

This follows the MCP authorization specification: protected resource metadata (RFC 9728), client ID metadata documents and dynamic client registration (RFC 7591), PKCE S256, resource indicators (RFC 8707) and the iss authorization response parameter (RFC 9207). Any MCP client using one of the two client methods works, for example Claude custom connectors. MCP server sign-in is available on every plan; signed-in users count toward your plan's user quota as usual.

1. Register your MCP server​

In the dashboard, open MCP Servers (Identity section) in the workspace whose users should sign in, then Add an MCP server:

  • Name: shown to users on the consent page, for example Acme MCP.
  • MCP server URL: the exact https address of your MCP endpoint, for example https://mcp.example.com/mcp. Assistants send it as resource, and it becomes the audience of every access token.
  • Allow new users to sign up while connecting: off by default, so only existing users of the workspace can connect.

The same operations exist in the API with the read_mcp and write_mcp token scopes.

2. Point assistants to SyAuth​

Serve this JSON from your MCP server at https://mcp.example.com/.well-known/oauth-protected-resource/mcp (path form) and at https://mcp.example.com/.well-known/oauth-protected-resource:

{
"resource": "https://mcp.example.com/mcp",
"authorization_servers": ["https://api.syauth.com/e/v1/mcp"],
"bearer_methods_supported": ["header"]
}

When a request to your MCP endpoint has no valid token, answer 401 with:

WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource/mcp"

The assistant then reads SyAuth's metadata, identifies itself (with the URL of its client metadata document, or by registering), opens SyAuth's sign-in in the user's browser and comes back with a token. You do not handle any of those steps.

3. Verify every access token​

Accept a request only when the Authorization: Bearer token is a JWT signed by SyAuth, with the right issuer, your exact URL as audience, and not expired.

Python (pip install "pyjwt[crypto]")

import jwt

ISSUER = "https://api.syauth.com/e/v1/mcp"
AUDIENCE = "https://mcp.example.com/mcp"
jwks = jwt.PyJWKClient("https://api.syauth.com/e/v1/.well-known/jwks.json")

def verify(token: str) -> dict:
key = jwks.get_signing_key_from_jwt(token)
return jwt.decode(token, key.key, algorithms=["RS256"], audience=AUDIENCE, issuer=ISSUER)
# raises jwt.InvalidTokenError: answer 401 with the WWW-Authenticate header above

TypeScript (npm install jose)

import { createRemoteJWKSet, jwtVerify } from 'jose'

const JWKS = createRemoteJWKSet(new URL('https://api.syauth.com/e/v1/.well-known/jwks.json'))

export async function verify(token: string) {
const { payload } = await jwtVerify(token, JWKS, {
issuer: 'https://api.syauth.com/e/v1/mcp',
audience: 'https://mcp.example.com/mcp',
algorithms: ['RS256'],
typ: 'at+jwt',
})
return payload // throws on any invalid token: answer 401
}

Never accept a token whose audience is another URL: it was issued for another server.

Token claims​

ClaimValue
isshttps://api.syauth.com/e/v1/mcp
audYour MCP server URL
subThe user's SyAuth ID: use it as your user key
emailThe user's email
workspace_idThe SyAuth workspace of the user
client_idThe assistant that obtained the token
scopeopenid profile email
exp, iat, nbf, jtiStandard JWT times and ID; tokens last 1 hour

Assistants renew tokens with a refresh token valid 30 days, without asking the user again. Each renewal returns a new refresh token and stops the old one. A refresh is refused once the user is deactivated or the MCP server is disabled or deleted.

4. Test it​

Add your MCP server URL to an MCP client that supports OAuth, for example a custom connector in claude.ai or the MCP Inspector. You should see your hosted login, then a consent page naming the assistant and your MCP server, then your tools.

Good to know​

  • Disabling an MCP server in the dashboard stops new sign-ins and revokes refresh tokens. Access tokens already issued remain valid until they expire, at most 1 hour.
  • Accounts served from a custom user database cannot sign in to MCP servers yet.
  • Assistants appear as separate connections per MCP server; their registrations never count toward your plan's application quota.
  • An assistant that identifies itself with a client metadata document is shown on the consent page with the host of that document, for example Claude (claude.ai): the name alone is the assistant's own claim. SyAuth reads these documents from public https addresses only, without following redirects.