feat(mcp): add dcr_bridge column and plumbing for client-forwarded auth modes - #32745
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds the
Confidence Score: 5/5Safe to merge — the change is purely additive (nullable column, no existing behavior altered) and no code reads the flag at request time yet. The field is plumbed correctly through all layers with matching schema, model, and builder changes. Validation is enforced at create time, at update time when auth_type is present, and at the endpoint level when it is absent, with the previously-flagged 404-vs-400 ambiguity now covered by an explicit test. No existing behavior is modified and no production code path reads dcr_bridge yet. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/_types.py | Adds dcr_bridge: Optional[bool] = None to both NewMCPServerRequest and UpdateMCPServerRequest, with mode-before model validators enforcing the field is only set with true_passthrough or oauth_delegate auth types; update validator correctly defers the no-auth_type case to the endpoint. |
| litellm/proxy/management_endpoints/mcp_management_endpoints.py | Adds old_server_record_read_failed flag and a gate block that validates dcr_bridge against the stored auth_type when the payload omits it; correctly skips the block (and falls through to a 404) when the record simply isn't found, addressing the prior review thread. |
| litellm/proxy/_experimental/mcp_server/db.py | Adds dcr_bridge to _AUTH_FLOW_SCOPED_FIELDS so the value is cleared when auth_type changes; explicit caller-provided values win over the clearing logic via the if field not in data_dict guard. |
| litellm/types/mcp_server/mcp_server_manager.py | Adds dcr_bridge: Optional[bool] = None field and is_dcr_bridge property to MCPServer; the property gates on both the flag and the mode as a defense-in-depth check for rows edited outside the normal paths. |
| tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py | Adds thorough test coverage: create-time rejection on wrong/absent auth_type, update-time rejection with and without stored record, the 404-not-400 case for nonexistent server_id, and round-trip verification on the response model. |
Reviews (2): Last reviewed commit: "fix(mcp): let a missing server 404 on a ..." | Re-trigger Greptile
… of a misleading 400
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5ec4c16. Configure here.
Relevant issues
Linear ticket
Part of LIT-4337 (PR 1 of the stack; the discovery facade, register relay, and UI toggle land in follow-up PRs on top of this field)
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Live proxy from this branch on localhost:4010 backed by a fresh Postgres database, with
prisma migrate deployapplying the new migration in sequence first ("All migrations have been successfully applied";information_schema.columnsthen showsdcr_bridge boolean, is_nullable YES)Note:
tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py::test_delete_mcp_oauth_user_credential_invalidates_when_record_already_gonefails identically on a cleanlitellm_internal_stagingcheckout, so it is pre-existing and unrelated to this changeType
🆕 New Feature
Changes
Adds the
dcr_bridgeper-server boolean end to end as a dark field: nullabledcr_bridgecolumn onLiteLLM_MCPServerTable(three schema.prisma copies plus a migration), the field onMCPServer,LiteLLM_MCPServerTable,NewMCPServerRequest, andUpdateMCPServerRequest, config-yaml ingestion, the DB-row and config builders, and both server-table response builders so the value round-trips to the dashboard. No behavior changes; nothing reads the flag at request time yetThe flag is only meaningful for the client-forwarded token modes, so it is validated everywhere it can enter: model validators reject it on create (and on update when the payload carries auth_type) for any auth type other than true_passthrough or oauth_delegate,
load_servers_from_configrejects it for other auth types and rejects non-boolean values, and the update endpoint validates a flag-only update against the stored row's auth_type, failing closed when that row cannot be read.dcr_bridgealso joins_AUTH_FLOW_SCOPED_FIELDSso switching a server's auth_type clears it alongside the other flow-scoped settings, and a newMCPServer.is_dcr_bridgeproperty gates on both the flag and the mode as defense in depth for rows edited outside these pathsContext: verbatim upstream OAuth discovery stays the default for the client-forwarded modes (that contract is load-bearing for deployments whose clients are pre-registered with the upstream IdP). The bridge is a per-server opt-in for OAuth-only MCP clients that can only connect via DCR; this PR ships the field so the follow-ups can gate the discovery facade and register relay on it
Note
Low Risk
Additive nullable column and config validation with no runtime OAuth path changes yet; auth-type guards reduce misconfiguration risk.
Overview
Adds a nullable
dcr_bridgeboolean on MCP servers end-to-end (Prisma migration + schema copies, API/request models, YAML config load, DB builders, and list/detail responses) so the value persists and round-trips. No request-time OAuth behavior uses the flag yet—this is storage and validation only ahead of discovery/register work.dcr_bridgeis only allowed whenauth_typeistrue_passthroughoroauth_delegate: Pydantic validators on create/update,load_servers_from_config, andedit_mcp_server(when enabling the flag withoutauth_type, checked against the stored row; fails closed if the pre-read fails). The field is in_AUTH_FLOW_SCOPED_FIELDS, so changing auth type clears it with other flow settings; switching to client-forwarded modes can still set it explicitly.MCPServer.is_dcr_bridgecombines the flag with those auth modes for later gating.Reviewed by Cursor Bugbot for commit 5ec4c16. Bugbot is set up for automated code reviews on this repo. Configure here.