@@ -160,7 +160,7 @@ func TestSSE(t *testing.T) {
160160
161161 request := JSONRPCRequest {
162162 JSONRPC : "2.0" ,
163- ID : 1 ,
163+ ID : mcp . NewRequestId ( int64 ( 1 )) ,
164164 Method : "debug/echo" ,
165165 Params : params ,
166166 }
@@ -174,7 +174,7 @@ func TestSSE(t *testing.T) {
174174 // Parse the result to verify echo
175175 var result struct {
176176 JSONRPC string `json:"jsonrpc"`
177- ID int64 `json:"id"`
177+ ID mcp. RequestId `json:"id"`
178178 Method string `json:"method"`
179179 Params map [string ]any `json:"params"`
180180 }
@@ -187,8 +187,11 @@ func TestSSE(t *testing.T) {
187187 if result .JSONRPC != "2.0" {
188188 t .Errorf ("Expected JSONRPC value '2.0', got '%s'" , result .JSONRPC )
189189 }
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 )
192195 }
193196 if result .Method != "debug/echo" {
194197 t .Errorf ("Expected method 'debug/echo', got '%s'" , result .Method )
@@ -211,7 +214,7 @@ func TestSSE(t *testing.T) {
211214 // Prepare a request
212215 request := JSONRPCRequest {
213216 JSONRPC : "2.0" ,
214- ID : 3 ,
217+ ID : mcp . NewRequestId ( int64 ( 3 )) ,
215218 Method : "debug/echo" ,
216219 }
217220
@@ -292,7 +295,7 @@ func TestSSE(t *testing.T) {
292295 // Each request has a unique ID and payload
293296 request := JSONRPCRequest {
294297 JSONRPC : "2.0" ,
295- ID : int64 (100 + idx ),
298+ ID : mcp . NewRequestId ( int64 (100 + idx ) ),
296299 Method : "debug/echo" ,
297300 Params : map [string ]any {
298301 "requestIndex" : idx ,
@@ -317,15 +320,25 @@ func TestSSE(t *testing.T) {
317320 continue
318321 }
319322
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 )
322335 continue
323336 }
324337
325338 // Parse the result to verify echo
326339 var result struct {
327340 JSONRPC string `json:"jsonrpc"`
328- ID int64 `json:"id"`
341+ ID mcp. RequestId `json:"id"`
329342 Method string `json:"method"`
330343 Params map [string ]any `json:"params"`
331344 }
@@ -336,8 +349,11 @@ func TestSSE(t *testing.T) {
336349 }
337350
338351 // 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 )
341357 }
342358
343359 if result .Method != "debug/echo" {
@@ -356,7 +372,7 @@ func TestSSE(t *testing.T) {
356372 // Prepare a request
357373 request := JSONRPCRequest {
358374 JSONRPC : "2.0" ,
359- ID : 100 ,
375+ ID : mcp . NewRequestId ( int64 ( 100 )) ,
360376 Method : "debug/echo_error_string" ,
361377 }
362378
@@ -378,8 +394,11 @@ func TestSSE(t *testing.T) {
378394 if responseError .Method != "debug/echo_error_string" {
379395 t .Errorf ("Expected method 'debug/echo_error_string', got '%s'" , responseError .Method )
380396 }
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 )
383402 }
384403 if responseError .JSONRPC != "2.0" {
385404 t .Errorf ("Expected JSONRPC '2.0', got '%s'" , responseError .JSONRPC )
@@ -453,7 +472,7 @@ func TestSSEErrors(t *testing.T) {
453472 // Prepare a request
454473 request := JSONRPCRequest {
455474 JSONRPC : "2.0" ,
456- ID : 99 ,
475+ ID : mcp . NewRequestId ( int64 ( 99 )) ,
457476 Method : "ping" ,
458477 }
459478
@@ -492,7 +511,7 @@ func TestSSEErrors(t *testing.T) {
492511 // Try to send a request after close
493512 request := JSONRPCRequest {
494513 JSONRPC : "2.0" ,
495- ID : 1 ,
514+ ID : mcp . NewRequestId ( int64 ( 1 )) ,
496515 Method : "ping" ,
497516 }
498517
0 commit comments