96007ebd77
Phase 1 of any_type_componentization_20260621. Promotes MCP_TOOL_SPECS
(45 dict[str, Any] literals in src/mcp_client.py) to typed dataclasses:
NEW src/mcp_tool_specs.py:
- ToolParameter dataclass (name, type, description, required, enum)
- ToolSpec dataclass (name, description, parameters: tuple)
- _REGISTRY: dict[str, ToolSpec]
- register() / get_tool_spec() / get_tool_schemas() / tool_names()
- to_dict() preserves legacy JSON shape for downstream serialization
- 45 register() calls (one per tool) at module level
- Mirrors src/vendor_capabilities.py reference pattern
NEW tests/test_mcp_tool_specs.py (11 tests, all pass):
- test_module_loads_with_45_registrations
- test_tool_names_set_matches_expected_45
- test_get_tool_spec_returns_correct_instance
- test_get_tool_spec_raises_for_unknown_name
- test_get_tool_schemas_returns_all_specs
- test_tool_spec_is_frozen
- test_tool_parameter_is_frozen
- test_to_dict_round_trip_preserves_shape
- test_tool_parameter_to_dict_includes_enum
- test_tool_names_subset_of_models_agent_tool_names (cross-module invariant)
- test_register_idempotent_replaces_existing (hot-reload support)
NEW scripts/tier2/artifacts/any_type_componentization_20260621/:
- generate_mcp_tool_specs.py: idempotent generator from MCP_TOOL_SPECS
- generate_tool_specs.py: helper that emits registration lines
- inspect_mcp_specs.py: shape inspection
- _generated_registrations.txt: the 45 registration lines
Verified: 11/11 tests pass. The legacy MCP_TOOL_SPECS dict in mcp_client.py
still exists; this commit only ADDS the new module. Migration of call sites
in mcp_client.py + ai_client.py follows in t1_4 + t1_5.
Verified with:
uv run pytest tests/test_mcp_tool_specs.py --timeout=30
11 passed in 3.01s