Skip to content

Commit 3b4fb05

Browse files
SachinSachin
authored andcommitted
Log exceptions in tool calls to match resource/prompt handlers
_handle_call_tool was silently catching exceptions and returning CallToolResult(is_error=True) without any server-side logging. The equivalent handlers for resources and prompts both call logger.exception() in their error branches. Added the same logging for tool calls so server operators can see tool execution failures. Fixes #3266
1 parent 57394b0 commit 3b4fb05

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/mcp/server/mcpserver/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ async def _handle_call_tool(
422422
except MCPError:
423423
raise
424424
except Exception as e:
425+
logger.exception(f"Error calling tool {params.name}")
425426
return CallToolResult(content=[TextContent(type="text", text=str(e))], is_error=True)
426427

427428
async def _handle_list_resources(

0 commit comments

Comments
 (0)