@@ -215,28 +215,26 @@ describe('wrapMcpServerWithSentry', () => {
215215
216216 mockTransport . onmessage ?.( jsonRpcRequest , extraWithClientInfo ) ;
217217
218- expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith (
219- {
220- name : 'tools/call get-weather' ,
221- op : 'mcp.server' ,
222- forceTransaction : true ,
223- attributes : {
224- 'mcp.method.name' : 'tools/call' ,
225- 'mcp.tool.name' : 'get-weather' ,
226- 'mcp.request.id' : 'req-1' ,
227- 'mcp.session.id' : 'test-session-123' ,
228- 'client.address' : '192.168.1.100' ,
229- 'client.port' : 54321 ,
230- 'mcp.transport' : 'http' ,
231- 'network.transport' : 'tcp' ,
232- 'network.protocol.version' : '2.0' ,
233- 'mcp.request.argument.location' : '"Seattle, WA"' ,
234- 'sentry.op' : 'mcp.server' ,
235- 'sentry.origin' : 'auto.function.mcp_server' ,
236- 'sentry.source' : 'route' ,
237- } ,
218+ expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
219+ name : 'tools/call get-weather' ,
220+ op : 'mcp.server' ,
221+ forceTransaction : true ,
222+ attributes : {
223+ 'mcp.method.name' : 'tools/call' ,
224+ 'mcp.tool.name' : 'get-weather' ,
225+ 'mcp.request.id' : 'req-1' ,
226+ 'mcp.session.id' : 'test-session-123' ,
227+ 'client.address' : '192.168.1.100' ,
228+ 'client.port' : 54321 ,
229+ 'mcp.transport' : 'http' ,
230+ 'network.transport' : 'tcp' ,
231+ 'network.protocol.version' : '2.0' ,
232+ 'mcp.request.argument.location' : '"Seattle, WA"' ,
233+ 'sentry.op' : 'mcp.server' ,
234+ 'sentry.origin' : 'auto.function.mcp_server' ,
235+ 'sentry.source' : 'route' ,
238236 } ,
239- ) ;
237+ } ) ;
240238 } ) ;
241239
242240 it ( 'should create spans with correct attributes for resource operations' , async ( ) => {
@@ -251,26 +249,24 @@ describe('wrapMcpServerWithSentry', () => {
251249
252250 mockTransport . onmessage ?.( jsonRpcRequest , { } ) ;
253251
254- expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith (
255- {
256- name : 'resources/read file:///docs/api.md' ,
257- op : 'mcp.server' ,
258- forceTransaction : true ,
259- attributes : {
260- 'mcp.method.name' : 'resources/read' ,
261- 'mcp.resource.uri' : 'file:///docs/api.md' ,
262- 'mcp.request.id' : 'req-2' ,
263- 'mcp.session.id' : 'test-session-123' ,
264- 'mcp.transport' : 'http' ,
265- 'network.transport' : 'tcp' ,
266- 'network.protocol.version' : '2.0' ,
267- 'mcp.request.argument.uri' : '"file:///docs/api.md"' ,
268- 'sentry.op' : 'mcp.server' ,
269- 'sentry.origin' : 'auto.function.mcp_server' ,
270- 'sentry.source' : 'route' ,
271- } ,
252+ expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
253+ name : 'resources/read file:///docs/api.md' ,
254+ op : 'mcp.server' ,
255+ forceTransaction : true ,
256+ attributes : {
257+ 'mcp.method.name' : 'resources/read' ,
258+ 'mcp.resource.uri' : 'file:///docs/api.md' ,
259+ 'mcp.request.id' : 'req-2' ,
260+ 'mcp.session.id' : 'test-session-123' ,
261+ 'mcp.transport' : 'http' ,
262+ 'network.transport' : 'tcp' ,
263+ 'network.protocol.version' : '2.0' ,
264+ 'mcp.request.argument.uri' : '"file:///docs/api.md"' ,
265+ 'sentry.op' : 'mcp.server' ,
266+ 'sentry.origin' : 'auto.function.mcp_server' ,
267+ 'sentry.source' : 'route' ,
272268 } ,
273- ) ;
269+ } ) ;
274270 } ) ;
275271
276272 it ( 'should create spans with correct attributes for prompt operations' , async ( ) => {
@@ -285,26 +281,24 @@ describe('wrapMcpServerWithSentry', () => {
285281
286282 mockTransport . onmessage ?.( jsonRpcRequest , { } ) ;
287283
288- expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith (
289- {
290- name : 'prompts/get analyze-code' ,
291- op : 'mcp.server' ,
292- forceTransaction : true ,
293- attributes : {
294- 'mcp.method.name' : 'prompts/get' ,
295- 'mcp.prompt.name' : 'analyze-code' ,
296- 'mcp.request.id' : 'req-3' ,
297- 'mcp.session.id' : 'test-session-123' ,
298- 'mcp.transport' : 'http' ,
299- 'network.transport' : 'tcp' ,
300- 'network.protocol.version' : '2.0' ,
301- 'mcp.request.argument.name' : '"analyze-code"' ,
302- 'sentry.op' : 'mcp.server' ,
303- 'sentry.origin' : 'auto.function.mcp_server' ,
304- 'sentry.source' : 'route' ,
305- } ,
284+ expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
285+ name : 'prompts/get analyze-code' ,
286+ op : 'mcp.server' ,
287+ forceTransaction : true ,
288+ attributes : {
289+ 'mcp.method.name' : 'prompts/get' ,
290+ 'mcp.prompt.name' : 'analyze-code' ,
291+ 'mcp.request.id' : 'req-3' ,
292+ 'mcp.session.id' : 'test-session-123' ,
293+ 'mcp.transport' : 'http' ,
294+ 'network.transport' : 'tcp' ,
295+ 'network.protocol.version' : '2.0' ,
296+ 'mcp.request.argument.name' : '"analyze-code"' ,
297+ 'sentry.op' : 'mcp.server' ,
298+ 'sentry.origin' : 'auto.function.mcp_server' ,
299+ 'sentry.source' : 'route' ,
306300 } ,
307- ) ;
301+ } ) ;
308302 } ) ;
309303
310304 it ( 'should create spans with correct attributes for notifications (no request id)' , async ( ) => {
@@ -547,7 +541,7 @@ describe('wrapMcpServerWithSentry', () => {
547541 id : 'req-tool-result' ,
548542 params : {
549543 name : 'weather-lookup' ,
550- arguments : { location : 'San Francisco' , units : 'celsius' }
544+ arguments : { location : 'San Francisco' , units : 'celsius' } ,
551545 } ,
552546 } ;
553547
@@ -576,11 +570,11 @@ describe('wrapMcpServerWithSentry', () => {
576570 content : [
577571 {
578572 type : 'text' ,
579- text : 'The weather in San Francisco is 18°C with partly cloudy skies.'
580- }
573+ text : 'The weather in San Francisco is 18°C with partly cloudy skies.' ,
574+ } ,
581575 ] ,
582- isError : false
583- }
576+ isError : false ,
577+ } ,
584578 } ;
585579
586580 // Simulate the outgoing response (this should trigger span completion)
@@ -591,8 +585,9 @@ describe('wrapMcpServerWithSentry', () => {
591585 expect . objectContaining ( {
592586 'mcp.tool.result.is_error' : false ,
593587 'mcp.tool.result.content_count' : 1 ,
594- 'mcp.tool.result.content' : '[{"type":"text","text":"The weather in San Francisco is 18°C with partly cloudy skies."}]' ,
595- } )
588+ 'mcp.tool.result.content' :
589+ '[{"type":"text","text":"The weather in San Francisco is 18°C with partly cloudy skies."}]' ,
590+ } ) ,
596591 ) ;
597592
598593 // Verify span was completed successfully (no error status set)
@@ -625,26 +620,24 @@ describe('wrapMcpServerWithSentry', () => {
625620
626621 mockStdioTransport . onmessage ?.( jsonRpcRequest , { } ) ;
627622
628- expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith (
629- {
630- name : 'tools/call process-file' ,
631- op : 'mcp.server' ,
632- forceTransaction : true ,
633- attributes : {
634- 'mcp.method.name' : 'tools/call' ,
635- 'mcp.tool.name' : 'process-file' ,
636- 'mcp.request.id' : 'req-stdio-1' ,
637- 'mcp.session.id' : 'stdio-session-456' ,
638- 'mcp.transport' : 'stdio' , // Should be stdio, not http
639- 'network.transport' : 'pipe' , // Should be pipe, not tcp
640- 'network.protocol.version' : '2.0' ,
641- 'mcp.request.argument.path' : '"/tmp/data.txt"' ,
642- 'sentry.op' : 'mcp.server' ,
643- 'sentry.origin' : 'auto.function.mcp_server' ,
644- 'sentry.source' : 'route' ,
645- } ,
623+ expect ( startInactiveSpanSpy ) . toHaveBeenCalledWith ( {
624+ name : 'tools/call process-file' ,
625+ op : 'mcp.server' ,
626+ forceTransaction : true ,
627+ attributes : {
628+ 'mcp.method.name' : 'tools/call' ,
629+ 'mcp.tool.name' : 'process-file' ,
630+ 'mcp.request.id' : 'req-stdio-1' ,
631+ 'mcp.session.id' : 'stdio-session-456' ,
632+ 'mcp.transport' : 'stdio' , // Should be stdio, not http
633+ 'network.transport' : 'pipe' , // Should be pipe, not tcp
634+ 'network.protocol.version' : '2.0' ,
635+ 'mcp.request.argument.path' : '"/tmp/data.txt"' ,
636+ 'sentry.op' : 'mcp.server' ,
637+ 'sentry.origin' : 'auto.function.mcp_server' ,
638+ 'sentry.source' : 'route' ,
646639 } ,
647- ) ;
640+ } ) ;
648641 } ) ;
649642
650643 it ( 'should handle stdio transport notifications correctly' , async ( ) => {
@@ -708,7 +701,7 @@ describe('wrapMcpServerWithSentry', () => {
708701 attributes : expect . objectContaining ( {
709702 'mcp.method.name' : 'resources/read' ,
710703 'mcp.resource.uri' : 'https://api.example.com/data' ,
711- 'mcp.transport' : 'sse' , // Deprecated but supported
704+ 'mcp.transport' : 'sse' , // Deprecated but supported
712705 'network.transport' : 'tcp' ,
713706 'mcp.session.id' : 'sse-session-789' ,
714707 } ) ,
0 commit comments