Repository navigation
fix(cli): add POST /api/mcp/restart and mcp enable/disable subcommands (#13012) - #13770
Merged
Merged
Conversation
#13012) `bin/cli/commands/mcp.mjs::runMcpRestartCommand` POSTs to /api/mcp/restart, but that route never existed under src/app/api/mcp/ — every `omniroute mcp restart` call 404d. There was also no CLI/env path to flip the mcpEnabled setting on: it was dashboard-only (/dashboard/mcp -> PATCH /api/settings), stranding headless/portable installs (Windows portable Node, no browser session) with no way to reach the MCP server's 110 tools. Adds the missing route (auth-gated via requireManagementAuth, 409 when disabled, 501 for stdio since HTTP/SSE sessions are the only in-process handle shutdownMcpHttp() can tear down) plus `omniroute mcp enable [--transport stdio|sse|streamable-http]` / `mcp disable`, which PATCH /api/settings the same way the dashboard toggle does. `mcp status` now hints at `mcp enable` when it reports the server stopped because it is disabled. Regression tests: tests/unit/mcp-restart-route-13012.test.ts (route behavior across disabled/stdio/http-family states + LOCAL_ONLY classification) and tests/unit/cli-mcp-enable-disable-13012.test.ts (PATCH body shape).
diegosouzapw
force-pushed
the
fix/13012-cli-mcp-restart-404-no
branch
from
September 15, 2026 22:55
bc17568 to
fd030b4
Compare
…2-cli-mcp-restart-404-no
HouMinXi
added a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Sep 16, 2026
…soning-effort test (cheaper-inference#13866) - Run agent skills generator to sync skills/cli-mcp/SKILL.md with mcp enable/disable subcommands added in cheaper-inference#13770 - Hydrate providerSpecificData.baseUrl in SimpleExecutor for reasoning-effort-clamp-and-retry.test.ts to satisfy cheaper-inference#13798 requireCompatibleBaseUrl guard Signed-off-by: Minxi Hou <houminxi@gmail.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
cheaper-inference#13012) (cheaper-inference#13770) Merged in the 2026-09-16 sweep of the maintainer's own open PRs, at the owner's explicit instruction. No push was made to the PR branch: the merge took the head as the owning session left it (verified OPEN, non-draft and MERGEABLE against the release tip immediately before merging).
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.
Refs #13012
Not covered here: Bug 1 (
config set <tool>crashing on the@/alias) — already fixed at tip bybin/aliasResolver.mjsper the owner's 2026-09-10 comment on the issue; this PR only addresses Bug 2 (mcp restart404 + no CLI/env path to enable MCP).Root cause
bin/cli/commands/mcp.mjs::runMcpRestartCommandPOSTs to/api/mcp/restart, but that route file has never existed undersrc/app/api/mcp/(audit/,sse/,status/,stream/,tools/only) — everyomniroute mcp restartcall 404s regardless of OS. Separately,mcpEnabled(defaultfalse,src/lib/db/settings.ts:174) was documented as dashboard-only — no CLI command, flag, or env var anywhere in the codebase could flip it — so a headless/portable install (the reporter's Windows portable-Node case) had no way to reach the MCP server's 110 tools.Fix
src/app/api/mcp/restart/route.ts— newPOSThandler, gated byrequireManagementAuth(sameacceptMcpConnectScopecarve-out as the other/api/mcp/*transport routes). Returns409whenmcpEnabledis false,501for thestdiotransport (stdio clients own their own subprocess — there's no in-process handle to restart), and otherwise calls the already-exportedshutdownMcpHttp()to tear down activesse/streamable-httpsessions so the next request re-initializes cleanly.bin/cli/commands/mcp.mjs— newomniroute mcp enable [--transport stdio|sse|streamable-http]/omniroute mcp disablesubcommands thatPATCH /api/settingsthe same way the dashboard's MCP page does ({mcpEnabled, mcpTransport}).mcp restart's error path now surfaces the route's JSONerrormessage instead of a bareHTTP 409.mcp statusprints amcp enablehint when it reports the server stopped becausemcpEnabledis false.en/zh-CN/zh-TW(full parity required bycheck:cli-i18n);pt-BRneeds no new top-level section.docs/frameworks/MCP-SERVER.mdupdated to document the new CLI commands (verified command names and route behavior against source before writing)./api/mcp/was already inLOCAL_ONLY_API_PREFIXES(src/server/authz/routeGuard.ts), so the new route inherits that classification automatically — pinned by an explicit test per Hard Rule #15.Regression tests
tests/unit/mcp-restart-route-13012.test.ts— RED on unfixed code (module doesn't exist):GREEN after the fix:
tests/unit/cli-mcp-enable-disable-13012.test.ts— pins themcp enable/mcp disablePATCH body shape (4/4 passing).Gates run
npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files>— 0 errors, 0 warnings on touched lines.npm run typecheck:core— exit 0.npm run check:cli-i18n— passes for the newmcp.*keys (fullzh-CN/zh-TWparity,pt-BRtop-level parity); pre-existing unrelated failureserve.ready_timeoutconfirmed present onorigin/release/v3.8.51before this branch (base drift, not mine).node scripts/check/check-file-size.mjs— no new violation (pre-existingopen-sse/utils/stream.tsfrozen-size violation is unrelated/untouched).node scripts/check/check-complexity.mjs/check-cognitive-complexity.mjs— both well under baseline (2824/3218, 1276/1437).node scripts/check/check-test-discovery.mjs— OK, new test files discovered.tests/unit/cli-mcp-call-commands.test.ts,tests/unit/cli-server-commands.test.ts,tests/unit/security-route-guard-tiers.test.ts,tests/unit/check-route-guard-membership.test.ts(17/17).npm run check:docs-all— 1 pre-existing STRICT failure (Code-derived counts — readCodeFacts unavailable — tsx/spawnSync failed, a nested-tsx subprocess that imports unrelated provider/catalog modules) and a pre-existing soft "Executors count: 111" drift ondocs/architecture/ARCHITECTURE.md— both unrelated to this PR's content and not caused by it (base, not mine).Existing tests aligned
None needed — no existing assertion encoded the old buggy contract.
Reporter credit: thanks @ricardusx for the original report.