feat(runtime#38): SSOT public surface for MCP tool schemas + target resolution #155
Reference in New Issue
Block a user
Delete Branch "fix/38-mcp-tool-ssot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #38 (parent: internal#638).
Problem
The universal Molecule communication contract (tool schemas + target resolution) was previously split across multiple modules:
molecule_runtime.mcp_tools(MCP-shape adapter of the platform tool list)molecule_runtime.platform_tools.registry(the actual tool specs —ToolSpecdataclass)molecule_runtime.mcp_workspace_resolver(env-driven multi-workspace resolution)Adapters (a2a_mcp_server, future LangChain/SDK integrations) consumed the contract via direct imports. A future refactor of any of those modules would silently fork the contract at adapter runtime, with no drift test to surface the divergence.
The issue's RCA from internal#638: this split is what allowed
send_message_to_userto be registered in MCP TOOLS but absent from the executor_helpers doc string, leaving agents with a silent capability regression. Drift prevention was the goal.Fix
Two new SSOT public-surface modules + drift tests + README. Adapters are shims; base MCP/runtime is the source of truth.
molecule_runtime/mcp_schemas.py— re-exportsMOLECULE_MCP_TOOLS,openai_function_tools(),PERMISSION_MAP; addsget_tool_schema(name)(returns the registry'sinput_schemafor one tool, identity-not-equality) andvalidate_adapter_schemas(adapter_tools)(drift check that returns{missing, extra}lists).molecule_runtime/mcp_target_resolution.py— re-exportsresolve_workspaces,read_token_file,print_missing_env_help; addsresolve_target_for_adapter()(single-tenant convenience: returns the first resolved target as a dict, orNone).tests/test_mcp_ssot.py— 15 drift tests pinning three contracts:__all__is the stable export name).a2a_mcp_server.TOOLSis asserted to be a strict subset of the SSOT (no missing tools, no extra tools). OpenAI function tools derive from the same SSOT.resolve_target_for_adapter()round-trips.README.md— added the "MCP SSOT public surface (issue #38)" section explicitly stating the contract ("Adapters are shims; base MCP/runtime is SSOT").No production code changed — the modules are new, the tests are new, the README is new. The SSOT is additive; existing imports of
mcp_tools/platform_tools.registry/mcp_workspace_resolverkeep working unchanged.Test plan
tests/test_mcp_ssot.py— all pass locally.MOLECULE_MCP_TOOLSinto a different module) — that's the whole point of the SSOT public surface.SOP checklist
go build ./...n/a (Python repo).python3 -m pytest tests/ --ignore=tests/integration— 668 passed, 1 skipped. The 15 new SSOT tests cover all 3 contracts (public surface identity, adapter conformance, env-driven resolution).smoke-installCI job will install the wheel in a clean venv and import all canonical surfaces, including the newmcp_schemasandmcp_target_resolution.__all__as the source of truth for the public surface), security (no new attack surface — re-exports only), performance (no measurable overhead — re-exports are O(1) at import time), readability (module docstrings explain the contract and the drift-prevention rationale).feedback_no_single_source_of_truth(the SSOT public surface is the structural fix for the contract split that allowed thesend_message_to_usersilent regression),feedback_no_such_thing_as_flakes(the drift tests pin the contract — if a future refactor breaks it, the test fails LOUDLY, not silently).REQUEST_CHANGES: Correctness issue in the new public target-resolution contract docs/tests.
molecule_runtime/mcp_target_resolution.pyandtests/test_mcp_ssot.pydescribeMOLECULE_WORKSPACES_JSONas a supported multi-workspace env shape / alias, but the underlyingmcp_workspace_resolver.resolve_workspaces()only readsMOLECULE_WORKSPACES. Because this PR is creating the SSOT public surface for adapters, documenting an unsupported env var would cause adapter authors to follow a contract that does not work. Please either add real resolver support + tests forMOLECULE_WORKSPACES_JSON, or remove those references and state onlyMOLECULE_WORKSPACESis supported. Other axes: no security/perf concerns in the re-export wrappers; CI is green; readability is otherwise good.APPROVED on
7c11d44d. The prior MOLECULE_WORKSPACES_JSON public-contract mismatch is resolved: current diff contains no MOLECULE_WORKSPACES_JSON references; the SSOT docs/tests now pin the supported multi-workspace JSON env shape as MOLECULE_WORKSPACES, matching the resolver. CI combined status is green.5-axis re-review: APPROVED at head
7c11d44d.The prior public-contract mismatch is resolved: there are no remaining
MOLECULE_WORKSPACES_JSONreferences, and the documented/tested multi-workspace shape is the supportedMOLECULE_WORKSPACESJSON array of{id, token, platform_url}objects.mcp_target_resolutionre-exports the realmcp_workspace_resolverfunctions by identity, and tests exercise legacy env, token-file fallback, and multi-workspace JSON throughresolve_workspaces()rather than a parallel parser.Correctness/robustness/readability are clean for the SSOT surface; no security or performance regression. CI is green and mergeable=true.