@@ -160,7 +160,7 @@ func TestSSE(t *testing.T) {
160
160
161
161
request := JSONRPCRequest {
162
162
JSONRPC : "2.0" ,
163
- ID : 1 ,
163
+ ID : mcp . NewRequestId ( int64 ( 1 )) ,
164
164
Method : "debug/echo" ,
165
165
Params : params ,
166
166
}
@@ -174,7 +174,7 @@ func TestSSE(t *testing.T) {
174
174
// Parse the result to verify echo
175
175
var result struct {
176
176
JSONRPC string `json:"jsonrpc"`
177
- ID int64 `json:"id"`
177
+ ID mcp. RequestId `json:"id"`
178
178
Method string `json:"method"`
179
179
Params map [string ]any `json:"params"`
180
180
}
@@ -187,8 +187,11 @@ func TestSSE(t *testing.T) {
187
187
if result .JSONRPC != "2.0" {
188
188
t .Errorf ("Expected JSONRPC value '2.0', got '%s'" , result .JSONRPC )
189
189
}
190
- if result .ID != 1 {
191
- t .Errorf ("Expected ID 1, got %d" , result .ID )
190
+ idValue , ok := result .ID .Value ().(int64 )
191
+ if ! ok {
192
+ t .Errorf ("Expected ID to be int64, got %T" , result .ID .Value ())
193
+ } else if idValue != 1 {
194
+ t .Errorf ("Expected ID 1, got %d" , idValue )
192
195
}
193
196
if result .Method != "debug/echo" {
194
197
t .Errorf ("Expected method 'debug/echo', got '%s'" , result .Method )
@@ -211,7 +214,7 @@ func TestSSE(t *testing.T) {
211
214
// Prepare a request
212
215
request := JSONRPCRequest {
213
216
JSONRPC : "2.0" ,
214
- ID : 3 ,
217
+ ID : mcp . NewRequestId ( int64 ( 3 )) ,
215
218
Method : "debug/echo" ,
216
219
}
217
220
@@ -292,7 +295,7 @@ func TestSSE(t *testing.T) {
292
295
// Each request has a unique ID and payload
293
296
request := JSONRPCRequest {
294
297
JSONRPC : "2.0" ,
295
- ID : int64 (100 + idx ),
298
+ ID : mcp . NewRequestId ( int64 (100 + idx ) ),
296
299
Method : "debug/echo" ,
297
300
Params : map [string ]any {
298
301
"requestIndex" : idx ,
@@ -317,15 +320,25 @@ func TestSSE(t *testing.T) {
317
320
continue
318
321
}
319
322
320
- if responses [i ] == nil || responses [i ].ID == nil || * responses [i ].ID != int64 (100 + i ) {
321
- t .Errorf ("Request %d: Expected ID %d, got %v" , i , 100 + i , responses [i ])
323
+ if responses [i ] == nil {
324
+ t .Errorf ("Request %d: Response is nil" , i )
325
+ continue
326
+ }
327
+
328
+ expectedId := int64 (100 + i )
329
+ idValue , ok := responses [i ].ID .Value ().(int64 )
330
+ if ! ok {
331
+ t .Errorf ("Request %d: Expected ID to be int64, got %T" , i , responses [i ].ID .Value ())
332
+ continue
333
+ } else if idValue != expectedId {
334
+ t .Errorf ("Request %d: Expected ID %d, got %d" , i , expectedId , idValue )
322
335
continue
323
336
}
324
337
325
338
// Parse the result to verify echo
326
339
var result struct {
327
340
JSONRPC string `json:"jsonrpc"`
328
- ID int64 `json:"id"`
341
+ ID mcp. RequestId `json:"id"`
329
342
Method string `json:"method"`
330
343
Params map [string ]any `json:"params"`
331
344
}
@@ -336,8 +349,11 @@ func TestSSE(t *testing.T) {
336
349
}
337
350
338
351
// Verify data matches what was sent
339
- if result .ID != int64 (100 + i ) {
340
- t .Errorf ("Request %d: Expected echoed ID %d, got %d" , i , 100 + i , result .ID )
352
+ idValue , ok = result .ID .Value ().(int64 )
353
+ if ! ok {
354
+ t .Errorf ("Request %d: Expected ID to be int64, got %T" , i , result .ID .Value ())
355
+ } else if idValue != int64 (100 + i ) {
356
+ t .Errorf ("Request %d: Expected echoed ID %d, got %d" , i , 100 + i , idValue )
341
357
}
342
358
343
359
if result .Method != "debug/echo" {
@@ -356,7 +372,7 @@ func TestSSE(t *testing.T) {
356
372
// Prepare a request
357
373
request := JSONRPCRequest {
358
374
JSONRPC : "2.0" ,
359
- ID : 100 ,
375
+ ID : mcp . NewRequestId ( int64 ( 100 )) ,
360
376
Method : "debug/echo_error_string" ,
361
377
}
362
378
@@ -378,8 +394,11 @@ func TestSSE(t *testing.T) {
378
394
if responseError .Method != "debug/echo_error_string" {
379
395
t .Errorf ("Expected method 'debug/echo_error_string', got '%s'" , responseError .Method )
380
396
}
381
- if responseError .ID != 100 {
382
- t .Errorf ("Expected ID 100, got %d" , responseError .ID )
397
+ idValue , ok := responseError .ID .Value ().(int64 )
398
+ if ! ok {
399
+ t .Errorf ("Expected ID to be int64, got %T" , responseError .ID .Value ())
400
+ } else if idValue != 100 {
401
+ t .Errorf ("Expected ID 100, got %d" , idValue )
383
402
}
384
403
if responseError .JSONRPC != "2.0" {
385
404
t .Errorf ("Expected JSONRPC '2.0', got '%s'" , responseError .JSONRPC )
@@ -453,7 +472,7 @@ func TestSSEErrors(t *testing.T) {
453
472
// Prepare a request
454
473
request := JSONRPCRequest {
455
474
JSONRPC : "2.0" ,
456
- ID : 99 ,
475
+ ID : mcp . NewRequestId ( int64 ( 99 )) ,
457
476
Method : "ping" ,
458
477
}
459
478
@@ -492,7 +511,7 @@ func TestSSEErrors(t *testing.T) {
492
511
// Try to send a request after close
493
512
request := JSONRPCRequest {
494
513
JSONRPC : "2.0" ,
495
- ID : 1 ,
514
+ ID : mcp . NewRequestId ( int64 ( 1 )) ,
496
515
Method : "ping" ,
497
516
}
498
517
0 commit comments