Add MCP server unit tests using InMemoryTransport (no subprocess)#30223
Merged
Add MCP server unit tests using InMemoryTransport (no subprocess)#30223
Conversation
6 tasks
…ryTransport Agent-Logs-Url: https://github.com/github/gh-aw/sessions/206a10f2-b403-4135-83a2-28f49b16537f Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/206a10f2-b403-4135-83a2-28f49b16537f Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Convert MCP server integration tests to unit tests using InMemoryTransport
Add MCP server unit tests using InMemoryTransport (no subprocess)
May 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds non-integration (unit) test coverage for the MCP server by using the MCP SDK’s in-memory transports, enabling make test-unit to exercise tool registration/capabilities and key tool behaviors without requiring a prebuilt gh-aw binary subprocess.
Changes:
- Introduces new
!integrationunit tests that connect an MCP client/server in-process via the existingconnectInMemoryhelper. - Adds focused unit coverage for tool listing, server capabilities, the
statustool JSON response, andcompiletool flag forwarding via a mockedexecCmd. - Updates the metrics-collector locked workflow to include
GH_AW_INFO_VERSION.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/mcp_server_unit_test.go |
Adds in-process MCP server unit tests using NewInMemoryTransports to avoid requiring a compiled binary for unit test runs. |
.github/workflows/metrics-collector.lock.yml |
Adds GH_AW_INFO_VERSION to the workflow environment configuration. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
|
|
||
| // With no workflow files in the directory, the response should be a valid empty JSON array. | ||
| var statuses []any | ||
| require.NoError(t, json.Unmarshal([]byte(textContent.Text), &statuses), "status tool should return valid JSON") |
Collaborator
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/ec346abd-590f-4cb6-a5ce-43b9671bcfdc Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All MCP server tests were tagged
//go:build integrationand spawned actual binary subprocesses, making them unavailable tomake test-unitand requiring a compiled binary. The SDK providesmcp.NewInMemoryTransports()for in-process testing.Changes
pkg/cli/mcp_server_unit_test.go(//go:build !integration) — four unit tests wiring server and client entirely in-process via the existingconnectInMemoryhelper:TestMCPServerUnit_ListToolscreateMCPServerTestMCPServerUnit_ServerCapabilitiesTools.ListChanged=false(static tool set)TestMCPServerUnit_StatusToolGetWorkflowStatusesdirectly (no subprocess)TestMCPServerUnit_CompileToolexecCmd; validates--jsonflag forwardingThe existing integration tests in
mcp_server_tools_test.goandmcp_server_compile_test.goare preserved for end-to-end binary validation.