The flow
1
The first request gets a 401
A request to
https://mcp.langmail.me/mcp without a bearer token returns 401 with a pointer to the resource metadata:Response header
2
Discover the protected resource
Request
Response
3
Discover the authorization server
Request
Response
auth.langmail.me. Clients only need to follow the endpoints in this document.4
Register as a client
The registration endpoint accepts dynamic client registration (RFC 7591) without prior credentials, rate-limited per IP. MCP clients typically register as a public client with a loopback redirect:Redirect URIs are matched exactly at authorization time, so register the precise URI you will use, including the port.
Registration request
5
The user signs in and consents
The client opens the authorization URL with a PKCE challenge:A client that sends no
scope asks for openid email offline_access, the same scopes the challenge and metadata advertise.A user without a session is sent to the Langmail login page first (Google sign-in is optional). Then a consent screen shows what the named client is asking for; approving redirects back to the client’s redirect_uri with an authorization code. Every dynamically registered client goes through consent — there are no silent grants.6
Exchange the code for tokens
Request
access_token and, because offline_access was granted, a refresh_token. Public clients send no client secret; the PKCE verifier binds the exchange to the client that started the flow.7
Call the MCP server
Request header
@langmail.me mailbox. Every tool call then operates on that mailbox — tokens are per-user, and a token can never reach another user’s mail.Tokens
- Access tokens are opaque — treat them as bearer credentials, not as JWTs to inspect.
- Refresh tokens are issued when
offline_accessis granted, so clients can stay connected without re-prompting you to sign in. - Ending access: every agent you connected is listed under Access with the scopes you granted. Revoke deletes its tokens and your consent, so it cannot refresh and has to connect again. An agent that is running can keep working for up to an hour after the revoke. Removing the server from your MCP client discards its tokens as well.
Requirements on the user
The signed-in account must belong to a Langmail user with an active@langmail.me mailbox. Accounts without one are rejected at the MCP server with 401 invalid_token — sign up at app.langmail.me first.
Authorization gives a client access to the tools the server exposes for your mailbox — currently read access to mail and read-write access to calendars. See the tool reference for the exact surface.