Skip to content

Add streamable-http transport with required bearer-token auth - #25

Open
erikgaas wants to merge 2 commits into
mcp2-supportfrom
http-transport
Open

Add streamable-http transport with required bearer-token auth#25
erikgaas wants to merge 2 commits into
mcp2-supportfrom
http-transport

Conversation

@erikgaas

@erikgaas erikgaas commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #24. Stacked on #23 (base branch mcp2-support), since HTTP mode needs the 2.x import; retarget to main once that merges.

clikernel-mcp now parses arguments (--transport, --host, --port via call_parse); stdio stays the default and is unchanged. For streamable-http the tools are served through MCPServer.streamable_http_app() under uvicorn, wrapped in a small ASGI middleware that requires Authorization: Bearer <token> on every HTTP request, compared with secrets.compare_digest. run_mcp refuses to start HTTP without a token (token= or $CLIKERNEL_TOKEN), so a reachable execute endpoint can't exist unauthenticated.

Notes on the choices: auth sits in ASGI middleware rather than the SDK's token_verifier/AuthSettings because those model an OAuth resource server (they require issuer and resource-server URLs), which is ceremony for a static personal token; the middleware is also identical across both SDK majors. uvicorn is imported lazily in the HTTP branch only, so stdio pays nothing for it, and it arrives with mcp in both majors.

Test: one new test_http_auth starts the server on a free port, asserts 401 for missing and wrong tokens, then runs a real client session (tools list, state persisting across calls). Green on mcp 1.29.0 (25/25 suite) and on real mcp 2.0.0. Also verified by hand end to end: claude mcp add --transport http ... -H "Authorization: Bearer ..." reports Connected.

Usage:

CLIKERNEL_TOKEN=... clikernel-mcp --transport streamable-http --host 0.0.0.0 --port 6001
claude mcp add --transport http my-instance https://<domain>/mcp -H "Authorization: Bearer ..."

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HEzsvsrhD291xoipP6X9KC
@erikgaas
erikgaas marked this pull request as draft July 29, 2026 18:49
…only Host check

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HEzsvsrhD291xoipP6X9KC
@erikgaas
erikgaas marked this pull request as ready for review July 31, 2026 05:43
@erikgaas
erikgaas requested a review from jph00 July 31, 2026 05:54
@erikgaas erikgaas added the enhancement New feature or request label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant