Skip to content

feat: add error logging for onErrorResume #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ronantakizawa
Copy link

@ronantakizawa ronantakizawa commented Aug 12, 2025

##Summary

Added error logging to onErrorResume handlers in McpServerSession to capture full stack traces when request processing fails, addressing issue #249.

Motivation and Context

Problem: The MCP server was silently swallowing exceptions in onErrorResume handlers, making debugging difficult.

Solution: Added comprehensive error logging that captures:

  • Full stack traces with line numbers and call hierarchy
  • Request method context for easier debugging
  • Error messages while preserving existing error handling behavior

Before: Silent failures with no diagnostic information for onErrorResume
After: Full error visibility while maintaining identical protocol behavior

How Has This Been Tested?

  • Created McpServerSessionRealErrorTest with 4 comprehensive test scenarios
  • Verified actual log output shows complete error information with stack traces
  • Confirmed existing error handling behavior is preserved
  • Validated that clients receive identical error responses as before
  • Ran successful builds and test for the java-sdk

Breaking Changes

None - This is a purely additive change:

  • All existing client-server communication remains identical
  • No changes to protocol messages, responses, or behavior
  • No configuration updates required
  • Existing implementations continue working without modification

Types of changes

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

  • Uses existing SLF4J logger with ERROR level for proper operational visibility
  • Passes full Throwable object to capture complete stack traces
  • Maintains all existing error response generation and transport behavior

TODO: Add structured error details to client responses while preserving security boundaries (The error message for the client side is currently null).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant