Skip to content

streamable http mcp#153

Open
pacifio wants to merge 1 commit intochopratejas:mainfrom
pacifio:main
Open

streamable http mcp#153
pacifio wants to merge 1 commit intochopratejas:mainfrom
pacifio:main

Conversation

@pacifio
Copy link
Copy Markdown
Contributor

@pacifio pacifio commented Apr 13, 2026

Added MCP Streamable HTTP transport so remote agents can connect to Headroom's compression tools over the network.

Changes

New file: headroom/ccr/mcp_http.py

  • FastMCP server with stateless_http=True exposing all 3 Headroom tools (headroom_compress, headroom_retrieve, headroom_stats)
  • Reuses the same compression pipeline, CompressionStore, and proxy fallback as the existing stdio server
  • run_standalone() for independent HTTP server mode

Modified: headroom/ccr/mcp_server.py

  • Added run_http(host, port) method to HeadroomMCPServer
  • Existing run_stdio() unchanged

Modified: headroom/proxy/server.py

  • Mounts FastMCP ASGI app at /mcp inside create_app() — proxy auto-exposes MCP tools with zero extra config
  • check_proxy=False since the MCP app shares the proxy process (no self-calls)
  • Gracefully skips if mcp package not installed

Modified: headroom/cli/mcp.py

  • headroom mcp serve now accepts --transport http|stdio, --host, --port
  • headroom mcp install now accepts --remote <url> for URL-based MCP config
  • Remote mode writes {"url": "http://host:port/mcp"} to mcp.json

New: headroom/ccr/tests/test_mcp_server.py (25 tests)

  • SessionStats, server init, compress/retrieve/stats tool handlers, shared stats, factory

New: headroom/ccr/tests/test_mcp_http.py (17 tests)

  • FastMCP creation, stateless mode, tool registration, tool invocation, standalone launcher, proxy config

Updated: README.md and docs/content/docs/mcp.mdx

  • Documented remote/Docker usage, Streamable HTTP protocol, CLI options, cross-tool compatibility table

Usage

# Proxy auto-exposes /mcp (recommended for Docker)
headroom proxy  # → http://host:8787/mcp

# Standalone HTTP server
headroom mcp serve --transport http --port 8080

# Configure remote agent
headroom mcp install --remote http://proxy-host:8787/mcp

Test Results

42 passed in 0.09s

for tests see headroom/ccr/tests/*

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 17.79141% with 134 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
headroom/ccr/mcp_http.py 15.45% 93 Missing ⚠️
headroom/cli/mcp.py 17.64% 27 Missing and 1 partial ⚠️
headroom/proxy/server.py 31.25% 11 Missing ⚠️
headroom/ccr/mcp_server.py 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chopratejas
Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants