Use a user token with MCP
Audience: Integrator.
Use this procedure when your MCP client accepts a user-owned bearer token. The backend generates the token and stores only its hash.
Prerequisites
- Use an authenticated backend session for the user who will own the token.
- Use a client that accepts an
Authorizationbearer header. - Use the backend’s MCP transport endpoints under
/v1/ai/mcp.
💡
Creating an MCP token replaces the existing token for that user.Generate a token
- Sign in as the user who will own the MCP access.
- Send an authenticated request as that user:
POST /v1/users/mcp-tokenThe response returns the plaintext token once:
{
"token": "hmcp_..."
}- Copy the returned
token. Store it in the MCP client configuration.
The backend cannot return the plaintext token again because it stores only its hash.
Use the token
Configure the MCP client to send this request header:
Authorization: Bearer hmcp_...MCP transport endpoints accept this bearer token. These include the information endpoint and tool routes under /v1/ai/mcp.
Rotation behavior
- Calling
POST /v1/users/mcp-tokenagain rotates the token for that user. - After rotation, the old token stops working immediately.
- Each user has at most one active MCP token at a time.
Generate another token to revoke and replace the current access.
Verify access
- Send the configured bearer header to an MCP information or tool endpoint.
- Make sure the request succeeds for the intended user.
- When you rotate the token, update the client configuration. The previous token stops working immediately.
Notes
- The MCP information payload documents the auth format as
Bearer <user_mcp_token>. - If an MCP request uses an invalid or rotated token, the backend responds with
401 Unauthorized.
Use the tool transport reference for endpoint requirements. Use OAuth client setup when you configure an OAuth connection.
Last updated on