Skip to content

Conversation

@Nyholm
Copy link
Contributor

@Nyholm Nyholm commented Dec 27, 2025

Motivation and Context

The current behavior IS compliant with PSR-3. But it is not what I would expect. PSR-3 reads:

If an Exception object is passed in the context data, it MUST be in the 'exception' key. Logging exceptions is a common pattern and this allows implementors to extract a stack trace from the exception when the log backend supports it. Implementors MUST still verify that the 'exception' key is actually an Exception before using it as such, as it MAY contain anything.

So when we pass an Exception as context, it must be under the exception key. We are using the exception key as a string.

This PR make sure we pass the full Throwable object to the logger context.

This PR also prints the exception message when running the examples. I found that easier to understand whats happening

How Has This Been Tested?

Yes, with examples

Breaking Changes

No.

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

@Nyholm Nyholm added this to the 0.2.x milestone Dec 27, 2025
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@chr-hertel chr-hertel merged commit 7f02285 into modelcontextprotocol:main Dec 27, 2025
15 checks passed
@Nyholm
Copy link
Contributor Author

Nyholm commented Dec 27, 2025

Thank you for merging

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.

2 participants