litellm/tests/mcp_tests
Tin Chi Lo 4b18ca26a3 feat(mcp): implement the token_exchange (RFC 8693 OBO) arm
Swaps the caller's live inbound token for a token bound to server.resource at the IdP's
exchange endpoint, via a new TokenExchanger port (hand-rolled RFC 8693 body deferred, faked in
tests). The inbound token is sent ONLY to the exchanger, never to the upstream - the upstream
gets the exchanged token; that is the core invariant distinguishing it from passthrough, and is
locked by a test. No inbound token -> unauthorized. Reuses the per-user TokenStore + Clock +
StoredToken; 'refresh' means re-exchange (no refresh token).

Folds in the scoping decisions: drop TokenExchangeConfig.audience (use server.resource for the
RFC 8707 indicator) and make token_exchange_endpoint optional (discovered via RFC 8414), so an
empty token_exchange config is valid. Error mapping via the exchanger: subject_token invalid ->
401 (user re-auths), config -> 500, endpoint down -> 503. Cache is best-effort (read failure
re-exchanges, write failure ignored), deliberately differing from authorization_code on the
same TokenStore since the exchanged token is re-exchangeable.

Tests: the swap invariant (inbound->exchanger, exchanged->upstream, bound to resource),
no-inbound->401, cached-fresh (no exchange), re-mint near expiry, subject-invalid->401,
config->500, down->503, cache-degrades, and discovery-default config. 48 tests, gates green.
2026-06-17 19:18:19 -07:00
..
gateway feat(mcp): implement the token_exchange (RFC 8693 OBO) arm 2026-06-17 19:18:19 -07:00
test_configs [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
conftest.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
mcp_server.py test: const 2026-01-19 12:03:26 +09:00
test_aresponses_api_with_mcp.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_auth_header_extraction.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_auth_priority.py [Feat] MCP Oauth2 Fixes - Add support for MCP M2M Oauth2 support (#20788) 2026-02-09 17:35:11 -08:00
test_mcp_chat_completions.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_client_unit.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_guardrails.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_hooks.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_litellm_client.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_logging.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_server.py [internal copy of #28008] Support MCP OAuth passthrough and issuer-scoped JWT auth (#28356) 2026-06-02 12:22:04 -07:00
test_oauth2_mcp_config.yaml [UI] M2M OAuth2 UI Flow (#20794) 2026-02-09 19:28:02 -08:00
test_openapi_spec_path_url.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_per_user_oauth_cache.py [internal copy of #28008] Support MCP OAuth passthrough and issuer-scoped JWT auth (#28356) 2026-06-02 12:22:04 -07:00
test_proxy_mcp_e2e.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_semantic_tool_filter_e2e.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00