Skip to content
gist.link ↗

MCP authentication

Every request to the MCP server carries an access token whose audience (aud) is mcp:

POST https://mcp.gist.link/mcp
Authorization: Bearer <access token, aud=mcp>

There are two ways to get one:

Path Who it’s for Acts as How
One-click OAuth People using Claude, ChatGPT, Cursor, VS Code, Claude Code You, in the organization you pick Standard MCP authorization (OAuth 2.1 + PKCE + dynamic client registration). Your client does it all.
IAM token Agents, scripts, backends, hosted model APIs An IAM user in your organization client_credentials exchange of an IAM key with audience=mcp.

An aud=mcp token is a gateway credential: product APIs reject it. The MCP server turns it into short-lived per-app tokens through a token exchange.

GistLink implements the MCP authorization specification (protocol version 2025-06-18), so compliant clients discover everything from the MCP URL alone.

A request without a valid token is rejected with a pointer to the server’s protected-resource metadata (RFC 9728):

POST /mcp HTTP/1.1
Host: mcp.gist.link
Content-Type: application/json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{…}}
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.gist.link/.well-known/oauth-protected-resource"
GET /.well-known/oauth-protected-resource HTTP/1.1
Host: mcp.gist.link
{
"resource": "https://mcp.gist.link/mcp",
"authorization_servers": ["https://auth.api.gist.link"],
"bearer_methods_supported": ["header"],
"scopes_supported": ["mcp"],
"resource_documentation": "https://developers.gist.link/mcp/overview/"
}

The client then reads the authorization server’s metadata (RFC 8414):

GET /.well-known/oauth-authorization-server HTTP/1.1
Host: auth.api.gist.link
{
"issuer": "https://auth.api.gist.link",
"authorization_endpoint": "https://auth.api.gist.link/oauth/authorize",
"token_endpoint": "https://auth.api.gist.link/oauth/token",
"registration_endpoint": "https://auth.api.gist.link/oauth/register",
"revocation_endpoint": "https://auth.api.gist.link/oauth/revoke",
"jwks_uri": "https://auth.api.gist.link/.well-known/jwks.json",
"response_types_supported": ["code"],
"grant_types_supported": [
"authorization_code",
"refresh_token",
"client_credentials",
"urn:ietf:params:oauth:grant-type:token-exchange"
],
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["none", "client_secret_post", "client_secret_basic"],
"scopes_supported": ["mcp"]
}

The same fields are also published in /.well-known/openid-configuration. Locally, substitute http://localhost:8028 for the MCP server and http://localhost:8001 for the authorization server.

Clients register themselves (RFC 7591). Registration creates a public client — no secret is issued; PKCE protects the flow instead.

POST /oauth/register HTTP/1.1
Host: auth.api.gist.link
Content-Type: application/json
{
"client_name": "Claude",
"redirect_uris": ["https://claude.ai/api/mcp/auth_callback"],
"token_endpoint_auth_method": "none",
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"]
}
HTTP/1.1 201 Created
{
"client_id": "gcmcp_6Jw1x0…",
"client_name": "Claude",
"redirect_uris": ["https://claude.ai/api/mcp/auth_callback"],
"token_endpoint_auth_method": "none",
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"]
}

Redirect URIs must be https://, http:// on a loopback host (localhost, 127.0.0.1, [::1]) for desktop tools, or a custom app scheme such as cursor:// or vscode://. Optional client_uri and logo_uri must be https://; the logo is shown on the consent screen. Registration is rate-limited per IP.

The client opens the browser at the authorization endpoint with a PKCE S256 challenge and the MCP server as the resource:

https://auth.api.gist.link/oauth/authorize
?response_type=code
&client_id=gcmcp_6Jw1x0…
&redirect_uri=https%3A%2F%2Fclaude.ai%2Fapi%2Fmcp%2Fauth_callback
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256
&scope=mcp
&state=af0ifjsldkj
&resource=https%3A%2F%2Fmcp.gist.link%2Fmcp

GistLink then shows its own consent screen at https://auth.gist.link:

  1. Sign in if you aren’t already — including two-factor authentication. Your password never reaches the AI client.
  2. Review the request. The screen shows the client’s name, logo and redirect host, and the account you’re signed in as.
  3. Pick an organization. The connection acts inside exactly one of your organizations. To use another, connect again.
  4. Approve or deny. Approving grants: Read and change data in the GistLink apps you can access, as you. Denying returns error=access_denied to the client.

On approval you’re redirected to the client with a single-use code (valid for 60 seconds) and the original state.

