Skip to content

fix(mcp): include mcp_serve module in built wheel#22148

Closed
briandevans wants to merge 1 commit into
NousResearch:mainfrom
briandevans:fix/pyproject-include-mcp-serve-22110
Closed

fix(mcp): include mcp_serve module in built wheel#22148
briandevans wants to merge 1 commit into
NousResearch:mainfrom
briandevans:fix/pyproject-include-mcp-serve-22110

Conversation

@briandevans

@briandevans briandevans commented May 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

hermes mcp serve fails on NixOS and any other non-editable install with ModuleNotFoundError: No module named 'mcp_serve'. Root cause: the top-level mcp_serve.py module is not listed under [tool.setuptools] py-modules in pyproject.toml, so it is omitted from the built wheel. This PR adds it.

hermes_cli/mcp_config.py:749 does a top-level from mcp_serve import run_mcp_server. mcp_serve.py lives at the repo root and defines run_mcp_server at line 866. Setuptools' wheel build only includes top-level modules listed in py-modules. Every other top-level module that production code imports (run_agent, cli, batch_runner, hermes_bootstrap, …) is in that list — mcp_serve was the lone omission. Editable installs (pip install -e .) are unaffected because the repo root is on sys.path, which is why dev and CI did not catch it.

Related Issue

Fixes #22110

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

  1. Build the wheel from a clean checkout: uv build --wheel
  2. Inspect the artifact contains the module: unzip -l dist/hermes_agent-*.whl | grep mcp_serve.py
  3. Inspect top_level.txt lists it: unzip -p dist/hermes_agent-*.whl hermes_agent-*.dist-info/top_level.txt | grep mcp_serve
  4. Install into a fresh non-editable env and run hermes mcp serve — the ModuleNotFoundError is gone.

Before/after of the wheel artifact:

# Before
unzip -l hermes_agent-*.whl | grep mcp_serve.py    # no output
unzip -p hermes_agent-*.whl ...top_level.txt | grep -c mcp_serve    # 0

# After
unzip -l hermes_agent-*.whl | grep mcp_serve.py    # 31690 ... mcp_serve.py
unzip -p hermes_agent-*.whl ...top_level.txt | grep mcp_serve    # mcp_serve

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run focused verification (wheel inspection — there is no pytest path for this packaging bug)
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features) — N/A, packaging-only fix verified via wheel inspection
  • I've tested on my platform: macOS 15.x

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — packaging fix is platform-independent
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Related / Positioning

Audited siblings: confirmed every other top-level .py module that production code imports (run_agent, cli, batch_runner, hermes_bootstrap, mcp_serve after this change, …) is now present in [tool.setuptools] py-modules. No widening needed.

Screenshots / Logs

File ".../site-packages/hermes_cli/mcp_config.py", line 749, in mcp_command
    from mcp_serve import run_mcp_server
ModuleNotFoundError: No module named 'mcp_serve'

Copilot AI review requested due to automatic review settings May 9, 2026 00:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a packaging issue where hermes mcp serve fails in non-editable installs because the top-level mcp_serve.py module was not included in the built wheel.

Changes:

  • Add mcp_serve to [tool.setuptools].py-modules so it’s included in wheel builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard tool/mcp MCP client and OAuth area/nix Nix flake, NixOS module, container packaging labels May 9, 2026
@briandevans briandevans force-pushed the fix/pyproject-include-mcp-serve-22110 branch 2 times, most recently from e3a11b7 to 4ba8d56 Compare May 12, 2026 06:16
@briandevans

Copy link
Copy Markdown
Contributor Author

CI audit — 3 of 4 failing checks on this PR are pre-existing baselines on clean origin/main (c1eb2dcda). The 4th (uv lock --check) is also pre-existing and unrelated to this packaging-only PR.

Job Symptom Root cause on main
test / e2e (Tests workflow) uv pip install -e .[all,dev] fails: Because there are no versions of mistralai and hermes-agent[all]==0.13.0 depends on mistralai>=2.3.0,<3 pyproject.toml on main pins mistralai>=2.3.0,<3 but no satisfying version is currently resolvable on PyPI. Reproduces on main's own scheduled Tests run 25716556968 (commit 99ad2d137).
Windows footguns (blocking) (Lint workflow) tools/process_registry.py:588: [bare os.killpg] / [bare signal.SIGKILL] Pre-existing on main: os.killpg(os.getpgid(proc.pid), signal.SIGKILL) at tools/process_registry.py:588. Reproduces on main's own scheduled Lint run 25721601431 (commit c1eb2dcda).
uv lock --check Same mistralai>=2.3.0,<3 resolution failure Same root cause as the Tests jobs.

This PR only adds mcp_serve to [tool.setuptools].py-modules; it does not touch mistralai or tools/process_registry.py. Happy to address any review comments — just flagging that the red CI badge here isn't from this PR.

@briandevans briandevans force-pushed the fix/pyproject-include-mcp-serve-22110 branch from 4ba8d56 to d2b94a2 Compare May 14, 2026 19:15
@briandevans briandevans requested a review from a team May 14, 2026 19:15
@briandevans briandevans force-pushed the fix/pyproject-include-mcp-serve-22110 branch from d2b94a2 to 51a0337 Compare May 19, 2026 00:26

@austinpickett austinpickett left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .github/PULL_REQUEST_TEMPLATE.md

@briandevans

Copy link
Copy Markdown
Contributor Author

@austinpickett thanks for the flag — updated the PR body to follow .github/PULL_REQUEST_TEMPLATE.md. No code change in this push; the wheel-packaging fix in pyproject.toml is unchanged.

@briandevans briandevans force-pushed the fix/pyproject-include-mcp-serve-22110 branch 2 times, most recently from f3bd35c to 9eaa382 Compare May 25, 2026 03:11
The `mcp_serve` top-level module was missing from the `py-modules` list in
pyproject.toml, so non-editable installs (e.g. NixOS, downstream packagers)
omitted it from the built wheel. `hermes mcp serve` then crashed with
`ModuleNotFoundError: No module named 'mcp_serve'` because
hermes_cli/mcp_config.py imports it via `from mcp_serve import run_mcp_server`.

Editable installs (`pip install -e .`) sidestep this because they add the
repo root to sys.path, which is why dev workflows never noticed.

Same shape of fix as the previous packaging gap caught for `minisweagent_path`
(PR NousResearch#2098).

Fixes NousResearch#22110

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Duplicate of #35044, which targets current main and merged cleanly (a57cc00). Your PR was submitted first and is the identical fix — credited in the merge discussion. Thanks @briandevans.

@teknium1 teknium1 closed this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/nix Nix flake, NixOS module, container packaging comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes mcp serve fails to start on NixOS

5 participants