Commit graph

745 commits

Author SHA1 Message Date
yassin
2231a3ca43 feat(mcp): give each allowed MCP client an alias and a value
mcp_allowed_clients entries become {alias, value} objects: the value is what the JWT claim or header must equal, the alias is the name the dashboard and logs show. The Network Settings section is renamed Allowed Clients with one alias/value row per client

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 22:29:17 +00:00
yassin
cca7ab8b1b test(mcp): type the REST allowlist test stubs
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 21:50:16 +00:00
yassin
0536fb3062 fix(mcp): fail closed on empty JWT claims and gate the REST tool routes on mcp_allowed_clients
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 21:29:59 +00:00
yassin
9917375d4b Merge remote-tracking branch 'origin/main' into litellm_mcp_client_allowlist
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	litellm/proxy/_experimental/mcp_server/server.py
2026-09-18 20:46:50 +00:00
yassin
fe8cf02823 feat(mcp): resolve the allowlisted client identity from the JWT claim or an opt-in header instead of clientInfo.name
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 19:27:43 +00:00
yassin
c5919a3c0e Merge remote-tracking branch 'origin/main' into litellm_mcp_client_allowlist
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	litellm/proxy/_experimental/mcp_server/server.py
#	litellm/proxy/proxy_server.py
2026-09-18 19:01:08 +00:00
yassin
ce48a3fbcc test(mcp): give the new cache and tombstone patches TQ008 reasons and match the keyword eviction call
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 02:49:41 +00:00
yassin
fd834f6f8b fix(mcp): broadcast BYOK and OAuth credential eviction to peer workers and expire admin session tombstones
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 02:10:50 +00:00
yassin
ea37596b88 feat(mcp): let proxy admins force-close live MCP sessions and revoke stored user credentials
Adds an admin-only DELETE /v1/mcp/sessions that terminates stateful MCP gateway sessions on the current worker by session id prefix and/or by the LiteLLM user that opened them, tombstones the terminated ids so a client reusing one gets 404 instead of a silently recreated stateless session, and lets PROXY_ADMIN name a user_id on the BYOK and OAuth credential delete routes. Full and view-only admins can list every user's stored credential metadata for a server (never the secret). The dashboard gains Disconnect controls on the Live Connections tab and a User Credentials tab with Revoke controls, both hidden from read-only admins.

