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

@ -69,7 +69,10 @@ func TestStreamableTransports(t *testing.T) {
t.Fatalf("client.Connect() failed: %v", err)
}
defer session.Close()
sid := session.ID()
if sid == "" {
t.Error("empty session ID")
}
// 4. The client calls the "greet" tool.
params := &CallToolParams{
Name: "greet",
@ -79,6 +82,9 @@ func TestStreamableTransports(t *testing.T) {
if err != nil {
t.Fatalf("CallTool() failed: %v", err)
}
if g := session.ID(); g != sid {
t.Errorf("session ID: got %q, want %q", g, sid)
}
// 5. Verify that the correct response is received.
want := &CallToolResult{