feat: add MCP contract testing for distributed AI systems#21
Merged
Conversation
…tection Adds the ability to snapshot external MCP server tool definitions and detect breaking changes (removed tools, new required params, type changes) before running tests. This addresses Scenario 2 of distributed AI evaluation: when you don't own the MCP server code. New commands: evalview mcp snapshot/check/list/show/delete New flag: evalview run --contracts --fail-on CONTRACT_DRIFT New CI status: CONTRACT_DRIFT (joins REGRESSION, TOOLS_CHANGED, OUTPUT_CHANGED) https://claude.ai/code/session_019CvwYcAoNoitWBdhEYUbxV
1. BUG: asyncio.run() nested inside run_in_executor in _run_async (already in an async context). Fixed to just await directly. 2. BUG: Contract check ran before fail_on resolved from config.yaml defaults, so config-based fail_on: [CONTRACT_DRIFT] was ignored. Moved contract check after config loading. 3. BUG: _discover_tools_http missing notifications/initialized after init (inconsistent with stdio path, violates MCP protocol). 4. BUG: _discover_tools_http didn't check init response for errors. 5. BUG: DiffStatus docstring said "Four states" but now has five. Also fixed: unused Optional import, duplicate datetime imports, variable shadowing (adapter/result in _run_async contract block). https://claude.ai/code/session_019CvwYcAoNoitWBdhEYUbxV
… test gaps 1. action.yml: When both diff=true and contracts=true, --fail-on was appended twice. Refactored to set it once after both flags. 2. mcp_adapter: _discover_tools_http incremented _request_id before the notification. JSON-RPC notifications don't carry an id, so incrementing is semantically wrong (wastes an id for the next call). 3. Tests: Removed unused Path import. Added test for summary() with mixed breaking + informational changes. Added test for duplicate tool names in current_tools (edge case). https://claude.ai/code/session_019CvwYcAoNoitWBdhEYUbxV
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.
Summary
Test plan
tests/test_mcp_contracts.py(495 lines)evalviewCLI with MCP contract commands🤖 Generated with Claude Code