npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aauth/mcp-server

v0.1.3

Published

AAuth server-side building blocks: challenge headers, interaction management, resource tokens

Downloads

256

Readme

@aauth/mcp-server

Server-side AAuth for MCP. Verifies signed requests, validates agent and auth tokens, builds AAuth challenge headers, creates resource tokens, and manages 202 interaction flows.

See the AAuth repo for protocol overview.

Install

npm install @aauth/mcp-server

Usage

verifyToken(options): Promise<VerifiedToken>

Verifies a JWT from a signed request. Supports both agent+jwt and auth+jwt token types. Fetches issuer metadata and JWKS automatically (cached).

import { verifyToken } from '@aauth/mcp-server'

const result = await verifyToken({
  jwt: tokenFromSignatureKeyHeader,
  httpSignatureThumbprint: thumbprintFromVerifiedSignature,
})

if (result.type === 'agent') {
  // VerifiedAgentToken: iss, sub, cnf, iat, exp
  console.log(`Agent: ${result.sub}`)
}

if (result.type === 'auth') {
  // VerifiedAuthToken: iss, aud, agent, cnf, sub?, scope?, iat, exp
  console.log(`Authorized agent: ${result.agent}, scope: ${result.scope}`)
}

Throws AAuthTokenError with a spec-defined error code on failure:

| Code | Meaning | |------|---------| | invalid_agent_token | Agent token verification failed | | invalid_auth_token | Auth token verification failed | | key_binding_failed | Request signing key doesn't match token cnf.jwk |

buildAAuthHeader(require, params?): string

Builds an AAuth response header for 401/403 challenges.

import { buildAAuthHeader } from '@aauth/mcp-server'

// 401 — require auth token
const header = buildAAuthHeader('auth-token', {
  resourceToken: '...',
  authServer: 'https://auth.example',
})
response.setHeader('AAuth', header)

// 403 — require interaction
const header = buildAAuthHeader('interaction', { code: 'ABCD1234' })

// Simple levels (no params)
buildAAuthHeader('pseudonym')
buildAAuthHeader('identity')
buildAAuthHeader('approval')

createResourceToken(options, sign): Promise<string>

Creates a resource+jwt token for inclusion in 401 AAuth challenges.

import { createResourceToken } from '@aauth/mcp-server'

const resourceToken = await createResourceToken(
  {
    resource: 'https://api.example.com',
    authServer: 'https://auth.example',
    agent: 'https://user.github.io',
    agentJkt: thumbprint,  // JWK Thumbprint of agent's signing key
    scope: 'files.read',
    lifetime: 300,         // seconds, default 300
  },
  async (payload, header) => {
    // Sign the JWT with your resource server's key
    return signedJwtString
  }
)

InteractionManager

Manages pending requests for 202 deferred response flows.

import { InteractionManager } from '@aauth/mcp-server'

const manager = new InteractionManager({
  baseUrl: 'https://api.example.com',
  pendingPath: '/pending',  // default
  codeLength: 8,            // default
  ttl: 600,                 // seconds, default
})

// Create a pending request (returns headers for 202 response)
const { headers, pending } = manager.createPending()
// headers: { Location, Retry-After, Cache-Control, AAuth }
// pending: { id, code, promise, resolve, reject }

// Resolve when the interaction completes
manager.resolve(pending.id, { granted: true })

// Or reject
manager.reject(pending.id, 'denied')

// Cleanup expired entries
manager.cleanup()

clearMetadataCache()

Clears the cached issuer metadata and JWKS used by verifyToken.

import { clearMetadataCache } from '@aauth/mcp-server'

clearMetadataCache()

License

MIT