fix(packaging): ship mcp_serve.py + mini_swe_runner.py — missing from py-modules (closes #80)#81
Merged
Merged
Conversation
… py-modules (closes #80)
This was referenced May 24, 2026
PowerCreek
added a commit
that referenced
this pull request
May 24, 2026
Layer 2 of the #67 cascade: post-#79 (register-ctx) + #81 (mcp_serve packaging), the bundled MCP server now ships and the G2/G3/G4 plugins load — but no MCP server entry pointed at it, so workers booted with zero MCP-side tools. This adds the missing wiring. Three edits: 1. mcp_serve.py — `if __name__ == "__main__":` block so `python -m mcp_serve` runs the existing stdio server. Honors `--verbose`/`-v` for subprocess debugging. 2. hermes_cli/mcp_autowire.py (new) — ensure_internal_mcp_server() idempotently inserts a `hermes-internal` entry under `mcp_servers` in the active profile config. Uses sys.executable + [-m, mcp_serve] so the spawn survives venv-not-on-PATH installs (the typical container-deploy shape). Opt-out via HERMES_DISABLE_INTERNAL_MCP=1. 3. tui_gateway/entry.py — calls ensure_internal_mcp_server() BEFORE the read_raw_config()::mcp_servers gate, so the gate sees the freshly-written entry on the same boot and discover_mcp_tools() picks it up. Issue body proposed `.mcp.json` (Claude-Code-style separate file); the actual config file is ~/.hermes/config.yaml under the `mcp_servers` key (the same location `tools/mcp_tool.py` reads via `hermes_cli.config.load_config`). This patch targets the real config. Tests (tests/test_internal_mcp_autowire.py — 20 cases): - HERMES_DISABLE_INTERNAL_MCP truthy variants all opt out - Idempotent: re-call is a no-op - Existing operator MCP servers (Linear/Notion/...) preserved - Creates `mcp_servers` key when absent - Command is sys.executable (not literal "python") - Args are [-m, mcp_serve] (catches the spawn-shape regression) - Source-level: mcp_serve has __main__ guard invoking run_mcp_server - Source-level: entry.py calls ensure_internal_mcp_server() BEFORE the read_raw_config gate (catches ordering regression) Smoke verified: `timeout 3 python3 -m mcp_serve < /dev/null` → exit 0 (stdio handshake; closes loop cleanly on stdin EOF). After container rebuild + worker spawn, poly-explorer should have end-to-end tool access (final layer of the cascade started at #67).
This was referenced May 24, 2026
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.
Closes #80 layer 1 (packaging). Layer 2 (runtime auto-start of mcp_serve when worker spawns) deferred to a follow-up issue.
Root cause (Layer 1)
`[tool.setuptools]` `py-modules` list omitted `mcp_serve` (and `mini_swe_runner`). Setuptools' `packages.find` only picks up Python PACKAGES (dirs with `init.py`), not top-level modules. So both were silently dropped from the wheel → `from mcp_serve import run_mcp_server` raises ImportError at runtime → no MCP server can be started from the installed wheel.
Fix
Add `mcp_serve` + `mini_swe_runner` to the py-modules list.
End-to-end verification
Built the wheel + inspected zip contents:
```
mcp_serve.py in wheel: True
mini_swe_runner.py in wheel: True
```
Test plan
Layer 2 (NOT in this PR — deferred)
Even with mcp_serve.py shipped, the MCP server doesn't auto-start when a worker session spawns. Architecture:
So for a worker to access grafted_context_fetch / silo_query / confer_run / file_issue / lane_h_*:
None of this auto-happens for polynomial-explorer (or any vertical) worker today. Operator-side wiring is undocumented + undelivered. I'll file the Layer 2 issue after this lands.
Combined deploy chain (post-#80)