Skip to content

Extract mcptest: the wire-test harness both instances duplicated - #2

Merged
jeremy merged 2 commits into
mainfrom
extract-mcptest
Aug 28, 2026
Merged

Extract mcptest: the wire-test harness both instances duplicated#2
jeremy merged 2 commits into
mainfrom
extract-mcptest

Conversation

@jeremy

@jeremyjeremy commented Aug 28, 2026

Copy link
Copy Markdown
Member

Extraction PR 2 of 4 per the program board's plan of record (internal): the wire-test harness, moved from where both product instances proved it by duplication.

What moves

  • mcptest.Connect — connects a real MCP client to a server over in-memory transports, so tests assert against the wire surface (tool listings, call results, isError) rather than internal state. From basecamp-mcp-server's connectInMemory (internal/server/mcp_test.go) and hey-mcp-server's connect (internal/server/server_test.go).
  • mcptest.ListTools / mcptest.CallText — the listing and text-call helpers, verbatim from hey-mcp-server, shape-identical in basecamp-mcp-server.
  • mcptest.Snapshot — golden-file compare with a rewrite switch, the mechanism both instances carry (hey's catalog snapshot, basecamp's tool snapshots).

Polish (only where the instances trivially disagree)

  • Helpers take testing.TB (both instances used *testing.T).
  • Connect closes both sessions via t.Cleanup (basecamp's behavior; hey closed only the client).
  • The snapshot switch is the -update flag (hey's spelling) rather than basecamp's BASECAMP_UPDATE_SNAPSHOTS env var.

No redesign otherwise. Self-tests cover the round-trip, in-band error surfacing, and snapshot compare/rewrite.

Adoption PRs in both instances follow once gateway and catalog land, per the sequence.

In-memory MCP client/server connect, ListTools/CallText helpers, and the
golden-snapshot compare with -update — moved from basecamp-mcp-server
(internal/server/mcp_test.go, internal/tools/snapshot_test.go) and
hey-mcp-server (internal/server/server_test.go), where the harness
existed near-verbatim by duplication.
Polish where the instances trivially disagreed: helpers take testing.TB,
Connect closes both sessions via t.Cleanup, and the snapshot switch is
the -update flag (hey's spelling) rather than an env var.
CopilotAI balanced review requested due to automatic review settings August 28, 2026 07:11

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extracts the duplicated MCP wire-test harness into the shared mcptest package.

Changes:

  • Adds in-memory client/server connection and tool-call helpers.
  • Adds golden snapshot comparison and rewriting.
  • Adds self-tests and MCP SDK dependencies.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
mcptest/mcptest.goImplements wire-test helpers.
mcptest/snapshot.goImplements snapshot comparison and rewriting.
mcptest/mcptest_test.goTests connection, calls, errors, and snapshots.
mcptest/testdata/snapshot_fixture.txtProvides the golden fixture.
go.modAdds required dependencies.
go.sumRecords dependency checksums.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment threadmcptest/mcptest.go Outdated
The SDK server pages tool listings by ServerOptions.PageSize, so taking
only the first ListTools response drops tools on servers larger than one
page. Iterate with ClientSession.Tools, which follows NextCursor; a
one-tool page size in the test forces the multi-page path.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:1bf1d97d9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadmcptest/mcptest.go
@jeremy
jeremy merged commit ea05259 into mainAug 28, 2026
2 checks passed
@jeremy
jeremy deleted the extract-mcptest branch August 28, 2026 08:28
Sign up for freeto 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

@jeremy