molecule-ai-workspace-runtime/molecule_runtime
rabbitblood 18d904cfc1 fix: MCP server path resolution + absolute imports (2nd half of #507)
The a2a MCP subprocess was launched with a hard-coded /app/a2a_mcp_server.py
path that only existed in the legacy workspace-template layout. Current
templates copy adapter.py into /app but not the MCP server script, so
claude-code's mcp_servers={"a2a": ...} config spawned a non-existent file,
the server never registered any tools, and every agent reported that
search_memory / commit_memory / list_peers / delegate_task / send_message_to_user
were unavailable in the tool registry.

Surfaced this cycle after the CRLF hook fix (PR molecule-core#508 +
plugin repo's .gitattributes) unblocked the primary (no response generated)
symptom. Before that, agents crashed before the missing-MCP issue was
observable — the two bugs stacked.

Changes
-------
* executor_helpers._default_mcp_server_path: resolves the installed
  molecule_runtime.a2a_mcp_server module's __file__ so the path is
  always correct regardless of template layout. Legacy /app path kept
  as last-resort fallback for any old images still in rotation.
* a2a_mcp_server.py, a2a_tools.py, a2a_client.py: convert bare module
  imports (from a2a_tools import ...) to absolute
  (from molecule_runtime.a2a_tools import ...). Previously this worked
  only when main.py injected the package dir onto sys.path; the MCP
  subprocess doesn't go through main.py, so the bare imports would fail.
  Added a sys.path shim at the top of a2a_mcp_server.py so running as a
  standalone script (python path/to/a2a_mcp_server.py) still works —
  the subprocess can now locate the package root automatically.
* consolidation.py, heartbeat.py, main.py: same bare-to-absolute
  conversion for platform_auth imports (unblocks the same class of
  failure if any of these modules are imported from a non-main.py
  entrypoint in the future).

Verification
------------
Deployed the updated files into ws-8010dbd0 (PM) and ran an isolated
sdk.query() as agent user. SystemMessage.init.mcp_servers now reports
[{'name': 'a2a', 'status': 'connected'}] and the tools list includes
all 8 mcp__a2a__* entries:
  mcp__a2a__check_task_status, mcp__a2a__commit_memory,
  mcp__a2a__delegate_task, mcp__a2a__delegate_task_async,
  mcp__a2a__get_workspace_info, mcp__a2a__list_peers,
  mcp__a2a__recall_memory, mcp__a2a__send_message_to_user

Rolled the in-container hotfix across all 22 workspaces pending release
(docker cp the 4 changed files into each site-packages/molecule_runtime/).

Fixes Molecule-AI/molecule-core#507 (secondary)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 13:28:57 -07:00
..
adapters feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
builtin_tools fix: switch top-level from adapters import to absolute imports (#1) 2026-04-16 07:53:03 -07:00
plugins_registry feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
policies feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
skill_loader feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
__init__.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
a2a_cli.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
a2a_client.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
a2a_executor.py fix: switch top-level from adapters import to absolute imports (#1) 2026-04-16 07:53:03 -07:00
a2a_mcp_server.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
a2a_tools.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
agent.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
claude_sdk_executor.py fix: gate session resume on file existence (closes #488) 2026-04-16 11:12:03 -07:00
cli_executor.py fix: gate session resume on file existence (closes #488) 2026-04-16 11:12:03 -07:00
config.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
consolidation.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
coordinator.py fix: switch top-level from adapters import to absolute imports (#1) 2026-04-16 07:53:03 -07:00
events.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
executor_helpers.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
heartbeat.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
initial_prompt.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
main.py fix: MCP server path resolution + absolute imports (2nd half of #507) 2026-04-16 13:28:57 -07:00
molecule_ai_status.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
platform_auth.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
plugins.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
preflight.py fix: gate session resume on file existence (closes #488) 2026-04-16 11:12:03 -07:00
prompt.py fix: switch top-level from adapters import to absolute imports (#1) 2026-04-16 07:53:03 -07:00
transcript_auth.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00
watcher.py feat: initial release of molecule-ai-workspace-runtime 0.1.0 2026-04-16 04:26:06 -07:00