mcp: block server initiated requests (SEP-2322) (#1057)

This PR explicitly blocks server initiated requests in server.go
This commit is contained in:
Guglielmo Colombo 2026-07-08 15:17:41 +02:00 • committed by GitHub
commit deecf8a432
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -114,7 +114,7 @@ func TestElicitationURLMode(t *testing.T) {
},
ElicitationHandler: tc.handler,
})
cs, err := c.Connect(ctx, ct, nil)
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
if err != nil {
t.Fatal(err)
}
@ -165,8 +165,18 @@ func TestElicitationCompleteNotification(t *testing.T) {
},
})
_, ss, cleanup := basicClientServerConnection(t, c, nil, nil)
defer cleanup()
ct, st := NewInMemoryTransports()
s := NewServer(testImpl, nil)
ss, err := s.Connect(ctx, st, nil)
if err != nil {
t.Fatal(err)
}
defer ss.Close()
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
if err != nil {
t.Fatal(err)
}
defer cs.Close()
// 1. Server initiates a URL elicitation
elicitID := "testElicitationID-123"
@ -245,7 +255,7 @@ func TestElicitationNoValidationWithoutAccept(t *testing.T) {
return &ElicitResult{Action: tc.action, Content: tc.content}, nil
},
})
cs, err := c.Connect(ctx, ct, nil)
cs, err := c.Connect(ctx, ct, &ClientSessionOptions{protocolVersion: protocolVersion20251125})
if err != nil {
t.Fatal(err)
}