mcp-server-typescript-oauth
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Remote MCP server in TypeScript with OAuth 2.1
A remote Model Context Protocol server, written with the official TypeScript SDK, that checks OAuth 2.1 access tokens itself. Your authorization server, such as Auth0, WorkOS, Keycloak or your own, signs users in and issues the tokens; this server does what the MCP authorization spec asks of an OAuth resource server:
Publishes protected resource metadata (RFC 9728) at
/.well-known/oauth-protected-resource/mcp, so MCP clients know where to sign in.Answers a call without a valid token with
401and aWWW-Authenticateheader that points to that metadata.Accepts only tokens issued for itself: the signature, the issuer, the expiry and the audience (RFC 8707) are checked with jose against your authorization server's published keys.
Answers
403 insufficient_scopewhen a valid token lacksmcp:tools.
It serves stateless Streamable HTTP: each call is complete on its own, so any
instance can answer any call, and the server can stop between calls. Two
example tools, whoami and add, show how a tool reads the caller's
identity. npm test checks all of the above against a stand-in issuer.
It runs anywhere that runs Node.js 22 or later. On Gregale it pauses between calls, so idle time isn't billed.
Run it locally
npm install
npm run dev-issuerdev-issuer is a stand-in authorization server for local testing. It
publishes metadata and a signing key on port 9000, and prints
OAUTH_ISSUER, MCP_RESOURCE and a one-hour TOKEN. In a second
terminal, export those three lines, then:
npm run build && npm startCall a tool with the token, then without it:
curl -s localhost:8080/mcp -H "authorization: Bearer $TOKEN" \
-H 'content-type: application/json' -H 'accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"whoami","arguments":{}}}'
curl -si localhost:8080/mcp -H 'content-type: application/json' -d '{}'The first returns your token's subject and scopes. The second returns 401
with the WWW-Authenticate header MCP clients follow.
Run the tests, which need no account or outside service:
npm testRelated MCP server: mcp-remote-auth-example
Configuration
Variable | What it is |
| Your authorization server's issuer URL, exactly as it appears in the tokens' |
| This server's public |
| Optional. The server reads the authorization server's metadata from |
| The port to listen on. Defaults to |
In your authorization server, register this server as an API or resource
whose identifier is MCP_RESOURCE, with a mcp:tools scope. The MCP spec
says authorization servers and clients should support OAuth Client ID
Metadata Documents for client registration; Dynamic Client Registration is
deprecated and kept for older servers. Check which your provider supports.
Deploy to Gregale
gregale deploy --create-only --name notes-mcp
gregale env set --app notes-mcp OAUTH_ISSUER=https://auth.example.com MCP_RESOURCE=https://notes-mcp.gregale.app/mcp
gregale deployGregale installs dependencies from the lockfile, runs the build script and
starts the app with the start script. access: public in gregale.yaml
matters: callers present your OAuth tokens, not Gregale API keys, and
without it an app on Hobby and above asks every caller for a Gregale API key
before the request reaches your code.
Check what an unauthenticated client sees:
curl -si https://notes-mcp.gregale.app/mcp -H 'content-type: application/json' -d '{}'
curl -s https://notes-mcp.gregale.app/.well-known/oauth-protected-resource/mcpA tool call must finish within the app's request timeout, 30 seconds by default. Hobby allows up to 60 seconds and Scale up to 900:
gregale app update notes-mcp --request-timeout 60MCP hosting is on the Hobby plan and higher. The walkthrough, with what we measured on Gregale and how other platforms handle MCP authorization, is Host a TypeScript MCP server with OAuth 2.1.
What we measured
We deployed this server on Gregale on 2026-11-27, with a stand-in authorization server and tokens we signed ourselves:
Memory: 112 MB while serving.
Waking up: the snapshot restore took 65 ms. An authenticated
tools/callto a parked server returned its first byte at 368 ms, including fetching the authorization server's keys.
Other examples
mcp-server-node: a JavaScript MCP server with resources, prompts, streaming progress and per-tool scopes, made by
gregale mcp server init.In version 2 of the TypeScript SDK,
requireBearerAuth,mcpAuthMetadataRouterandgetOAuthProtectedResourceMetadataUrlmove to the@modelcontextprotocol/expresspackage.
Using a coding agent
AGENTS.md tells Codex, Cursor, Claude Code and other agents how to deploy
and check this server with the gregale CLI. See also
Host an MCP server and
Use Gregale from coding agents.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Demo banking MCP server: accounts, transactions and payments. OAuth 2.1 with DPoP.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
MCP server for verifying EUDI/Talao wallet data via OIDC4VP (pull) for AI agents.
Remote MCP server exposing SMI Aware tools, resources, and skills over Streamable HTTP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA production-ready MCP server that authenticates agents via OAuth 2.1 Bearer tokens, validates JWTs with JWKS, enforces tool-level scopes and roles, and logs the full delegation chain.-
- -licenseNot gradedqualityFmaintenanceA minimal remote (Streamable HTTP) MCP server that is an OAuth 2.1 resource server, demonstrating the MCP authorization spec with token validation and audience checks.-
- AlicenseNot gradedqualityDmaintenanceImplements an MCP server with OAuth 2.1 Protected Resource Metadata, enabling token-based authentication for MCP tools like ping.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to connect over stateless Streamable HTTP and authenticate through an existing OAuth 2.1 / OpenID Connect authorization server, with JWT validation, per-tool scope enforcement, and step-up challenges. It ships example scoped tools for reading and creating per-user notes that developers replace with their own.MIT