Skip to main content

mcp-asgi-http

Mount an MCP server on an ASGI app over Streamable HTTP. Includes optional request auth and helpers that work when ASGI lifespan is off (for example Mangum on Lambda).

Docs and blog: johnny-rice.github.io/mcp-asgi-http

pip install mcp-asgi-http
pip install 'mcp-asgi-http[jwt]'   # if you use JwtAuth / dual JWT
from fastapi import FastAPI
from mcp.server import Server
from mcp_asgi_http import ApiKeyAuth, mount_mcp

server = Server("demo")
# register tools on server

api = FastAPI(redirect_slashes=False)
app = mount_mcp(
    api,
    server,
    auth=ApiKeyAuth(allowed_keys={"dev-secret"}),
    # auth=None if you authenticate in API Gateway or your own middleware
)

Components

Piece Role
StatelessMCPASGIApp Per-request Streamable HTTP (stateless=True, JSON responses)
McpPathMiddleware / mount_mcp Route /mcp without Starlette Mount slash-redirect issues
Auth backends api_key, jwt, dual, or auth=None
once_ready Run lazy init once when lifespan is off
Enrich / playbook helpers Optional deep-link hooks; markdown guide as MCP resource + HTTP route

Auth

Mode Behavior
auth=None / build_auth_backend("none") No auth in this library (use your gateway or middleware)
ApiKeyAuth / "api_key" Authorization: Bearer or X-API-Key
JwtAuth / "jwt" Bearer JWT via JWKS (issuer, audience, optional jwks_url)
DualAuth / "dual" API key first, then JWT

Related projects

These are different tools:

Project Difference
FastMCP Tool registration / DX. This package is for mounting and HTTP auth.
AWS Serverless MCP Server MCP tools for SAM/Lambda development, not an ASGI mount library.
invariantlabs-ai/mcp-streamable-http Transport examples.
mcp-streamablehttp-proxy / mcp-streamablehttp-client stdio ↔ HTTP bridges.

Examples and samples

Short snippets: examples/

Full stack apps (Docker / Fly / Render): samples/

  1. samples/ops-dual-auth - DualAuth + ops REST twin (hero)
  2. samples/clinical-intel - fixtures + enrich + playbook (hero)
  3. samples/catalog - supporting enrich/playbook UI
  4. samples/notes - supporting API-key + once_ready UI

Development

python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
pytest -q
mkdocs serve   # local docs site

License

Apache-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

mcp_asgi_http-0.1.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

mcp_asgi_http-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_asgi_http-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_asgi_http-0.1.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mcp_asgi_http-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1320a13033a1723c7f44bf558ae517b32eb355969e5f8c1046683452c437b9b5
MD5 ee03458b362bd75b7e3db3a92b223f9a
BLAKE2b-256 75ddff4a6b41ef56981acac04f232480411f9262d1597b4d9747a868f27f0d74

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_asgi_http-0.1.0.tar.gz:

Publisher: publish.yml on johnny-rice/mcp-asgi-http

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_asgi_http-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_asgi_http-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mcp_asgi_http-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2b3c87b39cbedf73984f355e4df712529f282872cb4a5bac38ac98075149c62
MD5 d1ca4c256bd92e9cf3e05243b78c35c9
BLAKE2b-256 9180b67698288114aa94530c6f0f698df92561d1810ec2ddc74651da609e6c01

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_asgi_http-0.1.0-py3-none-any.whl:

Publisher: publish.yml on johnny-rice/mcp-asgi-http

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

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