JavaScript MCP Auth Server logo

JavaScript MCP Auth Server

kabirrajsingh/mcp-server-auth-js
0 starsUpdated 2026-06-22Community

Is this your server?

Add your score badge to your README and get your server in front of 45k+ builders a month.

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Demonstrates MCP remote authentication boundary with OAuth 2.0, Keycloak token introspection, audience and scope validation, and protected tools.

README.md

JavaScript MCP Auth Server

This package shows the remote MCP auth boundary in JavaScript:

  • Express HTTP server
  • MCP Streamable HTTP transport at /mcp
  • Protected Resource Metadata
  • Bearer token middleware
  • Keycloak token introspection
  • audience validation
  • mcp:tools scope enforcement
  • protected add_numbers and server_status tools

Run

pnpm mcp-auth-server-js install
cp .env.example .env
pnpm mcp-auth-server-js demo:keycloak
pnpm mcp-auth-server-js start

For the demo, configure Keycloak with:

  • client scope: mcp:tools
  • MCP server confidential client: mcp-server
  • demo client/user for obtaining an access token
  • token audience: http://localhost:3000/mcp

Demo Scripts

pnpm mcp-auth-server-js demo:no-token
pnpm mcp-auth-server-js demo:metadata
pnpm mcp-auth-server-js demo:get-token
pnpm mcp-auth-server-js demo:call-tool
pnpm mcp-auth-server-js demo:bad-scope

The important point is the failure order:

  1. no token returns 401 with WWW-Authenticate
  2. metadata tells the client where auth lives
  3. token introspection rejects inactive tokens
  4. audience validation rejects tokens for another API
  5. scope validation rejects tokens without mcp:tools

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Other servers.