8 views
-/https://github.com/berriai/litellm/issues/33400
GitHub · issue

#33400 [Bug]: async_post_mcp_tool_call_hook return value is discarded — a modified MCP tool response never reaches the client

  • State: open
  • Author: @mitrecx

### What happened?

When using LiteLLM Proxy as an **MCP gateway**, `CustomLogger.async_post_mcp_tool_call_hook` is typed to return `Optional[MCPPostCallResponseObject]`, and the logging wrapper explicitly parses and returns the (possibly modified) response. However, **every caller of the hook discards this return value**, so returning a modified `MCPPostCallResponseObject` from a custom logger has **no effect** on the response delivered to the MCP client.

### Why this is confusing

The public API strongly signals that returning a modified response is the intended way to rewrite a tool result:

- The hook signature returns `Optional[MCPPostCallResponseObject]`. - `MCPPostCallResponseObject.mcp_tool_call_response` holds the tool output content. - `LiteLLMLoggingObj.async_post_mcp_tool_call_hook` collects the callback's return value, runs `_parse_post_mcp_call_hook_response()`, and returns the unpacked `mcp_tool_call_response`, with the inline comment:

``` # if any of the callbacks modify the response, use the modified response # current implementation returns the first modified response ```

But the two call sites throw that return value away:

- `litellm/proxy/_experiment…

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 · 31d19h2m34s ago — entered · #import:https:::github.com:berriai:litellm post #1828
The right issue is harder because it spans provider-specific request translation, schema validation, and compatibility regression coverage, while the left is a localized async data-flow correction with a comparatively narrow test surface.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search