Skip to content

Commit 3eda836

Browse files
committed
Document literal-bool limitation of tools/call error detection
Expand the comment to note raw-dict isError is matched as a literal bool; non-bool coercible values that serialize to an error are left undetected, since no hand predicate matches pydantic's wire coercion.
1 parent c0ab4e9 commit 3eda836

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/mcp/server/_otel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ async def __call__(self, ctx: ServerRequestContext[Any, Any], call_next: CallNex
5959
span.set_status(StatusCode.ERROR, str(e))
6060
raise
6161
if ctx.method == "tools/call":
62-
# Only shapes that survive wire serialization (alias-only) are real tool errors.
62+
# Tool errors are detected pre-serialization, so only shapes that reach the wire as an error
63+
# count: the model, or the camelCase alias (`is_error` is dropped by the alias-only wire
64+
# validation). A raw-dict `isError` is matched as a literal bool only - non-bool coercible
65+
# values (1, "true") would serialize to an error but are rare enough to leave undetected.
6366
match result:
6467
case CallToolResult(is_error=True) | {"isError": True}:
6568
span.set_attribute("error.type", "tool_error")

0 commit comments

Comments
 (0)