Overview
MCP clients use OAuth authorization-server metadata, Dynamic Client Registration, PKCE, token exchange, introspection, and revocation endpoints.@grantex/mcp-auth registers those six routes on a Fastify instance and provides
Express and Hono JWT-verification middleware.
Current published release: @grantex/mcp-auth@2.0.2.
The supplied
Grantex client can point at Grantex Cloud or a self-hosted
Grantex API. That backend choice does not make the MCP authorization server’s
own client-registration or authorization-code state managed or durable.Deployment behavior in 2.0.2
Quick Start
The following starts the published endpoint surface for local inspection and evaluation. It does not remove the limitations above.1. Create the auth server
2. Protect your MCP routes
Use the Express or Hono middleware to validate tokens on every request:3. Verify it works
MCP clients discover your auth server automatically:Endpoints
createMcpAuthServer() registers six endpoints on the Fastify instance:
Well-Known Metadata
The metadata endpoint returns a JSON document that MCP clients use to discover all other endpoints:Token Introspection
The endpoint verifies JWT signatures and claims against the issuer JWKS. In2.0.2 it does not query Grantex for current revocation state, so a revoked but otherwise valid token can remain active here until expiry:
Token Revocation
The revocation endpoint decodes the tokenjti and requests revocation from Grantex. It returns 200 OK even if that backend call fails, and the package middleware/introspection paths do not consult the resulting revocation state:
200 OK, even if the token was already revoked.
Scope Definition
Define the scopes your MCP server supports when creating the auth server:2.0.2:
- Authorization request: The package forwards the requested scopes to the configured Grantex client.
- Middleware:
requireMcpAuth()rejects tokens that lack required scopes.
Consent metadata (not a rendered page)
consentUi copies display metadata into the discovery document under
grantex_extensions.consent_ui_config:
Lifecycle hooks
Onlyhooks.onRevocation is invoked by 2.0.2:
onTokenIssued, but the token
endpoint in 2.0.2 does not call it. Do not depend on that hook until a corrected
release is published.
Express Middleware
Express and Hono middleware verify JWT signatures, claims, algorithms, and
configured scopes. They do not perform an online revocation check in
2.0.2.requireMcpAuth(options)
McpGrant (decoded token claims)
Hono Middleware
Custom Client Store
By default, client registrations are stored in process memory. A customClientStore can persist registrations, but authorization codes remain in a non-configurable process-local store in 2.0.2; a custom client store alone does not make the server durable or horizontally scalable:
Certification Program
Grantex accepts Bronze, Silver, and Gold certification applications for registered MCP servers. Applications begin inpending_conformance_test; submission alone is not certification. See the MCP Certification Applications guide for the current API and limitations.
Configuration Reference
McpAuthConfig
Rate Limits
Default per-endpoint rate limits:Security Considerations
@grantex/mcp-auth implements the following request and token-validation controls. These controls do not remove the deployment and end-to-end flow limitations documented above:
- PKCE S256 is mandatory. The
plainmethod and implicit grant are rejected. - No password grant. The
passwordgrant type is not supported. - No implicit grant. Only
response_type=codeis accepted. - Authorization codes are single-use. Replayed codes are rejected.
- HS256 rejected. Only asymmetric algorithms (RS256, ES256, PS256, EdDSA) are accepted.
- Client secrets are generated using
crypto.randomBytes(32). - JWKS verification uses the
joselibrary with remote key set fetching and caching.
Related
- MCP Certification Applications — Application API and current limitations
- MCP Server (17 tools) — Grantex MCP server for Claude Desktop/Cursor
- Express Middleware — Grantex Express.js middleware
- Self-Hosting Guide — Deploy the full Grantex stack
- Security Best Practices — Token verification, key rotation