id-aware-mcp-server
MCP server that verifies JWT identity tokens and exposes user claims via tools
pinned to #bfda1f9updated 2 weeks ago
Ask your AI client: “install mcps/id-aware-mcp-server”.
Requires the metahub MCP server installed in your client. Set up MCP.
mh install mcps/id-aware-mcp-servermetahub onboarded this repo on the author's behalf.
If you own github.com/TheLunarCompany/lunar on GitHub, claim the listing to take over publishing. Your claim preserves the existing eval history and badges; only the curator label is replaced with verified-publisher on your next publish.
Stars
468
Last commit
2 weeks ago
Latest release
published
- #agent-skills
- #api-proxy
- #mcp
- #mcp-client
- #mcp-gateway
- #mcp-security
- #mcp-server
- #mcp-servers
- #rate-limit
- #throttling
- #visibility
Evaluation report
WarningsAutomated checks the publisher passed at publish time — structure, docs, safety, and whether the artifact behaves as claimed.bfda1f9· 2 weeks ago
Documentation
41Description quality
13 words · 78 chars — OK but more detail helps
README is present and substantial
2,855 chars · 3 sections
Tags / topics declared
11 total — agent-skills, api-proxy, mcp, mcp-client, mcp-gateway, mcp-security (+5)
README has usage / example sectionswarn
README has no Usage / Example / Quick start / Installation heading at any level
Add a `# Usage`, `## Quick start`, or similar section so end users can copy/paste a working invocation. Code blocks alone work too if there are several.
Homepage / docs URL declared
https://lunar.dev
Release history
1- releasecurrentbfda1f9warn2 weeks ago
Contents
Identity-Aware MCP Server (Python) — POC
A streamable-HTTP MCP server that verifies JWT identity tokens and exposes user claims via tools.
Want to build your own? This README explains how to run this example server. For a guide on writing your own identity-aware MCP server in the mcpx ecosystem — covering the concepts, the auth flow, and what your server needs to do — see CREATING_ID_AWARE_MCP_SERVER.md.
This is a proof-of-concept for the case where the MCP server the customer develops needs to know who the user is — using the same identity token issued by the OIDC provider configured for mcpx login. The JWT that the user obtained when authenticating with mcpx is forwarded to this server, which verifies it against the same issuer's JWKS endpoint.
Use this as a template for building your own identity-aware MCP servers — replace the whoami tool with your own tools that need to know who the caller is.
This is not the pattern for MCP servers that need tokens from a third-party service (e.g. GitHub, Jira). Those require the MCP server to implement its own OAuth flow independently.
How it works
- The client sends a JWT in the
authorizationheader (mcpx will allow this) - The server extracts the Bearer token from the header on each tool call
- Verifies the JWT signature against the OIDC provider's JWKS endpoint
- Exposes the verified claims (email, name, sub) through the
whoamitool - Rejects missing, expired, or fabricated tokens with an error
Setup
pip install -e .
cp .env.example .env # then fill in your OIDC provider details
Configuration
| Variable | Description | Example |
|---|---|---|
JWKS_URI | JWKS endpoint URL | https://your-org.okta.com/oauth2/default/v1/keys |
JWT_ISSUER | Expected iss claim | https://your-org.okta.com/oauth2/default |
JWT_AUDIENCE | Expected aud claim | your-client-id |
PORT | Server port | 4050 (default) |
Run
python server.py
Running as non-root
The provided Dockerfile creates an unprivileged appuser (uid 10001) and switches to it before the entrypoint. When you adapt this example to your own MCP server, keep that pattern — most container runtimes (Kubernetes with runAsNonRoot: true, gVisor, restricted Pod Security profiles) refuse to start root containers, and a compromised MCP server running as root has the blast radius of the whole container.
If your server needs to bind to a privileged port (<1024), prefer binding to a high port and exposing it via a Service / Ingress port mapping rather than running as root.
Testing
Use MCP Inspector to connect to http://localhost:4050/mcp and add a custom authorization header with a Bearer <jwt> value.
Tools
whoami
Returns the authenticated user's identity from the JWT token.
Success:
{ "sub": "user-123", "email": "[email protected]", "name": "Jane Doe" }
No token / invalid token: tool call fails with an error describing the reason.
Reviews
No reviews yet. Be the first.
Related
@remote-mcp/example
@remote-mcp/example MCP server
vulnerable-mcp-server-malicious-code-exec
A simple MCP server with a get_qotd tool that fetches quotes from a free API
vulnerable-mcp-server-malicious-tools
A simple MCP server to fetch and display latest status of Atlassian services
mh install mcps/id-aware-mcp-server