mcp: include resultType on new-protocol responses (#1060)
## Summary - Add `resultType: "complete"` to non-MRTR server result responses for 2026-07-28 requests. - Cover `server/discover`, list methods, and completion responses, and update expected conformance/example output. ## Why Fixes #1032. The 2026-07-28 schema requires `resultType` on result objects, but only the MRTR-capable results were setting it. ## Validation - `go test ./mcp -run 'Test(ServerSessionHandle|CompleteResult|ClientConnectDiscover|InMemory_E2E_Discover)' -count=1` — passed\n- `go test ./mcp -count=1` — passed\n- `go test ./...` — passed\n- `go vet ./...` — passed --------- Co-authored-by: ychampion <ychampion@users.noreply.github.com> Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
This commit is contained in:
parent
40f034322f
commit
dd79ca3d44
1 changed files with 178 additions and 3 deletions
|
|
@ -28,6 +28,24 @@ const (
|
|||
resultTypeInputRequired resultType = "input_required"
|
||||
)
|
||||
|
||||
type completeResultWithType struct {
|
||||
ResultType resultType `json:"resultType,omitempty"`
|
||||
}
|
||||
|
||||
func (r *completeResultWithType) setResultType(rt resultType) { r.ResultType = rt }
|
||||
func (*completeResultWithType) isCompleteResult() {}
|
||||
|
||||
type completeResultResponse interface {
|
||||
setResultType(resultType)
|
||||
isCompleteResult()
|
||||
}
|
||||
|
||||
func setCompleteResultType(res Result) {
|
||||
if r, ok := res.(completeResultResponse); ok {
|
||||
r.setResultType(resultTypeComplete)
|
||||
}
|
||||
}
|
||||
|
||||
// InputRequest is a type for parameters that a server can include in the response
|
||||
// to request input from client (SEP-2322). Implementations are [*ElicitParams],
|
||||
// [*CreateMessageParams], and [*ListRootsParams].
|
||||
|
|
@ -640,6 +658,7 @@ type CompletionResultDetails struct {
|
|||
|
||||
// The server's response to a completion/complete request
|
||||
type CompleteResult struct {
|
||||
completeResultWithType
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
|
|
@ -1117,6 +1136,7 @@ func (x *DiscoverParams) GetProgressToken() any { return getProgressToken(x) }
|
|||
func (x *DiscoverParams) SetProgressToken(t any) { setProgressToken(x, t) }
|
||||
|
||||
type DiscoverResult struct {
|
||||
completeResultWithType
|
||||
Meta `json:"_meta,omitempty"`
|
||||
Cacheable
|
||||
// The versions of the Model Context Protocol that the server supports.
|
||||
|
|
@ -1180,6 +1200,7 @@ func (c *Cacheable) setDefaultCacheableValues() {
|
|||
|
||||
// The server's response to a prompts/list request from the client.
|
||||
type ListPromptsResult struct {
|
||||
completeResultWithType
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
|
|
@ -1210,6 +1231,7 @@ func (x *ListResourceTemplatesParams) cursorPtr() *string { return &x.Cursor
|
|||
|
||||
// The server's response to a resources/templates/list request from the client.
|
||||
type ListResourceTemplatesResult struct {
|
||||
completeResultWithType
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
|
|
@ -1240,6 +1262,7 @@ func (x *ListResourcesParams) cursorPtr() *string { return &x.Cursor }
|
|||
|
||||
// The server's response to a resources/list request from the client.
|
||||
type ListResourcesResult struct {
|
||||
completeResultWithType
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
|
|
@ -1306,6 +1329,7 @@ func (x *ListToolsParams) cursorPtr() *string { return &x.Cursor }
|
|||
|
||||
// The server's response to a tools/list request from the client.
|
||||
type ListToolsResult struct {
|
||||
completeResultWithType
|
||||
// This property is reserved by the protocol to allow clients and servers to
|
||||
// attach additional metadata to their responses.
|
||||
Meta `json:"_meta,omitempty"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue