Skip to content

Commit 00c83ad

Browse files
committed
fix(Srv/stream): add ID field to PingRequest
1 parent e744c19 commit 00c83ad

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

server/streamable_http.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,16 @@ func (s *StreamableHTTPServer) handleGet(w http.ResponseWriter, r *http.Request)
389389
go func() {
390390
ticker := time.NewTicker(s.listenHeartbeatInterval)
391391
defer ticker.Stop()
392-
message := mcp.JSONRPCRequest{
393-
JSONRPC: "2.0",
394-
Request: mcp.Request{
395-
Method: "ping",
396-
},
397-
}
398392
for {
399393
select {
400394
case <-ticker.C:
395+
message := mcp.JSONRPCRequest{
396+
JSONRPC: "2.0",
397+
ID: mcp.NewRequestId(session.requestID.Add(1)),
398+
Request: mcp.Request{
399+
Method: "ping",
400+
},
401+
}
401402
select {
402403
case writeChan <- message:
403404
case <-done:
@@ -511,6 +512,7 @@ type streamableHttpSession struct {
511512
notificationChannel chan mcp.JSONRPCNotification // server -> client notifications
512513
tools *sessionToolsStore
513514
upgradeToSSE atomic.Bool
515+
requestID atomic.Int64
514516
}
515517

516518
func newStreamableHttpSession(sessionID string, toolStore *sessionToolsStore) *streamableHttpSession {

0 commit comments

Comments
 (0)