Skip to content

fix(mcp): return camelCase tool keys from /v1/mcp/tools after the SDK 2 upgrade - #42352

Merged
mateo-berri merged 3 commits into
mainfrom
litellm_mcp_tools_camelcase_keys
Sep 22, 2026
Merged

mateo-berri merged 3 commits into
mainfrom
litellm_mcp_tools_camelcase_keys

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • GET /v1/mcp/tools returns input_schema and output_schema since v1.103.0-rc.1
  • Scripts reading inputSchema from that route get nothing back
  • Every other tools list route still returns inputSchema

How it solves it:

  • Dump each tool by its MCP wire aliases, the shape v1.102.0 returned
  • Regression test pins inputSchema, outputSchema, and _meta on the route
  • Drops an unused tools dict in Responses MCP streaming that pointed at the wrong site

User Flow

Before: a developer whose script lists a key's MCP tools from the management route gets no input schema back, so the script cannot build tool definitions

  1. The proxy admin adds an MCP server math (streamable HTTP, one add tool) under mcp_servers in the proxy config and starts the proxy
  2. The developer sends GET https://litellm-domain/v1/mcp/tools with their virtual key
  3. The 200 response lists add with the keys input_schema, output_schema, and meta, so tool.inputSchema reads undefined and the script builds an argument-less tool
  4. The same key's GET https://litellm-domain/mcp-rest/tools/list and the JSON-RPC tools/list on POST https://litellm-domain/mcp return add with inputSchema, so the script's parser works everywhere but this route

After: the same request returns add with inputSchema and outputSchema, so the script builds the tool definition as it did on v1.102.0

  1. The proxy admin adds an MCP server math (streamable HTTP, one add tool) under mcp_servers in the proxy config and starts the proxy
  2. The developer sends GET https://litellm-domain/v1/mcp/tools with their virtual key
  3. The 200 response lists add with inputSchema holding the JSON schema (a and b, both required integers), outputSchema, and _meta, the spelling the other two list routes use
  4. The script builds the tool definition from inputSchema and calls add on POST https://litellm-domain/mcp-rest/tools/call with {"a": 2, "b": 3} and the server id from GET https://litellm-domain/v1/mcp/server, and gets 5

Relevant issues

Affected release

