Skip to main content
Glama
kenngcareer

Secure MCP Auth Demo

by kenngcareer

Secure MCP Auth Demo

A small, local teaching demo that uses a real MCP Streamable HTTP server with JWT bearer-token authentication and scope-based authorization.

It is intentionally separate from the LangChain and LangGraph demos in this workspace.

What it teaches

The demo models three roles:

Demo user

Granted scopes

Alice Reader

profile:read, notes:read

Bob Contributor

Alice's scopes plus notes:write

Admin Auditor

All scopes, including admin:read

The protected MCP tools are:

Tool

Required scope

profile_read

profile:read

notes_search

notes:read

notes_create

notes:write

admin_audit_log

admin:read

Related MCP server: MCP Container TS

The request path

Streamlit teaching client
  -> Authorization: Bearer <JWT>
  -> MCP Streamable HTTP server (/mcp)
  -> validate signature, exp, iss, aud
  -> read trusted sub and scope claims
  -> allow or deny the requested tool

The JWT includes sub, scope, aud, iss, iat, exp, and jti. JWT payloads are signed, not encrypted: do not place passwords, API keys, or sensitive personal information in them.

Run locally

This project uses an isolated virtual environment.

.\.venv\Scripts\python.exe server.py

In another terminal:

.\.venv\Scripts\streamlit.exe run app.py --server.port 8503

Open http://127.0.0.1:8503. Choose Alice, Bob, or Admin, inspect the issued token claims, and try each tool. For example, Alice receives HTTP 403 when trying notes_create, while Bob succeeds.

Verify

.\.venv\Scripts\python.exe -m unittest discover -s tests -v

The server also exposes MCP protected-resource metadata at:

http://127.0.0.1:8765/.well-known/oauth-protected-resource/mcp

Teaching boundary

The local app issues tokens itself so every part of the flow is easy to inspect. That is suitable for a lesson, not for a deployed service.

For production, replace auth.py's local issuer with a trusted OAuth/OIDC authorization server such as Auth0, Okta, Microsoft Entra ID, Amazon Cognito, or a company identity provider. Keep the MCP server's validation of issuer, audience, expiry, signature, and scopes.

MCP's HTTP authorization model uses bearer tokens in the Authorization header on every request, validates tokens as an OAuth resource server, and uses 401 for missing or invalid credentials and 403 for insufficient scopes. See the MCP Authorization specification.

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    C
    maintenance
    A remote MCP server implementation that demonstrates authentication and authorization capabilities using OAuth 2.1. This is a workshop project for learning how to build secure MCP servers with user authentication.
    27,437
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    A remote MCP server (Node.js/TypeScript) deployed on Azure Container Apps that provides todo list management tools with JWT authentication and role-based access control.
    49
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    MCP server for enterprise authentication and authorization — JWT validation, OIDC token inspection, OAuth 2.0 introspection, and role-based access control for AI agents.
    8
    MIT

View all related MCP servers

Related MCP Connectors

  • Hash passwords with bcrypt and issue/verify JWT session tokens over A2A + MCP.

  • Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.

  • MCP server teaching AI agents to implement TideCloak: auth, E2EE, IGA, security analysis

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kenngcareer/secure-mcp-auth-demo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server