Skip to content

fix(mcp): resolve server entry from dist/ instead of app/ - #3765

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.24from
megamen32:fix/mcp-server-entry-path
Jun 13, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.24from
megamen32:fix/mcp-server-entry-path

Conversation

@megamen32

Copy link
Copy Markdown
Contributor

Problem

omniroute --mcp crashes on npm installs with ERR_MODULE_NOT_FOUND: Cannot find package @/lib because:

  1. prepublish.ts Step 8.5 bundles open-sse/mcp-server/server.ts → dist/open-sse/mcp-server/server.js via esbuild (which correctly resolves @/ and @omniroute/open-sse path aliases at bundle time)
  2. But bin/mcp-server.mjs:14 looks for the compiled entry at app/open-sse/mcp-server/server.js — a legacy path from VPS deploys
  3. The npm package never has an app/ directory, so the .js entry is never found
  4. It falls back to open-sse/mcp-server/server.ts via tsx, which fails on tsx >= 4.22 because tsx can't resolve TypeScript path aliases at runtime

The compiled JS artifact was already present in the published tarball at dist/open-sse/mcp-server/server.js (2.6 MB) — it just wasn't found because the code was looking in the wrong directory.

Fix

Changed the preferred entry candidate from join(rootDir, "app", ...) to join(rootDir, "dist", ...) in bin/mcp-server.mjs. When present, the compiled JS runs directly without tsx — no path alias resolution needed.

Also updated the corresponding comment in scripts/build/assembleStandalone.mjs.

Testing

$ omniroute --mcp
[MCP] OmniRoute MCP Server starting (stdio transport)...
[MCP] OmniRoute MCP Server connected and ready.

diegosouzapw and others added 2 commits June 13, 2026 00:07
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.28.0 to 0.28.1.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](evanw/esbuild@v0.28.0...v0.28.1)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.28.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@megamen32
megamen32 requested a review from diegosouzapw as a code owner June 13, 2026 11:29

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the MCP server entrypoint path from app/open-sse/mcp-server/server.js to dist/open-sse/mcp-server/server.js in bin/mcp-server.mjs and updates the corresponding documentation in scripts/build/assembleStandalone.mjs. Feedback was provided regarding a violation of the Repository Style Guide (Rule 9), which requires adding or updating tests when modifying production code in the bin/ directory.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread bin/mcp-server.mjs
Comment on lines +14 to +15
// Preferred distributable JS entry (npm publish artifact, built by prepublish.ts)
join(rootDir, "dist", "open-sse", "mcp-server", "server.js"),

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.

medium

According to the Repository Style Guide (Rule 9), changing production code in bin/ requires including or updating tests. Please add or update tests (e.g., under tests/unit/) to verify that resolveMcpEntry correctly resolves the dist/ path.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

The prepublish.ts Step 8.5 bundles open-sse/mcp-server/server.ts into
dist/open-sse/mcp-server/server.js via esbuild, but bin/mcp-server.mjs
was looking for it at app/open-sse/mcp-server/server.js — a legacy path
used only on VPS deploys. This meant npm installs never found the
compiled JS entry and fell back to running the raw .ts via tsx, which
fails on tsx >= 4.22 due to unresolvable @/ and @omniroute/open-sse
path aliases.

Changes:
- bin/mcp-server.mjs: change app/ -> dist/ in resolveMcpEntry candidates;
  export and accept injectable existsSyncFn for testability
- scripts/build/assembleStandalone.mjs: update comment to reflect dist/
- tests/unit/mcp-server-entry.test.ts: new test verifying
  resolveMcpEntry resolves dist/, falls back to ts, returns null,
  checks candidates in order, and stays within rootDir
@megamen32
megamen32 force-pushed the fix/mcp-server-entry-path branch from afc491c to 4e0b060 Compare June 13, 2026 11:34
@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.24 June 13, 2026 11:54
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @megamen32 — verified and correct. prepublish.ts bundles the MCP server to dist/open-sse/mcp-server/server.js (and the published files array ships dist/, not app/), so the old app/ candidate never matched and the npm-published omniroute mcp fell through to the TS-source fallback. Pointing the resolver at dist/ (with the matching error message + assembleStandalone doc comment) fixes it, and making resolveMcpEntry export an injectable existsSync for the 7 unit tests is a nice touch. Validated 7/7 on the merged state. Merging into release/v3.8.24. 🙌

