@@ -215,28 +215,26 @@ describe('wrapMcpServerWithSentry', () => {
215
215
216
216
mockTransport . onmessage ?.( jsonRpcRequest , extraWithClientInfo ) ;
217
217
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' ,
238
236
} ,
239
- ) ;
237
+ } ) ;
240
238
} ) ;
241
239
242
240
it ( 'should create spans with correct attributes for resource operations' , async ( ) => {
@@ -251,26 +249,24 @@ describe('wrapMcpServerWithSentry', () => {
251
249
252
250
mockTransport . onmessage ?.( jsonRpcRequest , { } ) ;
253
251
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' ,
272
268
} ,
273
- ) ;
269
+ } ) ;
274
270
} ) ;
275
271
276
272
it ( 'should create spans with correct attributes for prompt operations' , async ( ) => {
@@ -285,26 +281,24 @@ describe('wrapMcpServerWithSentry', () => {
285
281
286
282
mockTransport . onmessage ?.( jsonRpcRequest , { } ) ;
287
283
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' ,
306
300
} ,
307
- ) ;
301
+ } ) ;
308
302
} ) ;
309
303
310
304
it ( 'should create spans with correct attributes for notifications (no request id)' , async ( ) => {
@@ -547,7 +541,7 @@ describe('wrapMcpServerWithSentry', () => {
547
541
id : 'req-tool-result' ,
548
542
params : {
549
543
name : 'weather-lookup' ,
550
- arguments : { location : 'San Francisco' , units : 'celsius' }
544
+ arguments : { location : 'San Francisco' , units : 'celsius' } ,
551
545
} ,
552
546
} ;
553
547
@@ -576,11 +570,11 @@ describe('wrapMcpServerWithSentry', () => {
576
570
content : [
577
571
{
578
572
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
+ } ,
581
575
] ,
582
- isError : false
583
- }
576
+ isError : false ,
577
+ } ,
584
578
} ;
585
579
586
580
// Simulate the outgoing response (this should trigger span completion)
@@ -591,8 +585,9 @@ describe('wrapMcpServerWithSentry', () => {
591
585
expect . objectContaining ( {
592
586
'mcp.tool.result.is_error' : false ,
593
587
'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
+ } ) ,
596
591
) ;
597
592
598
593
// Verify span was completed successfully (no error status set)
@@ -625,26 +620,24 @@ describe('wrapMcpServerWithSentry', () => {
625
620
626
621
mockStdioTransport . onmessage ?.( jsonRpcRequest , { } ) ;
627
622
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' ,
646
639
} ,
647
- ) ;
640
+ } ) ;
648
641
} ) ;
649
642
650
643
it ( 'should handle stdio transport notifications correctly' , async ( ) => {
@@ -708,7 +701,7 @@ describe('wrapMcpServerWithSentry', () => {
708
701
attributes : expect . objectContaining ( {
709
702
'mcp.method.name' : 'resources/read' ,
710
703
'mcp.resource.uri' : 'https://api.example.com/data' ,
711
- 'mcp.transport' : 'sse' , // Deprecated but supported
704
+ 'mcp.transport' : 'sse' , // Deprecated but supported
712
705
'network.transport' : 'tcp' ,
713
706
'mcp.session.id' : 'sse-session-789' ,
714
707
} ) ,
0 commit comments