Skip to content

feat(harness): add MCP resource tools and keep oversized output on the host - #81

Draft
sanchitrk wants to merge 2 commits into
claude/cod-114-stacked-pr-92a28dfrom
claude/mcp-resources
Draft

sanchitrk wants to merge 2 commits into
claude/cod-114-stacked-pr-92a28dfrom
claude/mcp-resources

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #80. Adds MCP resources and Pi's handling of results the model isn't shown in full. Everything stays on the host: MCP runs in the harness process and never touches a session's sandbox, local or remote.

Resource tools (src/mcp/resources.ts)

  • list_mcp_resources, list_mcp_resource_templates and read_mcp_resource, named and shaped like the tools other agents use, so models trained on them use them unchanged.
  • They're registered when any enabled, non-hidden server offers resources, and reach every such server when they run.
  • With a server, one page is listed and cursor continues it. Without one, every page of every server is listed, and servers that fail go into errors.
  • MCP App resources (ui://, profile=mcp-app) and icons are left out of listings.
  • Reads become text and images; several contents are labelled with their URIs.

Result content (src/mcp/content.ts)

  • Text over 20 KB keeps its start and end, cut in the middle, and the full text is saved to a file whose path the result names.
  • Binary resources are saved; text-typed blobs (text/*, JSON, XML) are shown as text.
  • Resource links name read_mcp_resource when the server's resources can be read.

Saved files (src/mcp/output.ts)

  • They go to the host temp directory as codework-mcp-*, mode 0600, created exclusively, never into a sandbox.

One request path (src/mcp/mcp.ts)

  • Tool calls and resource requests share it: the current connection is looked up when the request runs, a dropped one reconnects, an expired HTTP session gets one more attempt on a new session, and a sign-in failure is reported. Tool calls are still never retried otherwise.

Docs

  • A new page, customize/mcp: where servers run (always on your machine), mcp.json, project overrides, exposure, resources, connections.

Review fixes (Codex peer review)

  • Strict paging. Listing every server's resources or templates uses the SDK's own pagination and limits, as tools() does. A server repeating a cursor can't keep a listing running.
  • Opaque cursors. A cursor goes back exactly as the server gave it; only server names and URIs are trimmed. The fixture's cursor is now " page-2 " to prove it.
  • Test cleanup. Tests remove the files they save, and read saved paths between the message's own delimiters, so a temp directory with spaces still parses.
  • Docs. Which servers a message waits for, that exposure changes keep a server running, and where server logs go.

Test plan

  • test/mcp.session.test.ts gains a third exchange, through the full harness against a real stdio server. It covers:
    • the server's configured cwd
    • a resource link
    • a 30 KB result cut below 21 KB, with the saved file holding all of it
    • listing every page and paging one server by cursor, with the ui:// resource left out
    • templates
    • a text read and a binary read, with the binary saved as a 0600 host file holding the right bytes
    • an unknown server
  • test/mcp.client.test.ts: artifact updated for saved binaries and Pi-style resource links
  • Full harness suite: 514 passed, 34 skipped (live/remote)
  • vp check and vp run typecheck

🤖 Generated with Claude Code

@sanchitrk
sanchitrk force-pushed the claude/cod-114-stacked-pr-92a28d branch from f3014f3 to b02d026 Compare October 14, 2026 19:30
@sanchitrk
sanchitrk force-pushed the claude/mcp-resources branch from a67866b to 60888b5 Compare October 14, 2026 19:30
sanchitrk and others added 2 commits October 15, 2026 09:16
…e host

- list_mcp_resources, list_mcp_resource_templates and read_mcp_resource
  reach every enabled server with resources, through the same request
  path as tool calls (reconnect, expired-session recovery, sign-in).
  Listings page per server or cover every page; MCP App resources are
  left out.
- Results keep the start and end of text over 20 KB and save the full
  text; binary resources are saved, text-typed blobs shown as text, and
  resource links name read_mcp_resource.
- Saved files go to the host temp directory (mode 0600), since MCP runs
  on the host whatever sandbox a session uses.
- Docs: an MCP page under Customize.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Listing every server's resources or templates uses the SDK's own
  pagination and its limits, so a server repeating a cursor cannot keep
  a listing running.
- A cursor goes back to the server exactly as it was given; only server
  names and URIs are trimmed.
- Tests remove the files they save, and read saved paths between the
  message's own delimiters.
- Docs: which servers a message waits for, exposure changes keep a
  server running, and where server logs go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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