@vurb/jwt
v3.7.8
Published
JWT verification middleware for MCP servers built with vurb. Standards-compliant token validation with jose, JWKS support, and self-healing error responses.
Maintainers
Readme
JWT verification middleware for MCP servers built with Vurb.ts. Timing-safe validation with
jose, JWKS auto-discovery, and self-healing error responses.
Quick Start
import { initVurb } from '@vurb/core';
import { jwtGuard } from '@vurb/jwt';
const f = initVurb<AppContext>();
const withJwt = jwtGuard({
secret: process.env.JWT_SECRET!,
algorithms: ['HS256'],
});
export default f.query('billing.invoices')
.use(withJwt)
.handle(async (input, ctx) => {
// ctx.jwt contains the decoded payload
return db.invoices.findMany({ where: { tenantId: ctx.jwt.sub } });
});Features
| Feature | Description |
|---------|-------------|
| Algorithms | HS256, RS256, ES256 — all standard algorithms via jose |
| JWKS | Auto-discovery from /.well-known/jwks.json with key rotation |
| Self-Healing | Expired/invalid tokens return actionable hints to the LLM agent |
| Timing-Safe | Constant-time signature verification |
| Zero Config | Works with Auth0, Clerk, Supabase, Firebase, any OIDC provider |
JWKS Auto-Discovery
const withJwt = jwtGuard({
jwksUri: 'https://auth.example.com/.well-known/jwks.json',
issuer: 'https://auth.example.com/',
audience: 'my-mcp-server',
});Installation
npm install @vurb/jwt josePeer Dependencies
| Package | Version |
|---------|---------|
| vurb | ^2.0.0 |
| jose | ^5.0.0 (optional) |
Requirements
- Node.js ≥ 18.0.0
- Vurb.ts ≥ 2.0.0 (peer dependency)
