Clarify missing tool_result validation error

Closed
HA
1mo ago
+19-0

Summary

  • keep tool_use / tool_result balance validation strict
  • split the missing-follow-up case into a clearer ValueError
  • add a direct regression test for an assistant tool_use followed by user text instead of tool_result

Related to #2960. This PR does not relax the balance rule; it only makes the diagnostic distinguish a missing tool_result from an ID mismatch when a tool_use is followed by a non-result message.

Tests

  • uv run --frozen pytest tests/server/test_validation.py -q
  • uv run --frozen ruff check src/mcp/server/validation.py tests/server/test_validation.py
  • uv run --frozen ruff format --check src/mcp/server/validation.py tests/server/test_validation.py
  • git diff --check