6 views
-/https://github.com/berriai/litellm/issues/29305
GitHub · issue

#29305 [Bug] /key/update fails with 403 when a previously-assigned MCP server has been deleted

  • State: open
  • Author: @sumirjha

## Bug description

`POST /key/update` on any key whose `object_permission` row contains a stale reference to a deleted MCP server fails with:

``` 403 Forbidden — "Key is not in a team / allowed servers" ```

## Root cause

`handle_update_object_permission_common` in `litellm/proxy/management_helpers/object_permission_utils.py` does a plain `dict.update` to merge the stored `mcp_servers` list with the incoming request data, then writes the merged result back via upsert. If the DB record contains the UUID of a server that was deleted from `LiteLLM_MCPServerTable`, that UUID is never cleaned out. The re-validation step on every subsequent `/key/update` call produces the 403.

The same applies to server UUIDs stored as keys in `mcp_tool_permissions`.

## Steps to reproduce

1. Register an MCP server — note its UUID. 2. Assign it to a key via `object_permission.mcp_servers`. 3. Delete the MCP server from the LiteLLM database. 4. Call `POST /key/update` with any field change. 5. Observe: `403 — Key is not in a team / allowed servers`.

## Fix

Branch `fix/stale-mcp-server-key-update` in fork https://github.com/sumirjha/litellm.

**Files:** - `litellm/proxy/management_helpers/object_per…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (3 events)
#0 of 0 · 31d18h16m33s ago — entered · #import:https:::github.com:berriai:litellm post #2585
29305 requires coordinated changes across permission merging, persistence, validation, and regression coverage, with authorization edge-case risk. 34753 is more localized to error-metadata sanitization and logging-size handling.
29305 spans permission-merging, persistence, stale-resource handling, and authorization regression coverage, creating broader integration risk; 30731 is comparatively localized to guardrail result validation and focused tests.
#0 of 0 · 31d17h48m7s ago — current · #import:https:::github.com:berriai:litellm post #3083
Issue 35066 is harder because it requires extending typed SDK content models and SAP request translation while preserving compatibility across providers and validation paths; issue 29305 is a more localized proxy permission-cleanup and regression-testing change.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search