Skip to content

🧰 fix: Scope MCP Registry Initialization To Config Fingerprints#13115

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/fix-mcp-config-rollout-cache
May 13, 2026
Merged

🧰 fix: Scope MCP Registry Initialization To Config Fingerprints#13115
danny-avila merged 1 commit into
devfrom
danny-avila/fix-mcp-config-rollout-cache

Conversation

@danny-avila

@danny-avila danny-avila commented May 13, 2026

Copy link
Copy Markdown
Owner

Summary

I fixed MCP registry initialization so rolling deployments with shared Redis do not reuse stale startup state from a different LibreChat config or hang behind an older leader pod.

  • Scope the shared MCP registry initialized marker to a stable fingerprint of configured MCP servers and MCP allowlists.
  • Reinitialize the registry when a pod sees an initialized marker for a different config, including follower-to-leader retry paths.
  • Bound follower waits for stale config fingerprints and allow the current instance to initialize after the leader wait is exhausted.
  • Preserve the existing skip path for repeated initialization with the same config in a single process.
  • Add regression coverage for stale config fingerprints, follower behavior during rolling deployment, and stale follower timeout fallback.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • npm run reinstall
  • npx jest src/mcp/registry/__tests__/MCPServersInitializer.test.ts --runInBand
  • USE_REDIS=true REDIS_URI=redis://127.0.0.1:6387 REDIS_KEY_PREFIX=MCPRollingLocalTest4 REDIS_RETRY_MAX_ATTEMPTS=2 npx jest src/mcp/registry/__tests__/MCPServersInitializer.cache_integration.spec.ts --runInBand --coverage=false --forceExit --silent
  • USE_REDIS=true REDIS_URI=redis://127.0.0.1:6387 REDIS_KEY_PREFIX=MCPStatusLocalTest4 REDIS_RETRY_MAX_ATTEMPTS=2 npx jest src/mcp/registry/cache/__tests__/RegistryStatusCache.cache_integration.spec.ts --runInBand --coverage=false --forceExit --silent
  • npx eslint packages/api/src/mcp/registry/MCPServersInitializer.ts packages/api/src/mcp/registry/cache/RegistryStatusCache.ts packages/api/src/mcp/registry/__tests__/MCPServersInitializer.test.ts
  • npm run build:api
  • git diff --check

Test Configuration:

  • Node.js v20.19.5
  • npm 10.8.2
  • Redis 8.4.0
  • Local Redis: redis://127.0.0.1:6387

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings May 13, 2026 19:13

Copy link
Copy Markdown
Owner Author

@codex review

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

Scopes the shared MCP registry "initialized" marker in Redis to a fingerprint of the current MCP config (servers + allowlists) so that, in rolling deployments with shared Redis, pods running an updated config no longer accept a stale initialized marker from the previous version. Followers also re-check the fingerprint on each retry, and a follower that becomes leader on retry will properly reinitialize.

Changes:

  • RegistryStatusCache adds isInitializedFor(configHash) / getInitializedConfigHash() and an optional configHash parameter to setInitialized, persisted under a new INITIALIZED_CONFIG_HASH key.
  • MCPServersInitializer.initialize is rewritten as a polling loop that compares a deterministic SHA-256 fingerprint of rawConfigs + allowed domains/addresses against the cached hash, and a new initializeAsLeader helper centralizes the leader path.
  • New tests cover stale-config reinitialization and the follower-promoted-to-leader retry path during a rolling deployment.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/api/src/mcp/registry/MCPServersInitializer.ts Compute deterministic config fingerprint, replace recursive follower retry with a loop, extract leader init into helper.
packages/api/src/mcp/registry/cache/RegistryStatusCache.ts Track and compare an initialized config hash alongside the boolean status.
packages/api/src/mcp/registry/tests/MCPServersInitializer.test.ts Add regression tests for stale fingerprints and follower-to-leader transitions.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc13be3109

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/mcp/registry/MCPServersInitializer.ts
@danny-avila danny-avila force-pushed the danny-avila/fix-mcp-config-rollout-cache branch from dc13be3 to 39ec554 Compare May 13, 2026 19:22
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13115 index is now live on the MCP server.
Deploy run

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39ec554793

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/api/src/mcp/registry/MCPServersInitializer.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13115 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila force-pushed the danny-avila/fix-mcp-config-rollout-cache branch from 39ec554 to 0945e8e Compare May 13, 2026 19:31

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13115 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila changed the title 🧭 fix: Scope MCP Registry Initialization To Config Fingerprints 🧰 fix: Scope MCP Registry Initialization To Config Fingerprints May 13, 2026
@danny-avila danny-avila changed the base branch from main to dev May 13, 2026 20:11
@danny-avila danny-avila marked this pull request as ready for review May 13, 2026 20:11
@danny-avila danny-avila merged commit 9e8b8c3 into dev May 13, 2026
11 checks passed
@danny-avila danny-avila deleted the danny-avila/fix-mcp-config-rollout-cache branch May 13, 2026 20:50
patricia2510 pushed a commit to lexaeon-org/libre-chat that referenced this pull request May 21, 2026
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