Skip to content

Share OSMO's Redis for MCP proxy state and allow scaling out - #1331

Closed
jiaenren wants to merge 1 commit into
jiaenr/mcp-derive-jwks-from-discoveryfrom
jiaenr/mcp-shared-redis-and-replicas
Closed

Share OSMO's Redis for MCP proxy state and allow scaling out#1331
jiaenren wants to merge 1 commit into
jiaenr/mcp-derive-jwks-from-discoveryfrom
jiaenr/mcp-shared-redis-and-replicas

Conversation

@jiaenren

@jiaenren jiaenren commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1330. Fourth of the MCP authentication simplification stack.

Issue #None

Two fixes

1. The single-replica rule was based on a misreading of FastMCP.

The chart hard-failed on replicas != 1 with the OIDC proxy enabled, citing process-local refresh serialization. FastMCP says the opposite:

All state is stored in the configured client_storage backend (Redis, disk, etc.) enabling horizontal scaling across multiple instances
oauth_proxy/proxy.py:212-213

and :1903-1912 handles the distributed refresh race explicitly ("another worker may have already refreshed and rotated the token"). The rule was also self-contradictory: sharing state through Redis only matters across replicas the chart forbade from existing.

2. oidcProxy.redis.tlsEnabled did not inherit — and that one can CrashLoop the pod.

serviceName and port already fell back to services.redis, but tlsEnabled did not. A deployment whose Redis requires TLS could satisfy every other OSMO service and still fail on MCP, with a connection error rather than a config error. All three now come from services.redis.

Only dbNumber stays MCP-local, which is its actual job — isolating proxy state from OSMO's other Redis users. Its default moves off 0 for the same reason.

Test change

The negative test asserting the replica ban is replaced by a positive assertion that two replicas render. I negative-tested the replacement by reintroducing a ban and confirming the check fails:

MCP chart validation failed: MCP OIDC proxy with two replicas failed to render

Verification

  • bazel test //src/service/mcp/... — 72/72 pass
  • render-tests.sh, validate-mcp-chart.sh — pass
  • Rendered Redis URL inherits correctly: rediss://redis:6379/14

🤖 Generated with Claude Code

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@jiaenren
jiaenren requested a review from a team as a code owner August 26, 2026 02:29
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6f603c7c-de8a-4371-9d82-7b3e6a16a74a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@jiaenren
jiaenren force-pushed the jiaenr/mcp-shared-redis-and-replicas branch from 24b388b to cc93b0d Compare August 26, 2026 23:56
The chart refused to render more than one MCP replica whenever the OIDC
proxy was enabled, on the premise that FastMCP serializes token refresh
within a process. FastMCP says the opposite: "All state is stored in the
configured client_storage backend (Redis, disk, etc.) enabling horizontal
scaling across multiple instances" (oauth_proxy/proxy.py:212-213), and
:1903-1912 handles the distributed refresh race explicitly. The rule also
contradicted itself, since sharing state through Redis only matters across
replicas that were forbidden from existing.

MCP also carried its own Redis host, port and TLS settings. serviceName
and port already fell back to services.redis, but tlsEnabled did not, so a
deployment whose Redis requires TLS could satisfy every other service and
still CrashLoop MCP. Take all three from services.redis like every sibling
and keep only dbNumber, which exists to isolate proxy state from OSMO's
other Redis users; its default moves off 0 for the same reason.

The CI negative test that asserted the replica ban is replaced by a
positive assertion that two replicas render, negative-tested by
reintroducing a ban and confirming the check fails.

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

Copy link
Copy Markdown
Collaborator Author

Consolidated into #1329 to reduce the number of PRs in this stack for review.

Sharing OSMO's Redis and allowing replicas is the same theme: MCP inherits what every sibling service already inherits.

No content is lost: the cumulative diff of the stack against main is byte-identical to before the consolidation (verified by comparing the resulting tree). Closing this one.

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.

1 participant