litellm/tests/integration/mcp
jesus-berri 3e0bcc508e
fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error (#52384)
* test(mcp): add red /mcp contract for an upstream -32042 URL elicitation error

A tools/call that the upstream answers with -32042 must reach the /mcp
client as a JSON-RPC error with code and data.elicitations intact. The
stub provider moves to a shared factory so the existing REST case and
the new /mcp case script the same peer.

* fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error

An upstream tools/call answered with JSON-RPC error -32042 was flattened into an isError text result, so the client never saw data.elicitations[].url. The four catches that built that result now re-raise it and the MCP SDK serializes it with code, message and data intact. /mcp-rest/tools/call keeps its HTTP 200 isError text result, and every other error keeps its current path.

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): keep the REST virtual mcp_tool_call result for an upstream -32042

The virtual mcp_tool_call branch of /mcp-rest/tools/call had no guard, so the re-raised -32042 became an HTTP 500. Both REST branches now share one guard that renders it as the HTTP 200 isError text result, while /mcp still relays it as a JSON-RPC error on its virtual path. The MCP client also re-raises -32042 before its error-level log, since it is an expected consent signal.

Co-Authored-By: bot_apk <apk@cognition.ai>

* test(mcp): add integration cells for upstream -32042 URL elicitation across entry points, auth paths and chaos

Covers every /mcp entry point, the official SDK client, SDK-built upstreams over http, sse and stdio,
token exchange, delegated and per-user OAuth servers, the REST error result, unusual error payloads,
spend log rows, a two-proxy burst, a killed worker, an upstream outage and a held reply.

The LLM auto-execute cell pins the tool result text and spend status that the merge base produces.

* test(mcp): assert the auto-executed -32042 tool call hands the model the error and logs a failure

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): run post_mcp_call guardrails over a relayed -32042 URL elicitation's message text

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): keep the LLM auto-execute path unchanged for -32042 and drop the unmasked cause from the relayed error

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): let a during-call guardrail block outrank a relayed -32042 and run the post tool call hook on its messages

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): flatten a -32042 for REST before the shared post-call path so guardrails and the tool call hook run once

Co-Authored-By: bot_apk <apk@cognition.ai>

* fix(mcp): run the -32042 guardrails and tool call hook outside the except block so a block cannot chain the upstream error

Co-Authored-By: bot_apk <apk@cognition.ai>

* test(mcp): drive the -32042 relay unit test through a real post_mcp_call guardrail

Co-Authored-By: bot_apk <apk@cognition.ai>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: bot_apk <apk@cognition.ai>
2026-11-19 08:56:01 -08:00
..
_config_mcp_e2e.yaml chore: move LiteLLM's configs and e2e tests off gpt-4o and gpt-4.1 before their 2027-01-14 shutdown (#51800) 2026-11-14 10:50:59 -08:00
_math_server.py
test_admin_mcp_authorization.py fix(proxy): resolve admin MCP authorization without listing every key and team (#52096) 2026-11-16 14:05:10 -08:00
test_interactions.py test(integration): cap the OAuth metadata lookup in the mixed capabilities subscription case (#50867) 2026-11-10 18:11:16 +00:00
test_litellm_proxy_mcp_handler_real_io.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_mcp_access_matrix.py
test_mcp_accounting_guardrails.py
test_mcp_agent_365_guardrail.py
test_mcp_akto_logging_only.py
test_mcp_client_real_io.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_mcp_credentials.py fix(mcp)!: forward the LiteLLM key when the admin configures it (#50604) 2026-11-10 20:51:34 -08:00
test_mcp_lifecycle.py test(mcp): cancel disconnected HTTP tool handlers (#49436) 2026-10-31 16:41:49 -07:00
test_mcp_listed_tool_metadata.py
test_mcp_llm_endpoints.py fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error (#52384) 2026-11-19 08:56:01 -08:00
test_mcp_management.py fix(mcp): use the saved description and server name in registry.json (#52319) 2026-11-17 13:36:07 -08:00
test_mcp_model_armor_post_mcp_call.py feat(model_armor): scan MCP tool results on post_mcp_call (#51887) 2026-11-18 12:17:47 -08:00
test_mcp_oauth_flows.py fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error (#52384) 2026-11-19 08:56:01 -08:00
test_mcp_protocol_errors.py fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error (#52384) 2026-11-19 08:56:01 -08:00
test_mcp_rate_limits.py
test_mcp_resilience.py
test_mcp_submission_rules.py
test_mcp_tool_permission_merge.py
test_mcp_toolsets.py
test_mcp_transports.py test(mcp): hold the progress test's upstream notification acks until they are dispatched (#49967) 2026-11-03 15:26:48 -08:00
test_mcp_url_elicitation.py fix(mcp): return an upstream -32042 URL elicitation error from /mcp as a JSON-RPC error (#52384) 2026-11-19 08:56:01 -08:00
test_mcp_user_env_vars.py
test_oauth_configuration.py
test_openapi_to_mcp_generator_real_io.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_pagination.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_proxy_mcp_e2e.py test(mcp): give the startup-failure child process the rig's calibrated readiness budget (#52365) 2026-11-18 02:36:51 +00:00
test_responses_mcp_mixed_tools.py
test_responses_mcp_streaming_round_history.py