The client redeems the code with its PKCE verifier:

Terminal window
curl https://auth.api.gist.link/oauth/token \
-d grant_type=authorization_code \
-d code=SplxlOBeZQQYbYS6WxSbIA \
-d redirect_uri=https://claude.ai/api/mcp/auth_callback \
-d client_id=gcmcp_6Jw1x0… \
-d code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk \
-d resource=https://mcp.gist.link/mcp
{
"access_token": "eyJhbGciOiJSUzI1NiIs…",
"token_type": "Bearer",
"expires_in": 900,
"refresh_token": "Xq3v9yTbN0kR…",
"scope": "mcp"
}

The access token is a normal GistLink user token (your sub, the chosen org, your roles) with aud=mcp. The refresh token rotates: each refresh returns a new one and invalidates the old, and refreshed tokens stay aud=mcp. Codes are single-use — replaying one revokes every token issued from it.

  • From the AI client: disconnecting or removing the connector deletes its stored tokens.
  • From GistLink: open Settings → Security → AI connections (https://settings.gist.link/dashboard/security/ai-connections). Every approved app is listed with its organization, connection date and last use; Disconnect kills its refresh-token chain immediately and the app must go through consent again. The same data is available programmatically as myOAuthConnections and revokeOAuthConnection(id) on the auth API.
  • Account changes apply immediately: removing a member from the organization, deactivating or locking the account, or blocking the mcp app makes the next per-app token exchange fail.

An already-issued access token stays valid until it expires (minutes), but it’s useless on its own — every tool call needs a fresh per-app exchange, which re-checks the account.

For unattended use, create an IAM user with the grants the agent needs (see the Quickstart), issue a key, and exchange it with audience=mcp:

Terminal window
curl https://auth.api.gist.link/oauth/token \
-u 'gciam_your_key_id:gcsk_your_secret' \
-d grant_type=client_credentials \
-d audience=mcp
{
"access_token": "eyJhbGciOiJSUzI1NiIs…",
"token_type": "Bearer",
"expires_in": 900,
"scope": "crm:query:* support:query:tickets support:mutation:createTicket"
}

Send it as Authorization: Bearer … to the MCP server. How it differs from a product token:

  • All apps, one token. A product token is filtered to one app; an aud=mcp token carries the key’s full effective grants across every app (still the intersection of the key’s and its IAM user’s grants).
  • Grants shape the tool list. The MCP server only lists and allows the operations your grants cover, using the normal permission grammar with final-segment wildcards. A key holding only crm:query:* sees CRM read tools and nothing else.
  • No refresh token. Re-run the exchange when it expires — it’s how revocations and narrowed grants take effect.

The MCP server never forwards your aud=mcp token to a product API. For each app it needs, it performs an RFC 8693 token exchange at the auth service, authenticating as GistLink’s own first-party MCP service client:

POST https://auth.api.gist.link/oauth/token
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
subject_token=<your aud=mcp token>
subject_token_type=urn:ietf:params:oauth:token-type:access_token
audience=crm
{
"access_token": "eyJhbGciOiJSUzI1NiIs…",
"token_type": "Bearer",
"expires_in": 600,
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token"
}

The exchange is the security boundary, and it only ever narrows:

  • Only the GistLink MCP service may use this grant — third parties can’t.
  • The subject token must be valid and have aud=mcp; the target must be a product app (never auth or mcp).
  • User subjects: your account and membership are re-loaded now. Inactive, locked or removed ⇒ refused. If the target app is blocked for you ⇒ refused. The derived token carries your current roles in the same organization.
  • IAM subjects: the IAM user and key are re-loaded now. Revoked, expired or disabled ⇒ refused. The derived token holds only your current grants for that app (crm:…); none ⇒ refused.
  • The derived token never outlives the subject token and has no refresh token. Every exchange is written to the audit log.

The MCP server caches derived tokens in memory until shortly before they expire, so a busy session doesn’t exchange on every call.

Situation What the client sees
No token, expired token, or a token for another audience HTTP 401 with WWW-Authenticate: Bearer resource_metadata="…" — OAuth clients re-authenticate automatically.
Account/membership/key no longer valid at exchange time A tool error asking you to reconnect (OAuth) or re-mint (IAM).
App blocked for you, or no IAM grants for that app A tool error naming the app; the tool is hidden for IAM tokens.
Missing permission for one operation A tool error naming the required permission, e.g. pay:mutation:createInvoice.

Token-endpoint errors (invalid_client, invalid_grant, invalid_target, invalid_scope) follow Errors & rate limits.