Skip to content

Pre-release review fixes: utcp_mcp - #23

Merged
leehack merged 2 commits into
mainfrom
fix/review-mcp
Nov 3, 2026
Merged

leehack merged 2 commits into
mainfrom
fix/review-mcp

Conversation

@leehack

@leehack leehack commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

utcp_mcp no longer reads the wrong resource after a server's resource list changes, no longer drops $defs that a property named default still points into, and no longer fails a server's discovery over a malformed $ref. When the SSE fallback fails, the error now gives the streamable HTTP status too. Follow-up to #4, from the pre-release audit.

Resource tools resolve to what discovery advertised

Before, every call to resource_* listed resources and tools again and recomputed the names. After the server added a resource, resource_x_2 (advertised as file:///c) read file:///b, and a once-unique resource_x turned into a tools/call. Discovery now keeps each manual's name→URI map per server, and a call reads that URI without listing anything.

sequenceDiagram
    participant C as UtcpClient
    participant P as McpCommunicationProtocol
    participant S as MCP server
    C->>P: registerManual
    P->>S: tools/list, resources/list
    P->>P: keep resource_x_1 → file:///a, resource_x_2 → file:///c
    Note over S: server adds file:///b
    C->>P: callTool resource_x_2
    Note over P: before: list again, recompute → file:///b
    P->>S: resources/read file:///c
    C->>P: callTool resource_notes (not in the map)
    P->>S: tools/call resource_notes
Loading

A name that isn't in the map is sent as tools/call. That covers a real tool named resource_*, a server whose resource listing failed with any error (before, only a JSON-RPC error was tolerated at call time), and a manual this protocol never registered, which the server then rejects. Deregistering a manual drops its map.

Other fixes

  • $ref inlining: default, enum, const, example and examples count as data only where a schema keyword can appear, not as keys of properties, patternProperties, $defs, definitions, dependentSchemas or dependencies. A $ref whose pointer has a non-UTF-8 escape (%FF) stays in place, like an unresolved ref, instead of throwing FormatException.
  • Fallback error: Could not connect to MCP server 'api': streamable HTTP answered 404, and the legacy HTTP+SSE transport failed: SSE connection request failed (HTTP 404). It contains only status codes; the test checks that the URL query, headers and token don't appear.
  • McpHttpServer.fromJson reads transport/type, so McpHttpServer.fromJson(sseServer.toJson()) stays SSE. A non-HTTP transport there throws.
  • Legacy SSE test server uses McpProtocol.legacy narrowed to 2024-11-05. Both type: sse and the 405 fallback now check that initialize completed and that later requests carry MCP-Protocol-Version: 2024-11-05.
  • Docs: SSE support is in the pubspec description, the README intro, Platforms (it builds everywhere but is tested only on the VM) and this package's Packages row. The Security note is corrected: mcp_dart's SSE transport does take an httpClient, but then the caller has to close it, so both transports are still built inside http.runWithClient. The root README and the other packages' tables are updated in Pre-release review fixes: docs, interop and conformance reasons #20.
  • CHANGELOG: configs that used to parse and now throw (an auth object on an HTTP server, any auth on stdio including null, ws:///wss:// URLs) and {"type": "sse"} changing transport are marked Breaking:.

Verification

  • dart format, dart analyze --fatal-infos: clean.
  • packages/utcp_mcp: 139 tests pass on the VM, and the 120 unit tests pass on Chrome. Every new test fails without its fix.
  • packages/utcp_conformance: 392 pass, with no fixture changes.
  • tool/interop/run.sh (Python 3.12): passes.

- Inline $refs under properties named default, enum, const, example or
  examples, and leave a ref with a non-UTF-8 escape in place instead of
  failing discovery.
- Resource tools read the URI discovery advertised, kept per manual and
  server, instead of relisting resources and tools on every call.
- A failed SSE fallback reports the streamable HTTP status and the SSE
  status.
- McpHttpServer.fromJson reads transport/type, so SSE servers round-trip.
- The legacy SSE test server speaks only MCP 2024-11-05.
- Docs: SSE support, the SSE transport's httpClient option, Breaking
  changelog markers.
@leehack
leehack merged commit d5b0153 into main Nov 3, 2026
9 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.

1 participant