-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
10.34.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Hello, I've been debugging this issue for a few days I think I understand why it happens, here is what I found.
The sentryMcpWrapper is storing the sessions in a weakmap from the transport to the session data.
The issue is, that the transport received in the onMessage method can be a different level of abstraction from the one recived in the send method
Here you can see images of both events for the same mcp call:
As you can see in the images above, this is the same request, but on response (send) the sdk exposes a different transport (a warpper that holds the original transport)
This happens because the send method is being called from a StreamableHTTPServerTransport which overrides the method, but it does not override the onMessage method so that one is being called from the super class which means the code is getting different this values in each invocation.
Because the weakmap uses the class of the transport itself as the key for the entire transaction this causes the event to not be found and not send to sentry.
A solution might be trying to use the prototype class or just forgo using classes at all there and trying to use the session id generated by the transport but I dont know all the details and I'm sure there was a good reason for this approach.
Steps to Reproduce
As far as I see this happens always if you create your own StreamableHTTPServerTransport and use mcpServer.connect(transport)
Expected Result
Events to be sent to sentry
Actual Result
Events are not being sent
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Labels
Projects
Status