@diegosouzapw
diegosouzapw merged commit f3cc266 into cheaper-inference:release/v3.8.24 Jun 13, 2026
2 checks passed
@kilo-code-bot

kilo-code-bot Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The PR updates MCP server entry point resolution from app/ to dist/ directory, aligning with the prepublish build output. Key changes:

  1. bin/mcp-server.mjs: Correctly changed default path to dist/open-sse/mcp-server/server.js (matching prepublish.ts line 232 output location). Added export keyword and existsSyncFn parameter for testability. Error message updated to reflect new path.

  2. scripts/build/prepublish.ts: Added hard link guard (lines 312-320) to remove opencode-plugin/node_modules after build - prevents npm registry E415 error from hard links created on Linux CI runners.

  3. tests/unit/mcp-server-entry.test.ts: New test file provides comprehensive coverage for resolveMcpEntry including: preferred path resolution, fallback behavior, null returns, order verification, rootDir scoping, and real filesystem integration.

  4. scripts/build/assembleStandalone.mjs: Comment-only update aligning docs with new path.

  5. package-lock.json: Auto-generated esbuild 0.28.1 upgrade - excluded from review (generated file).

The existing comment requesting tests has been addressed by this PR.


Reviewed by laguna-m.1-20260312:free · 437,841 tokens

diegosouzapw added a commit that referenced this pull request Jun 13, 2026
…contributor credits

- Restructure [3.8.24] into ✨ Features / 🔒 Security / 🐛 Fixed / 📝 Maintenance
- Add bullets for every PR landed since v3.8.23 that was missing:
  marketplace (#3656), strict-mode CC defaults (#3776), emergency-fallback flag (#3752),
  xhigh effort (#3756), Codex memory WS (#3749), IPv6 egress (#3777),
  marketplace SSRF (#3774), CodeQL/Dependabot (#3778), anthropic sampling (#3780),
  thinking passthrough (#3775), mcp dist entry (#3765), streamed tool args (#3762),
  logs light-mode (#3760), clean-history purge (#3751), quality-gates (#3757),
  docs gaps (#3453), file-size re-baseline (#3770), E415 publish guard, i18n prune
- Move misplaced #3775 bullet out of [Unreleased] into [3.8.24]
- Date [3.8.23] header (TBD -> 2026-06-12, the release tag date)
@diegosouzapw diegosouzapw mentioned this pull request Jun 13, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…ference#3765)

fix(mcp): resolve server entry from dist/ instead of app/ — matches prepublish output + published files[]. Integrated into release/v3.8.24.
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…contributor credits

- Restructure [3.8.24] into ✨ Features / 🔒 Security / 🐛 Fixed / 📝 Maintenance
- Add bullets for every PR landed since v3.8.23 that was missing:
  marketplace (cheaper-inference#3656), strict-mode CC defaults (cheaper-inference#3776), emergency-fallback flag (cheaper-inference#3752),
  xhigh effort (cheaper-inference#3756), Codex memory WS (cheaper-inference#3749), IPv6 egress (cheaper-inference#3777),
  marketplace SSRF (cheaper-inference#3774), CodeQL/Dependabot (cheaper-inference#3778), anthropic sampling (cheaper-inference#3780),
  thinking passthrough (cheaper-inference#3775), mcp dist entry (cheaper-inference#3765), streamed tool args (cheaper-inference#3762),
  logs light-mode (cheaper-inference#3760), clean-history purge (cheaper-inference#3751), quality-gates (cheaper-inference#3757),
  docs gaps (cheaper-inference#3453), file-size re-baseline (cheaper-inference#3770), E415 publish guard, i18n prune
- Move misplaced cheaper-inference#3775 bullet out of [Unreleased] into [3.8.24]
- Date [3.8.23] header (TBD -> 2026-06-12, the release tag date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants