Repository navigation
Description
Problem or Motivation
Part of #1330. The MCP test files are named after libraries, or hold several behaviours in one file. A failing file does not say which behaviour broke. The tool listing that clients see has no snapshot, so a change to a tool name, description or input schema passes unseen.
Measured at origin/main 29309f0:
| File | Lines | Tests | Problem |
|---|---|---|---|
tests/ai/mcp/test_fastmcp_contracts.py |
1,686 | 61 | Six behaviours in one file: registry, prompts and resources, argv of tools, dispatch logging, domain hydration, argument refusal |
tests/ai/mcp/test_mcp.py |
851 | 27 | Tool exposure table, scan tools, server start, CLI and a catch-all |
tests/ai/mcp/test_fastmcp_in_process.py |
300 | 14 | Named after FastMCP, tests the dispatcher |
tests/ai/agents/test_pydantic_ai_toolsets.py |
342 | 13 | Named after the library. One class TestPydanticAIToolsetsSubsystem |
tests/ai/tools/test_pydantic_ai_tools.py |
134 | 5 | Named after the library. One class TestPydanticAIToolsSubsystem |
The tool listing: 145 tools are registered. The listing as JSON (name, description, input schema, sorted by name) is 124,234 characters when compact. It is 181,944 characters with two-space indentation, the form of a syrupy JSON snapshot. It is the same in two processes and with another HOME. It holds no absolute path. I checked this at 4a2d958 and re-ran the count of 145 tools at 29309f0.
Left out on purpose. These files are not in this child.
test_pydantic_agent.py,test_pydantic_ai_exceptions.py,test_pydantic_ai_native_capabilities.py,test_agent_invariants.pyandtest_ai_agent_deferred_tools.pytestPydanticAgentandrunner.py. refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 deletes or rewrites them. A rename or split now would conflict with it. The docs-catalog test intest_pydantic_ai_exceptions.pystays there until refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 touches the file.test_pydantic_ai_mcp.pyis deleted by child D.- The other
test_pydantic_ai_*files (concurrency,retries,settings,format_prompt,function_signature,profiles_and_providers,workflows,ollama) belong to other subsystems. test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331, which listed them, is closed as completed. This child does not touch them.
Proposed Solution & Architectural Design
Blocked by child B, which edits the MCP files heavily. Move code, keep test names, and keep each test body unchanged unless a rule below says otherwise. A reviewer then sees pure moves.
Proposed split. The implementer may adjust the names. Each name states a behaviour.
test_fastmcp_contracts.pybecomestest_mcp_tool_registry.py(registration, docstrings, annotations, mutating floor, published schemas, roadmap registration),test_mcp_prompts_and_resources.py,test_mcp_tool_argv.py(the argv each tool builds),test_mcp_dispatch_logging.py,test_mcp_domain_hydration.pyandtest_mcp_argument_refusal.py.test_mcp.pybecomestest_mcp_exposure_table.py(test_all_cli_commands_are_either_exposed_or_excluded),test_mcp_scan_tools.py(the semgrep and uv audit tools),test_mcp_run_command.py(the cases of_run_mcp_cmdfrom child B) andtest_mcp_server_start.py. What remains moves to the files above. Child B already moved the CLI cases totests/commands/test_mcp_serve.py.test_fastmcp_in_process.pybecomestest_mcp_dispatcher.py. The contract suite of child B stays intest_dispatcher_contract.py.test_pydantic_ai_toolsets.pybecomestest_agent_toolsets.py, andtest_pydantic_ai_tools.pybecomestest_agent_tools.py. The two library-named classes become plain test functions.
The snapshot. Add tests/ai/mcp/test_mcp_tool_listing.py. It reads the registered tools from the server with await mcp.list_tools(run_middleware=False). The test sorts the tools by name. It compares name, description and the input schema with one syrupy snapshot. Use syrupy's JSONSnapshotExtension, so a diff reads line by line. The snapshot is one file under tests/ai/mcp/__snapshots__/ of about 180 KB. If the owner prefers a smaller diff per review, split it by domain. I ran the listing in a scratch script. I did not write the snapshot test.
Acceptance criteria
- None of the five files above exists under its old name.
ls tests/ai/mcp/test_fastmcp_*.py tests/ai/mcp/test_mcp.py tests/ai/agents/test_pydantic_ai_toolsets.py tests/ai/tools/test_pydantic_ai_tools.pylists no file. - No test file that this child creates is longer than 600 lines.
- No test class or test function in the new files has
PydanticAIorpydantic_aiin its name. - The set of test names before and after is the same. The pull request body lists each exception as renamed, deleted with the reason, or new. A script in the pull request comment shows the diff of the two sets.
- The snapshot test passes. It fails when a test adds a parameter to one tool, and it passes again when the snapshot is updated with
--snapshot-update. The pull request body shows both runs. - The snapshot has 145 tools at the base commit, sorted by name. Two runs in two processes give identical files.
- No new patch of a
devops_cliname and no private import enters any moved file. -
uv run devops cipasses. Coverage does not fall. The pull request body gives the counts of test files and tests before and after.
Target Subsystem
tests/ai/mcp/, tests/ai/agents/test_pydantic_ai_toolsets.py, tests/ai/tools/. No change in src.
Existing Tool Considered
syrupy (https://github.com/syrupy-project/syrupy, pinned 6.1.1 in pyproject.toml) with its JSONSnapshotExtension. The repository already uses syrupy, for example for tests/ci/__snapshots__/test_fail_to_pass.ambr. FastMCP's own list_tools supplies the listing. Nothing is built.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(mcp)scope of the title gives the scope.It improves test clarity and adds a snapshot, but it is blocked by another child and is not urgent.A failing file will name the broken behaviour, and the snapshot catches unseen tool listing changes.Five files split into roughly twelve, plus one new snapshot test; bodies stay unchanged.Both split test files by behaviour, but #3748 works on roadmap tests and this candidate works on MCP tests.test(mcp): name the MCP, toolset and tool tests by behavior
test(mcp): name the MCP, toolset and tool tests by behavior