Skip to main content

browserid-mcp-auth (Python)

Warrant-gated MCP tools over MCP's own OAuth 2.1 — the Python port of @browserid-ng/mcp-auth. No API keys: an agent redeems its human's short-lived, scoped, revocable BrowserID warrant for a bearer, and every tool call is attributable to "agent X on behalf of human Y". Revoke at browserid.me/account and the agent dies on its next call.

An embedded authorization server (the RFC 7521 jwt-bearer assertion grant) + a resource-server guard that re-checks the warrant's revocation status fail-closed on every call. Verification is delegated to the broker's DNSSEC-rooted hosted verifier (POST /verify) and POST /status/check — no crypto in Python. Stdlib-only (no runtime deps).

Use

from browserid_mcp_auth import McpAuth, McpAuthError

auth = McpAuth(
    resource="https://mcp.example.com",           # this server (OAuth resource + audience)
    scopes_for_tool={"create_issue": ["issues:create"]},
)

# 1. Discovery (serve as JSON):
#    GET /.well-known/oauth-protected-resource   -> auth.protected_resource_metadata()
#    GET /.well-known/oauth-authorization-server  -> auth.authorization_server_metadata()

# 2. Token endpoint (the embedded AS):
#    POST /token  ->  auth.handle_token(request_body)   # {grant_type, assertion, scope?}

# 3. Gate a tool call:
ctx = auth.require_warrant(authorization_header, "create_issue")
# ctx.grantor (human), ctx.grantee (agent), ctx.holder, ctx.issuer, ctx.scopes

On failure handle_token / require_warrant raise McpAuthError with .oauth_error and .http_status; render err.to_token_error_response() at the token endpoint and auth.challenge() in the WWW-Authenticate header on a 401.

FastMCP

FastMCP servers speak MCP OAuth; mount the three surfaces above on the server's HTTP app (the token endpoint + the two discovery routes), and call auth.require_warrant(request.headers.get("authorization"), tool_name) at the top of each tool. The core is synchronous and dependency-free; call it directly or wrap in a thread from async handlers. http_post is injectable if you prefer httpx/requests over the stdlib urllib default.

API

McpAuth(resource, broker="https://browserid.me", scopes_for_tool=None, token_ttl_s=3600, status_cache_s=60, accepted_fallbacks=None, store=None, http_post=None); handle_token(params), authenticate(header), require_warrant(header, tool_or_scopes), protected_resource_metadata(), authorization_server_metadata(), challenge(). MPL-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browserid_mcp_auth-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

browserid_mcp_auth-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file browserid_mcp_auth-0.1.1.tar.gz.

File metadata

  • Download URL: browserid_mcp_auth-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browserid_mcp_auth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68b2492ff63b4cfa5e952b85450f75d4ef6aa9e1fd2eb753495a83062ebcfa1a
MD5 04c2a6e72be286359cda8cb87a43390d
BLAKE2b-256 1c3a47f8819b76a152f492ed33035ce5950e02433706a7b2a71b9f896a349851

See more details on using hashes here.

File details

Details for the file browserid_mcp_auth-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: browserid_mcp_auth-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browserid_mcp_auth-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8c83330635cfffc6c9470e96af07565dfe7602c1c37cf31bbd41ca2d01bd511
MD5 811779721268c0b86402b7f92a940230
BLAKE2b-256 7fda3e305b293ecfd1393d99569c949ffd38300f11dc4f26a26fa5e82452f09e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page