Skip to content

Quickstart guide, MCP middleware SSE fix, and end-to-end token deploy log - #4

Merged
molaanaa merged 4 commits into
molaanaa:mainfrom
EnzinoBB:docs/quickstart-and-mcp-fixes
May 5, 2026
Merged

molaanaa merged 4 commits into
molaanaa:mainfrom
EnzinoBB:docs/quickstart-and-mcp-fixes

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented May 5, 2026

Copy link
Copy Markdown
Contributor

Three independent improvements bundled together:

  • fix(mcp) — pure-ASGI auth middleware, gate Bearer only on GET /sse
    (9747213). Replaces the Starlette BaseHTTPMiddleware-based auth
    middleware which broke SSE streams with TypeError: 'NoneType' object is not callable on every /sse request, and which also rejected the
    POST /messages/?session_id=… calls that mobile/web Claude clients send
    without re-attaching Authorization. The session-id minted by
    SseServerTransport after a successful handshake is itself the
    capability for /messages/. The new AuthAndSseHeadersASGI middleware
    is pure-ASGI and also injects X-Accel-Buffering: no /
    Cache-Control: no-cache / Connection: keep-alive on /sse.

  • docs(quickstart) — QUICKSTART.md (7118328 + e2ed732).
    Step-by-step English setup guide: prerequisites, virtualenv,
    .env / .env.mcp config with bearer generation, local startup,
    optional public HTTPS exposure (DuckDNS + Let's Encrypt + nginx
    vhost), client configuration, security notes.

  • docs(MOON_DEPLOY_LOG) — MOON_DEPLOY_LOG.md (6cd3b26).
    End-to-end record of a token deploy + transfer performed entirely
    through the public HTTP gateway (no MCP). Includes verbatim
    request/response pairs (signatures redacted), full Java source of a
    MOON token implementing every ExtensionStandard method
    (buyTokens no longer a stub, payable consuming CS to mint), and
    lessons learned (Variant param shape v_string vs V_STRING, fee
    consistency between Pack and Deploy/Execute,
    WaitForSmartTransaction.publicKey semantics).

Test plan

  • MCP fix verified live: /sse 401 without bearer, 200 with bearer,
    POST /messages/?session_id=… 202 without bearer.
  • Mobile Claude Code MCP client reconnects cleanly after the fix.
  • MOON token deployed at
    2T5dmjqYoDuJWiJsueq66qF83tguNZYpr6evYFtWDk2y, 100-MOON
    transfer to MooNRor8…ZSveDpP confirmed by reading both
    balanceOf values back from contract state.
  • Reviewer to spot-check QUICKSTART.md for env assumptions.

EnzinoBB and others added 4 commits May 5, 2026 15:17
Covers fresh-clone setup of gateway + MCP: prerequisites, venv,
.env/.env.mcp config with bearer generation, local startup, optional
public HTTPS exposure (DuckDNS + Let's Encrypt + nginx vhost), client
configuration, and security notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous implementation used Starlette's BaseHTTPMiddleware for both
auth and SSE-no-buffer logic, which is documented to break SSE streams
(observed in logs as "TypeError: 'NoneType' object is not callable" on
every /sse request, because BaseHTTPMiddleware tries to wrap a response
that the SseServerTransport bypasses via request._send).

It also enforced the Bearer on every request including POST /messages/.
Some clients (notably the Anthropic-backed Claude mobile MCP client) only
attach Authorization on the /sse handshake; subsequent /messages/ POSTs
arrived without it, returning 401 — surfaced upstream as a content-length:0
403 with the "first call OK, then forbidden" pattern.

Fix:
- Replace AuthMiddleware + SseNoBufferMiddleware with a single pure-ASGI
  middleware AuthAndSseHeadersASGI.
- Bearer is enforced only on GET /sse. POST /messages/?session_id=... is
  authorised by the unguessable session_id minted after a successful
  handshake (functionally a one-shot capability — same security model as
  bearer-on-handshake adopted by most SSE-based MCP gateways).
- The /sse response gets X-Accel-Buffering: no, Cache-Control: no-cache,
  and Connection: keep-alive injected at http.response.start so reverse
  proxies don't buffer the first event frame.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Documents the full gateway-only flow used to deploy a MOON ExtensionStandard
token contract and transfer 100 MOON to a test wallet, with verbatim
request/response pairs (private signature material redacted) and
lessons learned around Variant param shape (v_string vs V_STRING),
fee consistency between Pack and Deploy/Execute, and the
WaitForSmartTransaction publicKey field semantics.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@molaanaa
molaanaa merged commit a05ab9d into molaanaa:main May 5, 2026
2 checks passed
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.

2 participants