| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Tool.run() and _handle_call_tool() now return a generic error message for unexpected exceptions instead of str(e), which could expose sensitive internal details like connection strings, file paths, or stack traces to MCP clients. - ToolError is still passed through unchanged (intentional user-facing errors) - UrlElicitationRequiredError and MCPError are re-raised at the server level - All other exceptions log the full traceback server-side and return a generic 'An unexpected error occurred' message to the client Fixes modelcontextprotocol#698 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add test for ToolError passthrough (covers tools/base.py except ToolError) - Mark unreachable defensive except in _handle_call_tool as no cover Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sive handler test - Remove logger.exception from base.py Tool.run() to avoid duplicate logging (server.py's defensive handler already logs) - Remove unused logging import from base.py - Remove '# pragma: no cover' from server.py defensive exception handler - Add test_handle_call_tool_defensive_exception_handler to verify the defensive handler returns a generic error and does not leak internal exception details Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…leak # Conflicts: # src/mcp/server/mcpserver/server.py # tests/server/mcpserver/test_tool_manager.py
Replace inner async function with patch.object + AsyncMock to avoid coverage blind spot when the mock runs inside the server's task context with pytest-xdist parallel workers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve conflict in src/mcp/server/mcpserver/tools/base.py: keep the generic error message that avoids leaking exception details, and drop the stale _is_async_callable helper (replaced on main by mcp.shared._callable_inspection.is_async_callable).
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #698
Tool.run() and _handle_call_tool() previously exposed internal exception details (str(e)) to MCP clients. This could leak sensitive information like connection strings, file paths, or internal state.
Changes
src/mcp/server/mcpserver/tools/base.py:
src/mcp/server/mcpserver/server.py:
Tests updated:
Security
This is a security hardening change. Before this fix, any Python exception raised inside a tool function would have its full str() representation sent to the client, potentially exposing: