litellm/tests/test_litellm/proxy/_experimental/mcp_server
yuneng-jiang 36bd7f1138
fix(mcp): honor an explicit null on toolset update, cover MCP lifecycle e2e (#40022)
* fix(mcp): honor an explicit null on toolset update, cover MCP lifecycle e2e

PUT /v1/mcp/toolset dumped its payload with exclude_none, so a field sent as
null looked exactly like one the caller left out and the stored value
survived. An admin could not clear a toolset's description: the save reported
success and the old text came straight back. It now dumps with exclude_unset,
so absent keeps and null clears, which is what PUT /v1/mcp/server already did.
A null tools list clears the selection to empty, and a null toolset_name is
ignored because a toolset always has a name.

Adds create, read, partial-update, clear and delete e2e coverage for MCP
servers and toolsets, with every read-back polled on every replica so an edit
that lands on one replica and not another fails the test, plus an enforcement
test proving a key granted a toolset lists exactly that toolset's tools
against the real Datadog upstream.

* fix(e2e): refuse a read-back that no replica serves

A read-back over an empty replica mapping satisfied every predicate and
returned as if it had converged, so it would have asserted nothing and
passed. No wiring can produce that today, since the replica list always
falls back to at least one URL, but a helper whose whole job is proving a
write reached every replica should not have a shape that passes vacuously.

* fix(mcp): keep a null tools list a no-op on toolset update

Treating a null tools list as a clear meant an existing client that sends
tools=null during a partial update, meaning "leave the selection alone",
silently lost every tool the toolset grants. That is a permission surface,
so the quiet version of it is the worst version.

A toolset always has a tool list, the same way it always has a name, so a
null on either is now a no-op. Emptying the selection is an explicit [],
which cannot be confused with a field the caller left out, and which is
what the dashboard already sends.

* fix(e2e): keep MCP admin routes on the data plane

/v1/mcp/* is a lazily mounted feature, so a gateway registers it on the first
matching request, which happens after the startup route trim that drops
management endpoints. Routing it to the control plane therefore sent every MCP
call to the one backend process: the new lifecycle read-backs proved a single
process rather than every replica, and mcp_client's await_registered barrier
waited on a registry that does not serve the tools/list call it guards, so the
existing MCP suites polled a gateway that had not synced yet until poll_timeout

Verified against a two-gateway split stack (backend on 4001, gateways on 4010
and 4011, one postgres): both gateways answer /v1/mcp/server and /v1/mcp/toolset,
and each served 6 server reads and 7 toolset reads over the run

* fix(e2e): grant the toolset by the tool's own name, not the wire name

tools/list serves a tool as <prefix><tool_name>, but a toolset grants by the
tool's own name: resolve_toolset_permissions reads toolset.tools[].tool_name
straight through, and the prefix is added on the way out. The test built the
toolset from the names tools/list reported, so the grant matched nothing, the
scoped key listed no tools, and await_tools ran out its whole poll_timeout
before failing

Measure the prefix off search_datadog_logs, whose own name is known, rather than
guessing it from the alias, since the proxy can be configured to prefix with a
short server id instead. The expectation compared against tools/list stays in
wire names; only what the toolset stores crosses back

* test(mcp): build immutable lifecycle updates and replica results

* test: validate opaque stream IDs and hide log-reader credentials

* test: isolate auto-router scenarios and clean partial setup

* test: honor Datadog search rate-limit reset headers

* test: share the Datadog read-back deadline across retries

* test: preserve captured MCP toolset update fields
2026-09-08 22:50:13 -07:00
..
auth merge: bring litellm_internal_staging into litellm_fix_agent_mcp_grants 2026-09-07 16:35:40 -07:00
faults ci: lint the test tree for undefined names and fix all 30 (#37671) 2026-08-20 13:30:34 -07:00
guardrail_translation fix(mcp): scan and mask MCP tool call arguments in unified guardrails (#35142) 2026-09-05 20:51:25 +00:00
outbound_credentials feat(proxy): resolve root_path per request from a configured prefix list (SERVER_ROOT_PATHS) (#35935) 2026-09-07 11:54:59 -07:00
conftest.py test(mcp): resolve current manager in proxy fixtures 2026-09-08 18:35:25 -07:00
test_byok_oauth_endpoints.py feat(mcp): allow native MCP OAuth support for cursor (#28327) 2026-05-20 15:28:44 -07:00
test_callback_oauth_error_responses.py Litellm oss staging 250526 (#28770) 2026-05-26 11:57:39 -07:00
test_db_credentials.py fix(mcp): encrypt stored static headers and stdio environment (#40164) 2026-09-07 16:03:06 -07:00
test_discoverable_endpoints.py feat(mcp): start the named server's OAuth directly for a resource-scoped gateway flow (#39933) 2026-09-07 23:40:02 -07:00
test_gateway_dcr_flow.py feat(mcp): start the named server's OAuth directly for a resource-scoped gateway flow (#39933) 2026-09-07 23:40:02 -07:00
test_is_tool_name_prefixed.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_jwt_mcp_enforcement.py fix(mcp): resolve team.access_group_ids → MCP servers (#28997) 2026-05-27 12:36:50 -07:00
test_jwt_mcp_simple.py fix(mcp): resolve team.access_group_ids → MCP servers (#28997) 2026-05-27 12:36:50 -07:00
test_mcp_block_recording.py fix(guardrails): record MCP tool guardrail evaluations and blocks in usage monitor 2026-08-14 17:52:36 -04:00
test_mcp_cost_calculator.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_custom_fields.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_debug.py chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
test_mcp_discovery.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_elicitation_handler.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_env_vars.py fix(mcp): encrypt stored static headers and stdio environment (#40164) 2026-09-07 16:03:06 -07:00
test_mcp_guardrail_usage_monitor.py fix(guardrails): record MCP tool guardrail evaluations and blocks in usage monitor 2026-08-14 17:52:36 -04:00
test_mcp_header_alias_utils.py feat(mcp): use x-mcp-<access_group>-* headers as default upstream credentials for group members (#39717) 2026-09-04 12:45:24 -07:00
test_mcp_hook_extra_headers.py fix(mcp): keep upstream OAuth Authorization when jwt signer hook injects one on tools/call (#38555) 2026-08-27 12:44:36 -07:00
test_mcp_max_concurrent_requests.py feat(ui): expose MCP max_concurrent_requests in server create and edit forms (#32397) 2026-07-07 22:47:03 -07:00
test_mcp_metadata_preservation.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_oauth_passthrough.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_oauth_passthrough_cold_start.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_oauth_passthrough_tools.py fix: resolve Python 3.14 OCR annotations and remaining matrix failures 2026-09-02 14:35:38 -07:00
test_mcp_partial_update.py fix(mcp): honor an explicit null on toolset update, cover MCP lifecycle e2e (#40022) 2026-09-08 22:50:13 -07:00
test_mcp_proxy_mode.py fix(mcp): log proxy tool dispatch exceptions (#40351) 2026-09-08 19:56:21 -07:00
test_mcp_sampling_completion_flow.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_model_access.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_model_resolution.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_priority_selection.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_request_builder.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_response_conversion.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_sampling_tool_conversion.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_mcp_server.py feat(otel v2): send a key's or team's whole trace to its own destination (#39654) 2026-09-08 16:23:21 -07:00
test_mcp_server_identity_env.py test: trim mcp fixture docstring and reload comment 2026-09-01 11:06:08 +00:00
test_mcp_server_manager.py fix(mcp): encrypt stored static headers and stdio environment (#40164) 2026-09-07 16:03:06 -07:00
test_mcp_session_logging.py Add MCP semantic conventions to otelv2 (#29468) 2026-06-02 11:45:36 -07:00
test_mcp_sigv4_auth.py fix(mcp): encrypt stored static headers and stdio environment (#40164) 2026-09-07 16:03:06 -07:00
test_mcp_stale_session.py ci: lint the test tree for undefined names and fix all 30 (#37671) 2026-08-20 13:30:34 -07:00
test_mcp_tool_search.py merge: bring litellm_internal_staging into litellm_fix_agent_mcp_grants 2026-09-07 16:35:40 -07:00
test_mcp_toolset_scope.py fix(mcp): use a toolset row's stored tool name as written 2026-07-24 17:06:08 -07:00
test_oauth2_flow_backfill.py feat(mcp): startup backfill stamping oauth2_flow on legacy null rows (#32290) 2026-07-06 18:42:08 -07:00
test_oauth2_token_cache.py feat(mcp): let a resolved OAuth token target a custom upstream header (#38456) 2026-08-27 14:32:01 -07:00
test_oauth_issuer_stamp_backfill.py fix(mcp): never write discovery results to the row, heal rows a release already stamped, and retry failed discovery with backoff 2026-07-29 17:51:22 -07:00
test_openapi_to_mcp_generator.py fix(mcp): stop reporting failed OpenAPI tool calls as successes (#37496) 2026-08-19 14:26:02 -07:00
test_openapi_tool_auth.py feat(mcp): let a resolved OAuth token target a custom upstream header (#38456) 2026-08-27 14:32:01 -07:00
test_proxy_api_credentials.py fix(proxy): refuse a teamless native-client grant for a user who has teams 2026-08-20 05:37:35 -07:00
test_rest_endpoints.py Merge pull request #38806 from BerriAI/litellm_fix_mcp_test_connection_oauth_bearer 2026-09-07 15:18:35 -07:00
test_semantic_tool_filter.py merge: bring litellm_internal_staging into litellm_fix_agent_mcp_grants 2026-09-07 16:35:40 -07:00
test_short_mcp_tool_prefix.py test: require a match= on broad pytest.raises, and drop duplicate parametrize cases (#37769) 2026-08-20 20:24:49 -07:00
test_ui_session_utils.py fix(mcp): deny the interactive dcr_bridge authorize for a user without server access (#37865) 2026-08-21 12:27:00 -07:00
test_utils.py fix(mcp): drop caller host and configured upstream headers from logged metadata (#36901) 2026-08-14 17:21:07 -07:00