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

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

Metadata

Release files for mcp-asgi-http 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-asgi-http 0.1.0
File Size Uploaded Provenance Actions
mcp_asgi_http-0.1.0.tar.gz 19.6 kB With provenance Details for mcp_asgi_http-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-asgi-http 0.1.0
File Interpreter ABI Platform Actions
mcp_asgi_http-0.1.0-py3-none-any.whl Python 3 none any Details for mcp_asgi_http-0.1.0-py3-none-any.whl

Total release size: 36.2 kB

Release files / mcp_asgi_http-0.1.0.tar.gz

Download URL mcp_asgi_http-0.1.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1320a13033a1723c7f44bf558ae517b32eb355969e5f8c1046683452c437b9b5
BLAKE2b-256 checksum
How to use checksums
75ddff4a6b41ef56981acac04f232480411f9262d1597b4d9747a868f27f0d74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / mcp_asgi_http-0.1.0-py3-none-any.whl

Download URL mcp_asgi_http-0.1.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2b3c87b39cbedf73984f355e4df712529f282872cb4a5bac38ac98075149c62
BLAKE2b-256 checksum
How to use checksums
9180b67698288114aa94530c6f0f698df92561d1810ec2ddc74651da609e6c01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Security for mcp-asgi-http 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_asgi_http-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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