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/
samples/ops-dual-auth- DualAuth + ops REST twin (hero)samples/clinical-intel- fixtures + enrich + playbook (hero)samples/catalog- supporting enrich/playbook UIsamples/notes- supporting API-key +once_readyUI
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1320a13033a1723c7f44bf558ae517b32eb355969e5f8c1046683452c437b9b5
|
|
| MD5 |
ee03458b362bd75b7e3db3a92b223f9a
|
|
| BLAKE2b-256 |
75ddff4a6b41ef56981acac04f232480411f9262d1597b4d9747a868f27f0d74
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_asgi_http-0.1.0.tar.gz -
Subject digest:
1320a13033a1723c7f44bf558ae517b32eb355969e5f8c1046683452c437b9b5 - Sigstore transparency entry: 2231236641
- Sigstore integration time:
-
Permalink:
johnny-rice/mcp-asgi-http@264f8ea5333350716688f8b35036d9595666fd72 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/johnny-rice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@264f8ea5333350716688f8b35036d9595666fd72 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2b3c87b39cbedf73984f355e4df712529f282872cb4a5bac38ac98075149c62
|
|
| MD5 |
d1ca4c256bd92e9cf3e05243b78c35c9
|
|
| BLAKE2b-256 |
9180b67698288114aa94530c6f0f698df92561d1810ec2ddc74651da609e6c01
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_asgi_http-0.1.0-py3-none-any.whl -
Subject digest:
f2b3c87b39cbedf73984f355e4df712529f282872cb4a5bac38ac98075149c62 - Sigstore transparency entry: 2231237367
- Sigstore integration time:
-
Permalink:
johnny-rice/mcp-asgi-http@264f8ea5333350716688f8b35036d9595666fd72 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/johnny-rice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@264f8ea5333350716688f8b35036d9595666fd72 -
Trigger Event:
workflow_dispatch
-
Statement type: