mcp: add Session.ID (#67)

Support retrieving the session ID from client and server sessions.

Fixes #65.
This commit is contained in:
Jonathan Amsterdam 2025-07-01 13:49:23 -04:00 • committed by GitHub
commit 9b6327b3b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -142,6 +142,18 @@ type ClientSession struct {
client *Client
initializeResult *InitializeResult
keepaliveCancel context.CancelFunc
mcpConn Connection
}
func (cs *ClientSession) setConn(c Connection) {
cs.mcpConn = c
}
func (cs *ClientSession) ID() string {
if cs.mcpConn == nil {
return ""
}
return cs.mcpConn.SessionID()
}
// Close performs a graceful close of the connection, preventing new requests