@grantex/mcp-auth — GA Release

Your MCP Server Needs
Real Authorization.

Drop-in OAuth 2.1 + PKCE authorization for any Model Context Protocol server. Human consent, scoped access, instant revocation, and a full audit trail — in under 10 lines of code.

npm install @grantex/mcp-auth Copy
OAuth 2.1 + PKCE RFC Compliant 15 min setup Self-host or Managed Apache 2.0
Most MCP servers ship without real auth.

API keys and hardcoded JWTs are fine for demos. For production, you need consent, scoped permissions, revocation, and an audit trail.

Capability API Keys Hardcoded JWT Grantex MCP Auth
Human consent flow
Scoped permissions Manual
Instant revocation Rotate key
Audit trail
RFC standard Partial
Dynamic Client Registration
Token introspection
MCP Spec compliant
Six RFC-compliant endpoints, one function call.

createMcpAuthServer() registers everything an MCP client needs to discover, register, authorize, and manage tokens.

Method Endpoint RFC Description
GET /.well-known/oauth-authorization-server RFC 8414 Server metadata discovery
POST /register RFC 7591 Dynamic Client Registration
GET /authorize OAuth 2.1 Authorization (PKCE required)
POST /token OAuth 2.1 Token endpoint (code + refresh)
POST /introspect RFC 7662 Token introspection
POST /revoke RFC 7009 Token revocation
Production-ready auth in three steps.

Install the package, create the server, protect your routes. MCP clients auto-discover your auth endpoints via the well-known metadata URL.

1

Install the package

One dependency. Zero peer requirements beyond the Grantex SDK.

npm install @grantex/mcp-auth @grantex/sdk
2

Create the auth server

Define your scopes and issuer. The server handles PKCE, DCR, introspection, and revocation automatically.

import { Grantex } from '@grantex/sdk';
import { createMcpAuthServer } from '@grantex/mcp-auth';

const grantex = new Grantex({
  baseUrl: 'https://grantex-auth-dd4mtrt2gq-uc.a.run.app',
  apiKey: process.env.GRANTEX_API_KEY,
});

const authServer = await createMcpAuthServer({
  grantex,
  agentId: 'ag_your_mcp_server',
  scopes:  ['tools:read', 'tools:execute', 'resources:read'],
  issuer:  'https://your-mcp-server.example.com',
});

await authServer.listen({ port: 3001 });
3

Protect your MCP routes

Drop in the Express or Hono middleware. Every request is verified against the JWKS, scopes are enforced, and decoded grant claims are available in your handler.

import express from 'express';
import { requireMcpAuth } from '@grantex/mcp-auth/express';

const app = express();

// Protect all MCP tool routes
app.use('/mcp', requireMcpAuth({
  issuer: 'https://your-mcp-server.example.com',
  scopes: ['tools:execute'],
}));

// Decoded grant available on every request
app.post('/mcp/tools/call', (req, res) => {
  const grant = req.mcpGrant;
  console.log(grant.agentDid, grant.scopes);
  res.json({ result: 'tool executed' });
});
Get the Grantex-Auth Certified badge.

Prove your MCP server implements OAuth 2.1 correctly. Three tiers, automated conformance testing, and a listing in the Grantex MCP Registry visible to 10,000+ developers.

Bronze

Standard

  • OAuth 2.1 + PKCE S256
  • Dynamic Client Registration (RFC 7591)
  • Server metadata discovery (RFC 8414)
  • Rate limiting on token + authorize
Registry listing
Silver

Enhanced

  • All Bronze requirements
  • Token introspection (RFC 7662)
  • Token revocation (RFC 7009)
  • Consent UI customization
  • Lifecycle hooks for audit logging
Featured in registry
Gold

Production

  • All Silver requirements
  • Persistent client store
  • Resource indicators (RFC 8707)
  • Delegation support (SPEC §9)
  • Budget enforcement
  • Full conformance suite pass
Top placement + badge
Discover certified MCP servers.

Every certified server appears in the Grantex registry with its tier, scopes, and a direct install link. Users can trust that listed servers meet OAuth 2.1 requirements.

Calendar MCP Gold

Read, create, and manage calendar events. Full delegation support with budget controls for scheduling agents.

calendar:read calendar:write calendar:manage
File System MCP Silver

Sandboxed file operations with scoped directory access. Read, write, and search files within allowed paths.

fs:read fs:write fs:search
Database MCP Bronze

Read-only SQL queries against Postgres and MySQL. Schema introspection and query result formatting.

db:query db:schema
Managed or self-hosted. Same API.

Use Grantex Cloud for zero-infrastructure auth, or run the full stack on your own infrastructure. The code is identical — just point the SDK at a different URL.

Zero infrastructure

Grantex Cloud handles signing keys, JWKS hosting, and uptime.

99.9% uptime SLA

Cloud Run auto-scaling with global CDN for metadata endpoints.

SOC 2 + GDPR ready

Compliance handled on our side. Export audit logs anytime.

Free tier included

1,000 token exchanges per month. No credit card required.

const server = await createMcpAuthServer({
  grantex: new Grantex({
    baseUrl: 'https://grantex-auth-dd4mtrt2gq-uc.a.run.app',
    apiKey:  process.env.GRANTEX_API_KEY,
  }),
  agentId: 'ag_your_server',
  scopes:  ['tools:read', 'tools:execute'],
  issuer:  'https://your-domain.example.com',
});

Full data sovereignty

All tokens, keys, and audit logs stay on your infrastructure.

Your persistent store

Plug in Postgres, Redis, or any database via the ClientStore interface.

Docker + Helm + Terraform

Deploy configs for Kubernetes, Cloud Run, ECS, and bare metal.

Air-gapped support

Works offline once JWKS is cached. No outbound calls required at runtime.

const server = await createMcpAuthServer({
  grantex: new Grantex({
    baseUrl: 'https://auth.your-company.internal',
    apiKey:  process.env.GRANTEX_API_KEY,
  }),
  agentId: 'ag_internal_server',
  scopes:  ['internal:read', 'internal:write'],
  issuer:  'https://auth.your-company.internal',
  // Persistent storage for client registrations
  clientStore: new PostgresClientStore(),
});
OAuth 2.1 means no shortcuts.

Every security decision follows the OAuth 2.1 specification. No implicit grant, no password grant, no symmetric signing, no plain PKCE.

🔒

PKCE S256 Mandatory

The plain method and implicit grant are rejected. Every authorization request requires S256 code challenge.

🔑

Asymmetric Signing Only

HS256 is explicitly rejected. Tokens are verified with RS256, ES256, PS256, or EdDSA via remote JWKS.

Single-Use Auth Codes

Authorization codes are consumed on first exchange. Replay attempts are rejected and logged as anomalies.

🛡

Per-Endpoint Rate Limits

10/min on authorize, 20/min on token, 30/min on introspect. Configurable per deployment.

📜

Full Audit Trail

Every token issuance, introspection, and revocation is logged via Grantex events. Stream to Datadog, Splunk, or S3.

🌐

Crypto-Grade Secrets

Client secrets are generated with crypto.randomBytes(32). Auth codes use the same entropy source.

Ship your MCP server with real auth.

One package. Six RFC-compliant endpoints. Human consent, scoped access, instant revocation, and a certification badge to prove it.

npm install @grantex/mcp-auth Copy
Read the Docs Get Certified GitHub