INNER CODE UNIT · Python

_PreHandshakeStream

caiovicentino/polymarket-mcp-server · src/polymarket_mcp/server.py:148

class _PreHandshakeStream:
    """Read-stream interceptor serving pre-handshake requests.

    Installed in :func:`main` between the stdio transport and ``Server.run``:
    - ``server/discover`` is answered here (before any session exists), so the
      request never reaches the SDK union validation that produced -32602, nor
      the pre-handshake ``RuntimeError`` that drops it on some SDK versions
      (seam map: polymarket_mcp.discover docstring, issues #39/#40).
    - A version-less ``initialize`` is served on this server's declared default
      revision by injecting the version before session validation (issue #39
      R7 / issue #40: "a version-less request must be served", never timeout).
    - A request whose per-request ``_meta`` declares an unsupported protocol
      version is refused with ``-32022`` and the supported list (2026-07-28
      negotiation model; mcp-spec-test: "an unsupported version is rejected
      with the supported list"). A well-declared version passes through.
    Everything else passes through byte-identical, so the stock official-SDK
    handshake keeps its exact semantics (issue #39 R9).
    """

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…