regression in v1.103.0-rc.1 (the MCP SDK 2 upgrade in #41718), backport-stable label added

Linear ticket

Resolves LIT-8213

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Four live proxies, one per checkpoint, each booted from a detached worktree at that commit with its own venv (make bootstrap, so its own mcp pin), a fresh Postgres database, 2 uvicorn workers on a random port, and the same config. Every request below went through a virtual key minted on that proxy with POST /key/generate. The upstream is one SDK 2 MCP server with a single tool, shared by all four proxies; the two fix checkpoints also register a second, annotated upstream at runtime. Before and After were captured at the merge base 9cc5b78 and at this PR's tip 1c6c1e5 (the merge commit that brought that base in), so the proxy under test is the exact code under review

Checkpoint Commit mcp Expected GET /v1/mcp/tools /mcp-rest/tools/list JSON-RPC tools/list tools/call result
Before the regression PR (#41718) c3fa53b 1.28.1 PASS PASS, inputSchema inputSchema inputSchema 5
After the regression PR (#41718) eda1fab 2.2.0 FAIL FAIL, input_schema only inputSchema inputSchema 5
Before the fix (merge base) 9cc5b78 2.2.0 FAIL FAIL, input_schema only inputSchema inputSchema 5
After the fix (this PR's tip) 1c6c1e5 2.2.0 PASS PASS, inputSchema inputSchema inputSchema 5

Upstream, math_server.py, run as python math_server.py 28739:

import sys
from mcp.server.mcpserver import MCPServer

server = MCPServer("Math")


@server.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b


server.run(transport="streamable-http", host="127.0.0.1", port=int(sys.argv[1]))

Proxy config, identical at every checkpoint:

model_list:
  - model_name: gpt-5.4-mini
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
mcp_servers:
  math:
    url: http://127.0.0.1:28739/mcp
    transport: http
    allow_all_keys: true

Boot, from the checkpoint's worktree, with DATABASE_URL pointing at that checkpoint's fresh database:

python litellm/proxy/proxy_cli.py --config config.yaml --port $PORT --num_workers 2

Virtual key, minted once per proxy and used for every request below ($VKEY):

curl -s http://127.0.0.1:$PORT/key/generate -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"key_alias":"lit8213"}' | jq -r .key
sk-...redacted
Regression bracket: the same list step at c3fa53b (before #41718, mcp 1.28.1) and eda1fab (after #41718, mcp 2.2.0)

Before #41718, c3fa53b, port 26617:

curl -s http://127.0.0.1:26617/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq -c '.tools[0] | keys'
curl -s http://127.0.0.1:26617/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq -c '.tools[0] | {name, inputSchema: (.inputSchema | keys?), input_schema}'
["annotations","description","execution","icons","inputSchema","meta","name","outputSchema","title"]
{"name":"math-add","inputSchema":["properties","required","title","type"],"input_schema":null}

After #41718, eda1fab, port 35323:

curl -s http://127.0.0.1:35323/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq -c '.tools[0] | keys'
curl -s http://127.0.0.1:35323/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq -c '.tools[0] | {name, inputSchema, input_schema: (.input_schema | keys?)}'
["annotations","description","execution","icons","input_schema","meta","name","output_schema","title"]
{"name":"math-add","inputSchema":null,"input_schema":["properties","required","title","type"]}

At both commits GET /mcp-rest/tools/list and the JSON-RPC tools/list returned inputSchema and outputSchema, POST /mcp-rest/tools/call with {"name":"math-add","server_id":"8684b12454dc1c0ecb5bf344fc4a2f29","arguments":{"a":2,"b":3}} returned {"content":[{"type":"text","text":"5",...}],"structuredContent":{"result":5},"isError":false}, and the Responses stream produced the same mcp_list_tools and mcp_call items shown under Before and After below

Before (9cc5b78, merge base)

Port 39882, 2 workers (server processes 69313 and 69314), mcp 2.2.0, fresh database lit8213_before_merge

The script lists the key's tools and calls one

  1. List the tools from the management route

    curl -s http://127.0.0.1:39882/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '.tools[0] | keys'
    [
      "annotations",
      "description",
      "execution",
      "icons",
      "input_schema",
      "meta",
      "name",
      "output_schema",
      "title"
    ]
    
  2. Read the schema the script keys on

    curl -s http://127.0.0.1:39882/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '.tools[0] | {name, inputSchema, input_schema}'
    {
      "name": "math-add",
      "inputSchema": null,
      "input_schema": {
        "properties": {
          "a": {
            "title": "A",
            "type": "integer"
          },
          "b": {
            "title": "B",
            "type": "integer"
          }
        },
        "required": [
          "a",
          "b"
        ],
        "type": "object",
        "title": "addArguments"
      }
    }
    

    inputSchema is null, so a v1.102.0 script reading it builds an argument-less tool

  3. Call the tool. A body without server_id is rejected, so the script reads the id from /mcp-rest/tools/list's mcp_info and retries

    curl -s http://127.0.0.1:39882/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"math-add","arguments":{"a":2,"b":3}}'
    SERVER_ID=$(curl -s http://127.0.0.1:39882/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq -r '.tools[0].mcp_info.server_id'); echo "SERVER_ID=$SERVER_ID"
    curl -s http://127.0.0.1:39882/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"math-add","arguments":{"a":2,"b":3},"server_id":"'$SERVER_ID'"}'
    {"detail":{"error":"missing_parameter","message":"server_id is required in request body"}}
    SERVER_ID=8684b12454dc1c0ecb5bf344fc4a2f29
    {"_meta":null,"content":[{"type":"text","text":"5","annotations":null,"_meta":null}],"structuredContent":{"result":5},"isError":false,"resultType":"complete"}
    

The other list routes and the Responses stream (controls)

  1. REST list

    curl -s http://127.0.0.1:39882/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq '.tools[0] | keys'
    [
      "_meta",
      "annotations",
      "description",
      "execution",
      "icons",
      "inputSchema",
      "mcp_info",
      "name",
      "outputSchema",
      "title"
    ]
    
  2. JSON-RPC list (initialize, then tools/list with the returned session id)

    curl -s -D init-headers.txt -o /dev/null http://127.0.0.1:39882/mcp -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"lit8213-qa","version":"1"}}}'
    grep -i -E '^(HTTP|mcp-session-id|content-type)' init-headers.txt | tr -d '\r'
    SID=$(grep -i '^mcp-session-id:' init-headers.txt | tr -d '\r' | cut -d' ' -f2)
    curl -s http://127.0.0.1:39882/mcp -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -H "Mcp-Session-Id: $SID" -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | grep '^data:' | sed 's/^data: //' | jq '.result.tools[0] | keys'
    HTTP/1.1 200 OK
    content-type: text/event-stream
    mcp-session-id: 7c98f2db40364c2da268610f7678e822
    [
      "description",
      "inputSchema",
      "name",
      "outputSchema"
    ]
    
  3. Responses API MCP stream (real OpenAI call to gpt-5.4-mini)

    curl -s -N http://127.0.0.1:39882/v1/responses -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"model":"gpt-5.4-mini","stream":true,"input":"What is 2+3? Use the add tool.","tools":[{"type":"mcp","server_label":"math","server_url":"litellm_proxy/mcp/math","require_approval":"never"}]}' | grep '^data:' | sed 's/^data: //' | jq -c 'select(.type=="response.output_item.done") | .item | {type, name, tool_keys: (if .type=="mcp_list_tools" then (.tools[0] | keys) else null end), output}'
    {"type":"mcp_list_tools","name":null,"tool_keys":["annotations","description","input_schema","name"],"output":null}
    {"type":"function_call","name":"math-add","tool_keys":null,"output":null}
    {"type":"mcp_call","name":"math-add","tool_keys":null,"output":"5"}
    {"type":"message","name":null,"tool_keys":null,"output":null}
    

    (jq also prints a parse error for the trailing data: [DONE] line; the stream's response.completed event reported {"status":"completed","model":"gpt-5.4-mini-2026-03-17","cost":0.00009675000000000001})

Nested wire keys and a server added at runtime

A second upstream, math_server_annotated_sdk2.py on port 26461, serves one multiply tool with title="Multiply two numbers", ToolAnnotations(title="Multiply", read_only_hint=True, idempotent_hint=True, open_world_hint=False), and meta={"origin":"lit8213-risk"}, so every nested field this route can carry is populated

  1. Register it through the admin route, no restart

    curl -s http://127.0.0.1:39882/v1/mcp/server -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"server_name":"mathannotated","alias":"mathannotated","url":"http://127.0.0.1:26461/mcp","transport":"http","allow_all_keys":true}' | jq '{server_id, server_name, url, transport}'
    {
      "server_id": "e39a4401-b6cd-4783-b706-e7e7023317be",
      "server_name": "mathannotated",
      "url": "http://127.0.0.1:26461/mcp",
      "transport": "http"
    }
    
  2. The management route with both servers

    curl -s http://127.0.0.1:39882/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '[.tools[] | {name, keys: (keys), annotation_keys: (.annotations | if . == null then null else keys end), meta: ._meta, meta_snake: .meta}]'
    [
      {
        "name": "mathannotated-multiply",
        "keys": [
          "annotations",
          "description",
          "execution",
          "icons",
          "input_schema",
          "meta",
          "name",
          "output_schema",
          "title"
        ],
        "annotation_keys": [
          "destructiveHint",
          "idempotentHint",
          "openWorldHint",
          "readOnlyHint",
          "title"
        ],
        "meta": null,
        "meta_snake": {
          "origin": "lit8213-risk"
        }
      },
      {
        "name": "math-add",
        "keys": [
          "annotations",
          "description",
          "execution",
          "icons",
          "input_schema",
          "meta",
          "name",
          "output_schema",
          "title"
        ],
        "annotation_keys": null,
        "meta": null,
        "meta_snake": null
      }
    ]
    

    The top level is snake_case and the metadata sits under meta, while the nested annotations are already camelCase (FastAPI serializes the nested model by alias; only the top-level dict(tool) was snake_case). The full entry read {"name":"mathannotated-multiply","title":"Multiply two numbers","annotations":{"title":"Multiply","readOnlyHint":true,"destructiveHint":null,"idempotentHint":true,"openWorldHint":false},"meta":{"origin":"lit8213-risk"}}

  3. Control, the same tools on the REST list route

    curl -s http://127.0.0.1:39882/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq '[.tools[] | {name, keys: (keys), annotation_keys: (.annotations | if . == null then null else keys end)}]'
    [
      {
        "name": "multiply",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "mcp_info",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": null
      },
      {
        "name": "add",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "mcp_info",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": null
      }
    ]
    

    The REST route lists the bare tool name and reports title, annotations, and _meta as null for the same tool: {"name":"multiply","title":null,"annotations":null,"_meta":null,"mcp_info":{"server_name":"mathannotated","server_id":"e39a4401-b6cd-4783-b706-e7e7023317be","alias":"mathannotated"}}

  4. Call the runtime-added tool

    curl -s http://127.0.0.1:39882/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"multiply","arguments":{"a":6,"b":7},"server_id":"e39a4401-b6cd-4783-b706-e7e7023317be"}'
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    

After (1c6c1e5, this PR's tip)

Port 40886, 2 workers (server processes 90743 and 90744), mcp 2.2.0, fresh database lit8213_after_merge, same config and the same two upstreams

The script lists the key's tools and calls one

  1. List the tools from the management route

    curl -s http://127.0.0.1:40886/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '.tools[0] | keys'
    [
      "_meta",
      "annotations",
      "description",
      "execution",
      "icons",
      "inputSchema",
      "name",
      "outputSchema",
      "title"
    ]
    
  2. Read the schema the script keys on

    curl -s http://127.0.0.1:40886/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '.tools[0] | {name, inputSchema, input_schema}'
    {
      "name": "math-add",
      "inputSchema": {
        "properties": {
          "a": {
            "title": "A",
            "type": "integer"
          },
          "b": {
            "title": "B",
            "type": "integer"
          }
        },
        "required": [
          "a",
          "b"
        ],
        "type": "object",
        "title": "addArguments"
      },
      "input_schema": null
    }
    

    inputSchema holds the schema again, the v1.102.0 shape

  3. Call the tool, the same way as before the fix

    curl -s http://127.0.0.1:40886/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"math-add","arguments":{"a":2,"b":3}}'
    SERVER_ID=$(curl -s http://127.0.0.1:40886/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq -r '.tools[0].mcp_info.server_id'); echo "SERVER_ID=$SERVER_ID"
    curl -s http://127.0.0.1:40886/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"math-add","arguments":{"a":2,"b":3},"server_id":"'$SERVER_ID'"}'
    {"detail":{"error":"missing_parameter","message":"server_id is required in request body"}}
    SERVER_ID=8684b12454dc1c0ecb5bf344fc4a2f29
    {"_meta":null,"content":[{"type":"text","text":"5","annotations":null,"_meta":null}],"structuredContent":{"result":5},"isError":false,"resultType":"complete"}
    

The other list routes and the Responses stream (controls)

  1. REST list

    curl -s http://127.0.0.1:40886/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq '.tools[0] | keys'
    [
      "_meta",
      "annotations",
      "description",
      "execution",
      "icons",
      "inputSchema",
      "mcp_info",
      "name",
      "outputSchema",
      "title"
    ]
    
  2. JSON-RPC list

    curl -s -D init-headers.txt -o /dev/null http://127.0.0.1:40886/mcp -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"lit8213-qa","version":"1"}}}'
    grep -i -E '^(HTTP|mcp-session-id|content-type)' init-headers.txt | tr -d '\r'
    SID=$(grep -i '^mcp-session-id:' init-headers.txt | tr -d '\r' | cut -d' ' -f2)
    curl -s http://127.0.0.1:40886/mcp -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -H "Mcp-Session-Id: $SID" -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | grep '^data:' | sed 's/^data: //' | jq '.result.tools[0] | keys'
    HTTP/1.1 200 OK
    content-type: text/event-stream
    mcp-session-id: ddb3a917562444e4be2dbe36a1e5f4e6
    [
      "description",
      "inputSchema",
      "name",
      "outputSchema"
    ]
    
  3. Responses API MCP stream (real OpenAI call to gpt-5.4-mini)

    curl -s -N http://127.0.0.1:40886/v1/responses -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"model":"gpt-5.4-mini","stream":true,"input":"What is 2+3? Use the add tool.","tools":[{"type":"mcp","server_label":"math","server_url":"litellm_proxy/mcp/math","require_approval":"never"}]}' | grep '^data:' | sed 's/^data: //' | jq -c 'select(.type=="response.output_item.done") | .item | {type, name, tool_keys: (if .type=="mcp_list_tools" then (.tools[0] | keys) else null end), output}'
    {"type":"mcp_list_tools","name":null,"tool_keys":["annotations","description","input_schema","name"],"output":null}
    {"type":"function_call","name":"math-add","tool_keys":null,"output":null}
    {"type":"mcp_call","name":"math-add","tool_keys":null,"output":"5"}
    {"type":"message","name":null,"tool_keys":null,"output":null}
    

    Same items and the same mcp_list_tools key set as before the fix, which is OpenAI's own mcp_list_tools shape (response.completed again reported {"status":"completed","model":"gpt-5.4-mini-2026-03-17","cost":0.00009675000000000001})

Nested wire keys and a server added at runtime

  1. Register the annotated upstream through the admin route, no restart

    curl -s http://127.0.0.1:40886/v1/mcp/server -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d '{"server_name":"mathannotated","alias":"mathannotated","url":"http://127.0.0.1:26461/mcp","transport":"http","allow_all_keys":true}' | jq '{server_id, server_name, url, transport}'
    {
      "server_id": "3911db7d-d577-44f0-8448-8e1af5cbcd4d",
      "server_name": "mathannotated",
      "url": "http://127.0.0.1:26461/mcp",
      "transport": "http"
    }
    
  2. The management route with both servers

    curl -s http://127.0.0.1:40886/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq '[.tools[] | {name, keys: (keys), annotation_keys: (.annotations | if . == null then null else keys end), meta: ._meta, meta_snake: .meta}]'
    [
      {
        "name": "mathannotated-multiply",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": [
          "destructiveHint",
          "idempotentHint",
          "openWorldHint",
          "readOnlyHint",
          "title"
        ],
        "meta": {
          "origin": "lit8213-risk"
        },
        "meta_snake": null
      },
      {
        "name": "math-add",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": null,
        "meta": null,
        "meta_snake": null
      }
    ]
    

    Top level camelCase, metadata under _meta, nested annotations keys unchanged from before the fix

  3. Control, the same tools on the REST list route

    curl -s http://127.0.0.1:40886/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq '[.tools[] | {name, keys: (keys), annotation_keys: (.annotations | if . == null then null else keys end)}]'
    [
      {
        "name": "multiply",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "mcp_info",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": null
      },
      {
        "name": "add",
        "keys": [
          "_meta",
          "annotations",
          "description",
          "execution",
          "icons",
          "inputSchema",
          "mcp_info",
          "name",
          "outputSchema",
          "title"
        ],
        "annotation_keys": null
      }
    ]
    

    Unchanged from before the fix, server_id apart: {"name":"multiply","title":null,"annotations":null,"_meta":null,"mcp_info":{"server_name":"mathannotated","server_id":"3911db7d-d577-44f0-8448-8e1af5cbcd4d","alias":"mathannotated"}}

  4. Call the runtime-added tool. The first attempt read the name from a fresh GET /mcp-rest/tools/list, and that particular response came back without multiply (see the next step), so the call went out with an empty name and was rejected. Recorded as it happened, then retried with the listed name

    MNAME=$(curl -s http://127.0.0.1:40886/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq -r '.tools[] | select(.name | test("multiply")) | .name'); echo "MNAME=$MNAME"
    curl -s http://127.0.0.1:40886/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"'$MNAME'","arguments":{"a":6,"b":7},"server_id":"3911db7d-d577-44f0-8448-8e1af5cbcd4d"}'
    curl -s http://127.0.0.1:40886/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"multiply","arguments":{"a":6,"b":7},"server_id":"3911db7d-d577-44f0-8448-8e1af5cbcd4d"}'
    MNAME=
    {"detail":{"error":"missing_parameter","message":"name is required in request body"}}
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    
  5. Because the empty name pointed at the listing itself, both list routes were read eight times each and the call repeated four more times, all with the same key

    for i in {1..8}; do curl -s http://127.0.0.1:40886/v1/mcp/tools -H "Authorization: Bearer $VKEY" | jq -c '[.tools[].name]'; done
    for i in {1..8}; do curl -s http://127.0.0.1:40886/mcp-rest/tools/list -H "Authorization: Bearer $VKEY" | jq -c '[.tools[].name]'; done
    for i in {1..4}; do curl -s http://127.0.0.1:40886/mcp-rest/tools/call -H "Authorization: Bearer $VKEY" -H "Content-Type: application/json" -d '{"name":"multiply","arguments":{"a":6,"b":7},"server_id":"3911db7d-d577-44f0-8448-8e1af5cbcd4d"}'; echo; done
    ["mathannotated-multiply","math-add"]
    ["mathannotated-multiply","math-add"]
    ["math-add"]
    ["math-add"]
    ["math-add"]
    ["math-add"]
    ["mathannotated-multiply","math-add"]
    ["mathannotated-multiply","math-add"]
    ["multiply","add"]
    ["add"]
    ["multiply","add"]
    ["multiply","add"]
    ["add"]
    ["multiply","add"]
    ["multiply","add"]
    ["multiply","add"]
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    {"_meta":null,"content":[{"type":"text","text":"42","annotations":null,"_meta":null}],"structuredContent":{"result":42},"isError":false,"resultType":"complete"}
    

    Both list routes, the one this PR changes and the one it does not, alternate between listing and omitting the server added a moment earlier, while every call that names the tool and its server_id returns 42. With 2 uvicorn workers that reads as one worker having picked up the new server before the other. The merge-base proxy was not probed this way (its three listings after registration all included multiply), and this PR touches no server registry code (see Caveats)

Notes from the run, none of them changed by this PR:

  • POST /mcp-rest/tools/call rejects a body without server_id at every checkpoint
  • Responses stream emits a function_call item beside mcp_call, every checkpoint
  • tools/call results carry resultType since refactor(mcp): upgrade SDK2 while preserving legacy gateway behavior #41718
  • meta is spelled _meta on this route after the fix (see Caveats)
  • Nested annotations keys are camelCase (readOnlyHint, idempotentHint, openWorldHint, destructiveHint) at both checkpoints; the fix changes only the top-level keys and the metadata key
  • /v1/mcp/tools prefixes tool names with the server name (mathannotated-multiply) and carries title, annotations, and _meta; /mcp-rest/tools/list lists the bare name (multiply) with those three as null, at both checkpoints

/live-pr-risk (1c6c1e5)

Breaking: none observed. Every route the live proxies exercised (GET /v1/mcp/tools, GET /mcp-rest/tools/list, JSON-RPC initialize and tools/list on POST /mcp, POST /mcp-rest/tools/call, POST /v1/mcp/server, POST /key/generate, and the Responses MCP stream against the real OpenAI API) answered at the tip with the same status codes, values, and tool results (5 and 42) as at the merge base, apart from the key spellings this PR sets out to change

Backward incompatible: meta becomes _meta on GET /v1/mcp/tools. v1.102.0 (c3fa53b, the regression bracket above) returned meta, the merge base returns meta, the tip returns _meta, which is the spelling GET /mcp-rest/tools/list and the JSON-RPC tools/list used at every checkpoint and the key the MCP spec names. A v1.102.0 reader of meta on this route now reads undefined; the key is null for every tool without metadata. Deliberate: the alternative (dump by alias, then rename _meta back to meta on this one route) is rejected under Caveats and the regression test pins _meta. Accepted by the approving review on this PR

Regression risk: a server registered at runtime through POST /v1/mcp/server showed on one of the two uvicorn workers before the other for a short stretch at the tip (8 consecutive reads of each list route alternated between listing and omitting its tool, while every tools/call with server_id returned 42). Observed at the tip only; the merge-base proxy was not probed the same way (its three post-registration listings all included the tool). The diff is 3 files, +23/-11 (git diff --stat 9cc5b78c33 1c6c1e568d): the one model_dump(by_alias=True) line in get_mcp_tools, a dead dict removed from litellm/responses/mcp/mcp_streaming_iterator.py, and the test. It touches neither the MCP server registry nor POST /v1/mcp/server nor the per-worker refresh, so the lag is inferred pre-existing and is recorded as a Low caveat, not attributed to this PR

Dependency graph:

  • litellm/proxy/_types.py route lists: /v1/mcp/tools stays in the same allowlists; untouched, and every request above went through a virtual key minted on that proxy, so key auth on the route is exercised at both checkpoints
  • OpenAPI snapshot and ui/litellm-dashboard/src/lib/http/schema.d.ts: the route declares no response_model (it returns a plain dict), so the schema carries no field names for it and neither file changes; untouched
  • the Admin UI reads GET /mcp-rest/tools/list and /v1/mcp/toolset, not this route: GET /mcp-rest/tools/list is captured as a control at every checkpoint and is unchanged
  • get_mcp_tools has no in-repo callers besides the router registration (grep -rn 'get_mcp_tools\b' litellm tests finds only the new test); the new unit test calls it directly and asserts inputSchema, outputSchema, _meta, and the absence of the snake_case keys
  • _mcp_tools_dict (removed): zero references at the tip (grep -rn _mcp_tools_dict litellm tests is empty)
  • nested annotations, title, icons, _meta, and a server registered in the database at runtime: verified live at both checkpoints in the annotated upstream section; only the top-level keys and the metadata key change

Not verified:

  • the outbound tools/list request to the upstream MCP server was not captured on the wire; it is inferred unchanged from the diff, which runs after the fetch and touches serialization only
  • the Admin UI was not clicked; the routes it reads were exercised with curl as controls
  • a proxy with more than 2 workers or more than one replica was not booted, so the cross-worker lag above is characterized only for the 2-worker proxy

Type

🐛 Bug Fix

Caveats (if any)

Low

  • meta on this route is now spelled _meta, the MCP wire name /mcp-rest/tools/list already uses
    • a v1.102.0 reader of meta here now reads undefined; the key is null for every tool without metadata
    • the alternative, dumping by alias and renaming _meta back to meta for this one route, would keep a spelling no other route or the MCP spec uses, so it was not taken
  • The full key set is kept (no exclude_none), matching v1.102.0 and the other list routes
  • No docs describe this route's body, so nothing in docs changes: a grep of the docs repo for v1/mcp/tools finds only the v1.91.0 release note that names the route (feat(proxy): allow llm_api_routes virtual keys to list MCP tools via /v1/mcp/tools #31031) and /v1/mcp/toolset examples
  • The red CircleCI jobs at the tip are fleet-wide, not from this PR: every failing test at 1c6c1e5 (pipeline 90025) also fails on main's pipeline 90023 (9fad216, main 17 commits past the 9cc5b78 this tip merged in), compared job by job through the CircleCI tests API
    • integration-cost: the same 23 test_cost_tracking::test_case_bills_expected_cost[...] cases (azure gpt-5.6 stream, gpt-5.3-codex stream, gpt-5.5-pro stream, gpt-5.6 responses) on both
    • integration-providers: test_fal_ai_video_wire::test_fal_h3_video_create_uses_canonical_body_and_status_path on both
    • local_testing_part1: test_get_model_info_bedrock_cross_region_capability_parity and test_get_model_info_bedrock_models on both
    • unit: test_secret_detection::test_scan_message_stays_linear_on_adversarial_credential_lines[assignment-flood] on both
    • llm_translation_testing: the same 12 cases on both (test_bedrock_moonshot json stream, ten test_fireworks_ai_translation document-inlining cases, test_optional_params::test_drop_nested_params_add_prop_and_strict[hosted_vllm-my-vllm-model])
    • e2e_ui_testing: tests/e2e/ui/tests/mcp/mcpTools.spec.ts:38 (MCP Tools tab lists ask_question) on both, 153 other specs pass on both; the public DeepWiki server that spec registers now advertises ask_wiki_question instead (its tools/list on 2026-09-22), and main's scheduled pipelines passed the job through 89979 (2026-09-21 18:09Z) and fail it from 90021 (00:09Z) on. The tab reads /mcp-rest/tools/list, which this PR does not touch
    • main is additionally red on using_litellm_on_windows, which this branch passes
    • this PR touches no cost, provider, router, or budget code
  • proxy-infra / Run tests (not a required check) is red at the tip on test_registry_read_through.py::test_get_agent_with_read_through_returns_none_for_unknown_agent, a flake: the file passes locally at the tip (23 passed), fails the same way on main run 35671790986 (12f7930) and passes on later main runs, and nothing in this PR touches it
  • A server registered at runtime through POST /v1/mcp/server showed on one of the two uvicorn workers before the other for a short stretch at the tip (the 8-probe loop under After); every tools/call with server_id returned 42 throughout. Not probed at the merge base, and this PR touches no server registry code, so it is inferred pre-existing and left as is

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

  • 1c6c1e5 passes /live-pr-risk

… 2 upgrade

SDK 2 spells the Tool model's Python attributes in snake_case behind camelCase aliases, so dumping attribute names handed scripts input_schema and output_schema instead of the inputSchema and outputSchema v1.102.0 returned. Dump each tool by its MCP wire aliases, as the other list routes do, and pin the shape with a regression test. Also drop an unused tools dict in the Responses MCP stream iterator.
@devin-ai-integration

devin-ai-integration Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri mateo-berri added run-ci backport-stable P0 regression fix only (Urgent ticket): cherry-pick onto the baking rc line before the stable tag labels Sep 21, 2026
@greptile-apps

greptile-apps Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the endpoint contract is restored with focused regression coverage and no outstanding findings.

Summary

Restores the MCP wire-format field aliases returned by GET /v1/mcp/tools.

  • Serializes MCP tools with aliases so schemas use inputSchema, outputSchema, and _meta.
  • Adds regression coverage for the endpoint’s response shape.
  • Removes an unused intermediate tool serialization from MCP response streaming.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

@codspeed

codspeed Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_mcp_tools_camelcase_keys (1c6c1e5) with main (9fad216)

Open in CodSpeed

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1c6c1e5. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 5eb4e30 into main Sep 22, 2026
150 of 157 checks passed
@mateo-berri
mateo-berri deleted the litellm_mcp_tools_camelcase_keys branch September 22, 2026 01:46
yuneng-berri added a commit that referenced this pull request Sep 26, 2026
* fix: apply configured cache_control_injection_points beside client cache_control marks (#41956)

(cherry picked from commit d8267d5)

* fix(token_counter): count replayed redacted_thinking blocks so prompt_caching keeps pinning (#42069)

(cherry picked from commit 0e7cf51)

* fix(mcp): return camelCase tool keys from /v1/mcp/tools after the SDK 2 upgrade (#42352)

(cherry picked from commit 5eb4e30)

* fix(rust_bridge): keep the Messages route on Python until the Rust path is ready (#42517)

rc/1.103.0 has no token counter or tokenizer routes in the catalog, so only the Messages rule moves to PYTHON_ONLY

(cherry picked from commit 85ed18e)

* fix(proxy): stop leaking periodic tasks on every DB config reload (#42784)

(cherry picked from commit fc87a06)

---------

Co-authored-by: Mateo Wang <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri mateo-berri removed the backport-stable P0 regression fix only (Urgent ticket): cherry-pick onto the baking rc line before the stable tag label Sep 26, 2026

This branch was previously deployed

1 inactive deployment
e2e-changed — 1c6c1e56 Deployed Sep 22, 2026 by mateo-berri via oauth #218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant