fix(mcp_server): coerce integer progressToken before slicing in debug log - #32183
fix(mcp_server): coerce integer progressToken before slicing in debug log#32183juancarlosm wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes a crash in
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted fix to a debug log line with no impact on request routing or auth logic. The only changed production code is a single helper function and one updated call site in a debug log path. The fix is correct: No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/_experimental/mcp_server/server.py | Extracts _format_progress_token_for_log() to coerce progressToken to str before slicing, fixing the TypeError when an integer token is received. The surrounding call site is updated accordingly. |
| tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py | Adds a parametrized regression test covering both integer and string progressToken values — pure unit test, no network calls. |
Reviews (1): Last reviewed commit: "fix(mcp_server): coerce integer progress..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… log An MCP progressToken may be a string or an integer per spec. The host progress-capture path logged host_token[:8], which raised 'TypeError: int object is not subscriptable' for integer tokens and aborted the entire tool call before the backend was dispatched. Extract the token formatting into _format_progress_token_for_log(), which coerces to str before slicing, and cover it with a regression test. Fixes BerriAI#32181
dbe7db3 to
c4eb936
Compare
|
The related issue has been closed by another PR (#32402), I assume this can be safely closed ? |
Summary
MCP
tools/callthrough the proxy crashes withTypeError: 'int' object is not subscriptablewhen the client sends an integerprogressToken. The MCP spec allowsprogressTokento bestring | integer, but_capture_host_progress_callbackloggedhost_token[:8], which only works for strings. Because the f-string is built beforeverbose_logger.debug(...)runs, it raises even with debug logging disabled, and the exception aborts the whole tool call before the backend server is dispatched (backend logs stay clean, so it looks like a gateway/auth fault).Fixes #32181.
Changes
_format_progress_token_for_log(), coercing the token tostrbefore slicing.Reproduce
Call any tool with an integer
_meta.progressToken(e.g.{"progressToken": 1}). Clients such as Claude Code send monotonically increasing integer tokens by default. A string or absent token does not trigger it.Testing
_format_progress_token_for_log(123456789)→"12345678..."(previously raised);"abcdefghij"→"abcdefgh..."unchanged.