Resolves LIT-8001

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 01:01:26 +00:00
yassin
33531649c3 perf(mcp): count gateway session groups with Counter and pin the oversized initialize peek invariant
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 23:20:47 +00:00
yassin
c230393731 fix(mcp): refuse sessionless and stale-session POSTs that skip initialize while mcp_allowed_clients is set
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 23:18:54 +00:00
yassin
5f6702ee47 fix(mcp): admit an allowlisted initialize that fills the peek cap exactly and type the allowlist test helpers
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 22:22:19 +00:00
yassin
a9ab7392ae feat(mcp): show live gateway sessions by AI client and user
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 22:15:55 +00:00
yassin
c0f335d8ca fix(mcp): cap the body the client allowlist inspects at 64 KiB
With mcp_allowed_clients set the gateway used to read the whole POST body to
find clientInfo.name, so an authenticated client could make the proxy buffer an
arbitrarily large payload. Inspection is now capped at MCP_ALLOWLIST_PEEK_MAX_BYTES
and a sessionless POST that exceeds the cap is rejected with 403 before routing,
while posts on an admitted session stream through unchanged

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 21:46:15 +00:00
yassin
d240a5b6bb test(mcp): import json at module level in the MCP allowlist tests
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 21:04:56 +00:00
yassin
14639bbb5a fix(mcp): read the whole initialize body under allowlist enforcement and surface a stored empty allowlist in the UI
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 20:55:09 +00:00
yassin
f29be6e1ee fix(ui): save the MCP private ranges and client allowlist sequentially
The proxy stores both fields with a whole-row read-modify-write of
general_settings, so two concurrent writes from one save can drop one
of them. Also drops docstrings and suppressions the diff did not need

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 20:05:35 +00:00
yassin
99eeb813c4 Merge remote-tracking branch 'origin/main' into litellm_mcp_client_allowlist 2026-09-17 19:34:42 +00:00
yassin
a705e0396e refactor(mcp): type the allowlist 403 body and replay consumed messages immutably
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 18:55:47 +00:00
yassin
47be6c8aeb feat(mcp): allowlist client applications for MCP gateway access
Adds the mcp_allowed_clients general setting, enforced against the
clientInfo.name each MCP client sends in its initialize request. A client
not on the list, or one that does not identify itself, is rejected with
403 before any stateful session is created. The setting is configurable
from config.yaml and from the Admin UI MCP network settings page

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-17 18:34:36 +00:00
Joshua Valluru
5b91195406 fix(mcp): retain selected guardrails for virtual REST calls 2026-09-17 10:40:33 -07:00
Joshua Valluru
743684bdbe fix(mcp): preserve request-selected guardrails during tool execution 2026-09-17 09:57:08 -07:00
Mateo Wang
9e1eb546e4
Merge pull request #41514 from BerriAI/litellm_mcp_api_key_static_header_slot
fix(mcp): count admin static headers as api_key credential slots
2026-09-16 17:22:08 -07:00
mateo-berri
574ea15b8f fix(mcp): count admin static headers as api_key credential slots
An api_key server whose key lives in static_headers, the documented
shape for upstreams that expect a custom header name, dispatched fine
before the fail-closed check and was rejected as misconfigured after
it. The check now treats every static header the admin configured as a
credential slot for api_key mode, on both the MCP client path and the
OpenAPI tool path, with regression tests at all three layers.
2026-09-16 16:42:20 -07:00
joshua-berri
41410e9556
Merge pull request #41364 from BerriAI/litellm_fix_mcp_auth_fail_closed_4501
fix(mcp): fail closed on missing upstream credentials
2026-09-16 23:26:38 +00:00
Joshua Valluru
70ef8b24b6 fix(mcp): reject bare schemes in raw authorization 2026-09-16 10:44:00 -07:00
yassin
5fee1c8710 Merge remote-tracking branch 'origin/main' into litellm_model_access_denied_message
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	tests/test_litellm/proxy/auth/test_handle_jwt.py
2026-09-16 16:27:18 +00:00
Joshua Valluru
6c517bfc49 fix(mcp): reject scheme-only API key authorization payloads 2026-09-16 09:00:17 -07:00
Joshua Valluru
fdb8e3533b fix(mcp): validate credentials in existing request paths 2026-09-16 08:07:10 -07:00
Joshua Valluru
87190604f6 chore: integrate current main for MCP security compatibility 2026-09-16 07:54:13 -07:00
Joshua Valluru
ee676d59f2 fix(mcp): preserve browser OAuth for unrelated bearer tokens 2026-09-15 23:08:14 -07:00
Joshua Valluru
e035682ed1 refactor(auth): separate JWT identity and OAuth authorization 2026-09-15 22:15:57 -07:00
Joshua Valluru
258176de76 fix(mcp): validate rendered static credential payloads 2026-09-15 20:32:25 -07:00
Joshua Valluru
be506936bd fix(mcp): preserve explicit caller authorization credentials 2026-09-15 19:52:40 -07:00
Joshua Valluru
84e14789d1 fix(mcp): preserve usable alternate header credentials 2026-09-15 19:18:48 -07:00
Joshua Valluru
c7e4160ee6 fix(mcp): enforce OAuth write policy across signed callbacks 2026-09-15 19:15:34 -07:00
Joshua Valluru
97211bc356 fix(mcp): authorize per-user OAuth credential writes 2026-09-15 19:00:47 -07:00
yassin
b085a3c151 fix(mcp): return fixed client message on sampling model access denial
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-16 01:51:29 +00:00
yassin
15f2e25e8a refactor(proxy): replace configurable model access denied message with a fixed clean client message
Drop the model_access_denied_message setting, its {model} template, the DB
override entry and the Admin UI field. Model access denials now always return
the fixed client message while the allowlist diagnostic is logged at the final
HTTP, realtime and MCP boundaries

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-16 01:44:36 +00:00
Joshua Valluru
8a3add3c6a fix(mcp): reject scheme-only Basic credentials 2026-09-15 18:27:25 -07:00
Joshua Valluru
13553473aa fix(mcp): reject missing upstream authentication credentials 2026-09-15 18:06:00 -07:00
Joshua Valluru
61e3b5ddae fix(mcp): persist OAuth credentials for rowless JWT admins 2026-09-15 17:31:07 -07:00
yassin
241b177f05 fix(proxy): log the internal model access denial reason for MCP sampling denials
MCP sampling catches the denial itself and returns ErrorData, so the central ProxyException handler never sees it. Log the sanitized internal reason there and share the CR/LF stripping through ModelAccessDeniedProxyException.sanitized_internal_message

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-16 00:22:48 +00:00
Joshua Valluru
53318796fd fix(mcp): separate JWT identity lookup from request authorization 2026-09-15 17:13:10 -07:00
Joshua Valluru
88d0371a46 fix(mcp): reuse the standard JWT auth builder for OAuth ownership 2026-09-15 16:50:55 -07:00
Joshua Valluru
eda98f38d9 fix(mcp): preserve canonical JWT owner lookup without cached identity 2026-09-15 12:41:12 -07:00
Joshua Valluru
92e182b898 fix(mcp): persist OAuth credentials for validated JWT users 2026-09-15 12:29:03 -07:00
Joshua Valluru
939fa4ee73 test(mcp): remove unrelated formatting changes 2026-09-12 18:27:20 -07:00
Joshua Valluru
f33bac8080 test(mcp): model delegated hook credentials 2026-09-12 17:29:26 -07:00
Joshua Valluru
364e466210 fix(mcp): strip duplicate delegated credentials 2026-09-12 17:18:54 -07:00