litellm - ✅(Solved) Fix [Bug] Cannot update the MCP servers with api [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#22854Fetched 2026-04-08 00:39:37
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #22876: fix(proxy): make PUT /v1/mcp/server support partial updates

Description (problem / solution / changelog)

Summary

Fixes #22854

The PUT /v1/mcp/server endpoint was overwriting unmodified fields with default values when performing partial updates. For example, sending only {"server_id": "...", "description": "new desc"} would reset transport to sse, is_byok to false, allow_all_keys to false, and mcp_access_groups to [] — effectively corrupting the server configuration even though the API returned 200 OK.

Root cause: UpdateMCPServerRequest used non-Optional fields with default values (e.g. transport: MCPTransportType = MCPTransport.sse, is_byok: bool = False). When model_dump(exclude_none=True) was called, these defaults were included in the dict and written to the database, overwriting existing values.

Changes:

  • Make all fields in UpdateMCPServerRequest (except server_id) Optional[...] = None so that model_dump(exclude_none=True) only serializes user-provided fields
  • Update _prepare_mcp_server_data() to only force-include alias and is_byok defaults for create operations, not updates
  • Remove server_id from the update data dict (it belongs in the WHERE clause, not the data payload)
  • Add 7 comprehensive unit tests covering partial update behavior at the model, DB helper, and endpoint layers

Test plan

  • TestUpdateMCPServerPartialUpdate::test_update_request_only_includes_provided_fields — verifies model_dump only includes user-provided fields
  • TestUpdateMCPServerPartialUpdate::test_update_request_does_not_include_default_transport — verifies default fields like transport, is_byok, etc. are excluded
  • TestUpdateMCPServerPartialUpdate::test_update_request_includes_fields_when_explicitly_set — verifies explicitly set fields are included
  • TestUpdateMCPServerPartialUpdate::test_prepare_mcp_server_data_partial_update — verifies _prepare_mcp_server_data for partial update
  • TestUpdateMCPServerPartialUpdate::test_prepare_mcp_server_data_create_includes_defaults — verifies create operations still include defaults
  • TestUpdateMCPServerPartialUpdate::test_edit_mcp_server_partial_update_preserves_existing — end-to-end test of the edit endpoint
  • TestUpdateMCPServerPartialUpdate::test_update_mcp_server_db_only_updates_provided_fields — verifies DB layer only sends user-provided fields to Prisma

Changed files

  • litellm/proxy/_experimental/mcp_server/db.py (modified, +46/-22)
  • litellm/proxy/_types.py (modified, +63/-53)
  • tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py (modified, +260/-6)
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

A bug happened!

Steps to Reproduce

Add a MCP server from the UI.

Update it via: /mcp/server

curl -X PUT 'http://localhost:4000/v1/mcp/server'
-H 'Authorization: Bearer sk-key'
-H 'Content-Type: application/json'
-d '{ "server_id": "server_id", "description": "Your new description here" }'

See if the changes are applied in UI. (They are not applied correctly even tho the curl succeds)

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

main

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To resolve the issue of updates not being applied correctly after a successful curl request, we need to ensure that the UI is properly refreshed or updated after the PUT request.

Here are the steps to fix the issue:

  • Check if the UI is using a caching mechanism that prevents updates from being reflected immediately.
  • Verify that the server update endpoint (/mcp/server) is correctly handling the update request and returning a success response.
  • Ensure that the UI is polling or listening for updates to the server configuration.

Example code to handle updates in the UI:

// Assuming a React-like UI framework
useEffect(() => {
  // Poll for updates every 5 seconds
  const intervalId = setInterval(() => {
    fetch('/mcp/server')
      .then(response => response.json())
      .then(data => {
        // Update the UI with the latest server configuration
        setServerConfig(data);
      });
  }, 5000);

  return () => {
    clearInterval(intervalId);
  };
}, []);

Alternatively, consider implementing a WebSocket or Webhook-based update mechanism to push updates from the server to the UI in real-time.

Verification

To verify that the fix worked:

  • Update a server using the curl command.
  • Check the UI to see if the changes are reflected within a reasonable time frame (e.g., 5-10 seconds).
  • Use the browser's developer tools to inspect the network requests and verify that the UI is polling for updates or receiving updates via a WebSocket connection.

Extra Tips

  • Consider adding logging or debugging statements to the server update endpoint to verify that the update request is being handled correctly.
  • If using a caching mechanism, ensure that it is properly configured to expire or update cached values when the server configuration changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug] Cannot update the MCP servers with api [1 pull requests, 1 participants]