Start from the template
Use the Convex OAuth template for a standalone MCP server with an authenticatedwhoami tool.
MCP_USE_OAUTH_CONVEX_AUTH_URL in .env, then run npm run dev. Connect your MCP client to http://localhost:3000/mcp.
The template hosts the MCP resource server. Your Convex deployment must provide the OAuth Provider component, login, consent, and token issuance; Convex Auth alone is not sufficient.
You can also deploy the template to Manufact. Set the issuer URL in the deployment environment before starting the server. For public or tunnel deployments, set MCP_URL to the public MCP server origin, without /mcp.
Configure Convex
In your Convex deployment, set up the OAuth Provider component:- Install the Convex OAuth Provider component in your Convex project.
- Enable Dynamic Client Registration on the OAuth component so MCP clients can register automatically.
- Configure the allowed scopes for your deployment. At minimum, include
openid profile email. - Deploy your Convex project and note the base URL of your Convex site. It will look like:
Set environment variables
Configure the MCP server
Use Convex identity in tools
When a request is authenticated, tools receive the verified Convex identity onctx.auth.
Verify the setup
Run the server and connect with an OAuth-capable MCP client.- The client discovers Convex OAuth metadata from your MCP server.
- The client registers with your Convex deployment.
- Authenticated tool calls include
ctx.auth.user.id. - Tool calls without a valid bearer token are rejected.
openid profile email if the client does not send a scope by default.
Next steps
Convex OAuth template
Clone or deploy a standalone MCP server with Convex authentication.
Convex OAuth Provider component
Set up the OAuth Provider component in your Convex deployment.
User Context
Use Convex identity data inside tools.