Add streamable-http transport with required bearer-token auth - #25
Open
erikgaas wants to merge 2 commits into
Open
Add streamable-http transport with required bearer-token auth#25erikgaas wants to merge 2 commits into
erikgaas wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HEzsvsrhD291xoipP6X9KC
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24. Stacked on #23 (base branch
mcp2-support), since HTTP mode needs the 2.x import; retarget tomainonce that merges.clikernel-mcpnow parses arguments (--transport,--host,--portviacall_parse); stdio stays the default and is unchanged. Forstreamable-httpthe tools are served throughMCPServer.streamable_http_app()under uvicorn, wrapped in a small ASGI middleware that requiresAuthorization: Bearer <token>on every HTTP request, compared withsecrets.compare_digest.run_mcprefuses to start HTTP without a token (token=or$CLIKERNEL_TOKEN), so a reachableexecuteendpoint can't exist unauthenticated.Notes on the choices: auth sits in ASGI middleware rather than the SDK's
token_verifier/AuthSettingsbecause 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 withmcpin both majors.Test: one new
test_http_authstarts 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 onmcp 1.29.0(25/25 suite) and on realmcp 2.0.0. Also verified by hand end to end:claude mcp add --transport http ... -H "Authorization: Bearer ..."reports Connected.Usage: