Skip to content

2025-11-25 spec compliance fixes + JuliaC trim-compile harness - #4

Open
quinnj wants to merge 6 commits into
mainfrom
spec-2025-11-25-fixes
Open

2025-11-25 spec compliance fixes + JuliaC trim-compile harness#4
quinnj wants to merge 6 commits into
mainfrom
spec-2025-11-25-fixes

Conversation

@quinnj

@quinnj quinnj commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

Brings the implementation into full compliance with MCP 2025-11-25 and adds the standard JuliaC `--trim=safe` compile harness used across JuliaServices packages.

Spec compliance fixes

  • Deterministic list ordering — `tools/list`, `prompts/list`, `resources/list`, and `resources/templates/list` now return items sorted by name/uri. Previously order came from `Dict` iteration, which silently hurt client-side LLM prompt-cache hit rates (and the 2026-07-28 spec makes deterministic ordering an explicit SHOULD).
  • Correct error codes — unknown tool/prompt now return `-32602` Invalid params (was `-32601` Method not found); unknown resource returns `-32002` Resource not found per the 2025-11-25 resources spec.
  • Client handles SSE-streamed POST responses — Streamable HTTP servers may answer a POST with `Content-Type: text/event-stream` carrying request-scoped notifications before the final response (the TS SDK does this by default). The client previously assumed a plain JSON body and would fail; it now parses the stream, dispatches interleaved notifications/server requests to registered handlers, and extracts the final response.

Trim-compile harness

  • Merges the `codex/trim-safe-server` static server work (`StaticMCPServer` — concrete-typed tools-only transport) and makes it actually pass `--trim=safe`: the JSON.lazy/typed-parse request paths reached Parsers' recursive float parsing and `repr()`-based error formatting (456 verifier errors), so request parsing is now a minimal self-contained scanner. This also drops the StructUtils dependency.
  • `test/trim_compile_tests.jl` + `test/mcp_trim_safe.jl` follow the same harness pattern as Figgy/Servo: compile the workload with JuliaC `--trim=safe` in a temp env, require 0 verifier errors/warnings, then run the produced executable. Skips on Julia < 1.12, prerelease, and 32-bit; runs on the `1` CI matrix entry.

Test plan

  • Full suite green locally on Julia 1.12.6 (169 tests: Session stores, MCP client over HTTP, HTTP transport edge cases, Discovery auth challenges, Static tools server, MCP Apps, new Spec compliance fixes, Trim compile)
  • Trim workload compiles with 0 verifier errors/warnings and the binary runs

🤖 Generated with Claude Code

quinnj and others added 6 commits July 22, 2026 12:11
Add a concrete tools-only Streamable HTTP server for native compilation. Typed request envelopes, raw JSON fragments, concrete handlers, and explicit sessions avoid dynamic Function and Dict dispatch while preserving initialize, tools/list, tools/call, ping, and session lifecycle behavior.
…med responses

- Return tools/prompts/resources/templates lists in deterministic sorted
  order so clients get stable prompt-cache-friendly results
- Unknown tool/prompt in tools/call & prompts/get now return -32602
  (Invalid params) instead of -32601; unknown resource in resources/read
  returns -32002 (Resource not found) per the 2025-11-25 spec
- Client now handles Streamable HTTP POST responses delivered as SSE
  streams: request-scoped notifications/server requests are dispatched to
  registered handlers and the final JSON-RPC response is extracted

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
JSON.lazy/typed-parse request paths reach Parsers' recursive float
parsing and repr()-based error formatting, neither of which passes the
JuliaC --trim=safe verifier (456 errors). Replace them with a minimal
self-contained scanner (string unescape incl. surrogate pairs, value
extent skipping, Int64 ids) so the static server's entire request graph
verifies clean. Drops the StructUtils dependency.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- test/trim_compile_tests.jl: standard trim harness (compiles workloads
  with --trim=safe in a temp env, requires 0 verifier errors/warnings,
  runs the produced executable); skips on Julia < 1.12/prerelease/32-bit
- test/mcp_trim_safe.jl: StaticMCPServer workload exercising the full
  session + tools request lifecycle over in-memory HTTP requests
- New testset covering deterministic list ordering, spec error codes,
  and SSE-streamed POST response handling in the client

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
quinnj added a commit that referenced this pull request Jul 30, 2026
Replace fixed 200 ms sleeps with bounded condition waits. This matches the deterministic listener test change already present in PR #4 and prevents unrelated platform timing failures from masking the stale-session regression.
quinnj added a commit that referenced this pull request Jul 31, 2026
* fix(transport): return 404 for stale sessions

Return the HTTP status required by Streamable HTTP when a client sends an unknown MCP session ID. Keep the JSON-RPC -32001 body so clients can log the protocol error while using HTTP 404 to start a new session.

* test(client): wait for streamed events

Replace fixed 200 ms sleeps with bounded condition waits. This matches the deterministic listener test change already present in PR #4 and prevents unrelated platform timing failures from masking the stale-session regression.
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.

1 participant