Skip to content

refactor(mcp): MCP tool tests install a dispatcher - #3834

Merged
dan-petty merged 4 commits into
mainfrom
refactor/1330-mcp-dispatcher-hook
Nov 6, 2026
Merged

dan-petty merged 4 commits into
mainfrom
refactor/1330-mcp-dispatcher-hook

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

MCP tool tests now install a dispatcher. They no longer patch the process.

An MCP tool hands one devops argv to the CLI. The real dispatcher runs the Typer app in the same process, so no program starts and the process fake never sees the argv. The seam is McpDispatcher in devops_cli.ai.mcp.dispatcher, with install_mcp_dispatcher and reset_mcp_dispatcher. The test double is DispatcherFake, behind the mcp_dispatcher fixture. A contract suite runs each case over the fake and over InProcessDispatcher.

The hermetic floor resets the seam after each test. docs/TESTING.md names the seam.

Closes #3760

Change: openspec/changes/archive/2026-11-06-3760-mcp-dispatcher-hook/

An MCP tool hands a devops command line to the in-process dispatcher, so
no process starts and the process fake cannot see it. Add
install_mcp_dispatcher and a DispatcherFake with a contract suite, delete
the subprocess branch that only tests reached, and move the MCP tool
tests off the _run_mcp_cmd and run_subprocess patches.

Plans the work of #3760 (parent #1330).
@dan-petty dan-petty added type/refactor Type refactor: a new structure, same behavior scope/mcp Model Context Protocol tools, system resources, and prompts labels Nov 6, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check results.

  • Full uv run devops ci on the final code (before the last rebase over main): every row passes except test and coverage. test had 2 failures and 1 error, all from host conditions: test_mark_only_commands_under_global_dry_run and test_the_direct_executor_refuses_a_network_profile_before_it_starts_the_tool[direct] (popeye in the shared home volume). Both fail the same way on a checkout of main. coverage fails because test failed.
  • After the final rebase: tests/ai/mcp and tests/invariants pass (1198 tests).
  • The review of the branch gave four minors. Fixed: the dispatcher seam has its own bullet in docs/TESTING.md; the _answers type of DispatcherFake is exact. Skipped: a hanging-command case with the real dispatcher, because test_in_process_dispatcher_timeout_stops_command_within_budget and the contract suite already cover the real timeout path.
  • Scope note: the proposal lists what stays open in refactor(mcp): one dispatcher seam replaces the _run_mcp_cmd patches #3760 (the patches of devops_cli.ai.mcp.server.mcp, commands.mcp.run_mcp_server, mcp._list_tools, schema_violations and instructions, and the _COMMAND_SPECS import in tests/ai/mcp/test_mcp.py). This pull request covers the process patch and the dispatcher seam only.

@dan-petty
dan-petty marked this pull request as ready for review November 6, 2026 19:13
@dan-petty
dan-petty merged commit e50d0dc into main Nov 6, 2026
24 checks passed
@dan-petty
dan-petty deleted the refactor/1330-mcp-dispatcher-hook branch November 6, 2026 19:14
dan-petty pushed a commit that referenced this pull request Nov 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.72.0](v0.71.1...v0.72.0)
(2026-11-06)


### Features

* **roadmap:** rewrite a merged plan with plan-recheck
([#3832](#3832))
([7ea287b](7ea287b))


### Bug Fixes

* **roadmap:** refine job failure is no person wait
([#3833](#3833))
([378579a](378579a)),
closes [#3632](#3632)
* **roadmap:** the draft of a stopped step closes its issue
([#3831](#3831))
([5ca91e0](5ca91e0))


### Code Refactoring

* **mcp:** MCP tool tests install a dispatcher
([#3834](#3834))
([e50d0dc](e50d0dc)),
closes [#3760](#3760)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/mcp Model Context Protocol tools, system resources, and prompts type/refactor Type refactor: a new structure, same behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(mcp): one dispatcher seam replaces the _run_mcp_cmd patches

1 participant