fix(mcp): auto-fall-back to user-installed providers.json; backfill UNIFIED_PROVIDERS_CONFIG#162
Conversation
Even on a fresh Claude Code session with all merged fixes pulled, every
vanilla MCP slot (codex-1, gemini-1, opencode-1, copilot-1, claude-1)
exits with "Unknown PROVIDER_SLOT" on launch and never registers its
tools. Root cause:
The mcpServers entries in ~/.claude.json that /nf:mcp-setup created
historically have only `env: { PROVIDER_SLOT: <name> }` — no pointer to
where the per-slot config lives. unified-mcp-server defaults to
`__dirname/providers.json`, which ships intentionally empty (populated
at install time into ~/.claude/nf/bin/providers.json). So the spawned
server sees zero providers, can't find PROVIDER_SLOT, and exits.
Two complementary fixes:
1. bin/unified-mcp-server.mjs: when neither UNIFIED_PROVIDERS_CONFIG nor
a populated repo-source providers.json is available, fall back to
~/.claude/nf/bin/providers.json. This self-heals existing user installs
with no install re-run required.
2. bin/install.js: when creating new mcpServers entries OR re-processing
existing ones, set UNIFIED_PROVIDERS_CONFIG explicitly to the
user-installed path. Old entries get backfilled on next install so
the env is self-documenting going forward.
Verified live: spawning the server with only `PROVIDER_SLOT=codex-1` (no
explicit config env) now resolves all 5 CLI binaries and health_check
returns healthy:true at 38ms — previously exited with "Unknown
PROVIDER_SLOT" at session start.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adding the loadProvidersConfig() helper shifted two pre-existing baselined hashes by 28 lines (490→518, 920→948). Hashes unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP slot startup failures by ensuring unified-mcp-server can always find a populated providers.json, even for older MCP entries that only set PROVIDER_SLOT. It introduces a runtime fallback to the user-installed providers config and updates the installer to explicitly set/backfill UNIFIED_PROVIDERS_CONFIG in ~/.claude.json.
Changes:
- Add providers config resolution precedence in
unified-mcp-server.mjs(env override → repo source if populated → user-installed copy). - Backfill
UNIFIED_PROVIDERS_CONFIGinto existing~/.claude.jsonmcpServersentries during install, and set it for newly-created entries. - Refresh
.secrets.baselineline references due to code movement.
Reviewed changes
Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bin/unified-mcp-server.mjs | Adds config loading logic to fall back to the user-installed providers.json when the repo copy is empty/unset. |
| bin/install.js | Ensures MCP server entries always include UNIFIED_PROVIDERS_CONFIG, including backfilling older entries. |
| .secrets.baseline | Updates stored line numbers / generated timestamp after code shifts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…mpty (#163) PR #162 added a backfill loop that sets UNIFIED_PROVIDERS_CONFIG on existing mcpServers entries — but it lives in the non-empty branch of ensureMcpSlotsFromProviders, which never runs when bin/providers.json (repo source) is empty. The empty case is the typical install state (providers.json is populated at install time into ~/.claude/nf/bin/), so the backfill never actually executed for any normal user. Fix: add the same backfill inline in the empty-source branch, right after the reconstructed providers.json is written. Iterates the same mcpSlots list used to build the reconstructed file. Self-heals 5 vanilla entries (codex-1, gemini-1, opencode-1, copilot-1, claude-1) on first install after this lands. Verified live: stripped UNIFIED_PROVIDERS_CONFIG from 5 entries, ran install, all 5 were backfilled cleanly. Co-authored-by: jobordu <jonathan@jonathanborduas.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Closes the real root cause of the persistent
unhealthy@1ms/errorstate in/nf:mcp-statusthat PRs #158 / #159 / #161 didn't fully address. Even on a fresh Claude Code session with all prior fixes pulled into main, every vanilla MCP slot still exits withUnknown PROVIDER_SLOTand never registers its tools.Root cause
The mcpServers entries that
/nf:mcp-setuphistorically created have onlyenv: { PROVIDER_SLOT: <name> }— noUNIFIED_PROVIDERS_CONFIG. The MCP server defaults to__dirname/providers.json, which ships intentionally empty (populated at install time into~/.claude/nf/bin/providers.json). So the spawned server sees zero providers, can't find its PROVIDER_SLOT, and exits before any tools register.Fix
Two complementary changes:
1.
bin/unified-mcp-server.mjs— when neitherUNIFIED_PROVIDERS_CONFIGnor a populated repo-sourceproviders.jsonis available, fall back to~/.claude/nf/bin/providers.json. This self-heals existing user installs with zero install re-run required — the next session start picks up the right config.Precedence: explicit env → populated repo source → user-installed copy.
2.
bin/install.js— when creating mcpServers entries OR re-processing existing ones, setUNIFIED_PROVIDERS_CONFIGexplicitly. Old entries get backfilled on next install so the env is self-documenting going forward.Verified live
Previously: exited with
Unknown PROVIDER_SLOT: codex-1at session start.Test plan
npm run test:ci— 1550 pass, 0 failnpm run lint:isolation— cleannpm run check:assets— cleanPROVIDER_SLOTenv, noUNIFIED_PROVIDERS_CONFIG→ starts cleanly, health_check returns healthy:true/nf:mcp-statusshows all 7 slotsavailable🤖 Generated with Claude Code