@@ -39,70 +39,18 @@ type Annotations struct {
39
39
Priority float64 `json:"priority,omitempty"`
40
40
}
41
41
42
- type CallToolParams struct {
43
- // This property is reserved by the protocol to allow clients and servers to
44
- // attach additional metadata to their responses.
45
- Meta `json:"_meta,omitempty"`
46
- Arguments any `json:"arguments,omitempty"`
47
- Name string `json:"name"`
48
- }
49
-
50
- func (x * CallToolParams ) GetProgressToken () any { return getProgressToken (x ) }
51
- func (x * CallToolParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
42
+ type CallToolParams = CallToolParamsFor [any ]
52
43
53
44
type CallToolParamsFor [In any ] struct {
54
45
// This property is reserved by the protocol to allow clients and servers to
55
46
// attach additional metadata to their responses.
56
47
Meta `json:"_meta,omitempty"`
57
- Arguments In `json:"arguments,omitempty"`
58
48
Name string `json:"name"`
49
+ Arguments In `json:"arguments,omitempty"`
59
50
}
60
51
61
52
// The server's response to a tool call.
62
- type CallToolResult struct {
63
- // This property is reserved by the protocol to allow clients and servers to
64
- // attach additional metadata to their responses.
65
- Meta `json:"_meta,omitempty"`
66
- // A list of content objects that represent the unstructured result of the tool
67
- // call.
68
- Content []Content `json:"content"`
69
- // Whether the tool call ended in an error.
70
- //
71
- // If not set, this is assumed to be false (the call was successful).
72
- //
73
- // Any errors that originate from the tool should be reported inside the result
74
- // object, with isError set to true, not as an MCP protocol-level error
75
- // response. Otherwise, the LLM would not be able to see that an error occurred
76
- // and self-correct.
77
- //
78
- // However, any errors in finding the tool, an error indicating that the
79
- // server does not support tool calls, or any other exceptional conditions,
80
- // should be reported as an MCP error response.
81
- IsError bool `json:"isError,omitempty"`
82
- // An optional JSON object that represents the structured result of the tool
83
- // call.
84
- // TODO(jba,rfindley): should this be any?
85
- StructuredContent map [string ]any `json:"structuredContent,omitempty"`
86
- }
87
-
88
- // UnmarshalJSON handles the unmarshalling of content into the Content
89
- // interface.
90
- func (x * CallToolResult ) UnmarshalJSON (data []byte ) error {
91
- type res CallToolResult // avoid recursion
92
- var wire struct {
93
- res
94
- Content []* wireContent `json:"content"`
95
- }
96
- if err := json .Unmarshal (data , & wire ); err != nil {
97
- return err
98
- }
99
- var err error
100
- if wire .res .Content , err = contentsFromWire (wire .Content , nil ); err != nil {
101
- return err
102
- }
103
- * x = CallToolResult (wire .res )
104
- return nil
105
- }
53
+ type CallToolResult = CallToolResultFor [any ]
106
54
107
55
type CallToolResultFor [Out any ] struct {
108
56
// This property is reserved by the protocol to allow clients and servers to
@@ -111,6 +59,9 @@ type CallToolResultFor[Out any] struct {
111
59
// A list of content objects that represent the unstructured result of the tool
112
60
// call.
113
61
Content []Content `json:"content"`
62
+ // An optional JSON object that represents the structured result of the tool
63
+ // call.
64
+ StructuredContent Out `json:"structuredContent,omitempty"`
114
65
// Whether the tool call ended in an error.
115
66
//
116
67
// If not set, this is assumed to be false (the call was successful).
@@ -124,9 +75,6 @@ type CallToolResultFor[Out any] struct {
124
75
// server does not support tool calls, or any other exceptional conditions,
125
76
// should be reported as an MCP error response.
126
77
IsError bool `json:"isError,omitempty"`
127
- // An optional JSON object that represents the structured result of the tool
128
- // call.
129
- StructuredContent Out `json:"structuredContent,omitempty"`
130
78
}
131
79
132
80
// UnmarshalJSON handles the unmarshalling of content into the Content
@@ -148,6 +96,9 @@ func (x *CallToolResultFor[Out]) UnmarshalJSON(data []byte) error {
148
96
return nil
149
97
}
150
98
99
+ func (x * CallToolParamsFor [Out ]) GetProgressToken () any { return getProgressToken (x ) }
100
+ func (x * CallToolParamsFor [Out ]) SetProgressToken (t any ) { setProgressToken (x , t ) }
101
+
151
102
type CancelledParams struct {
152
103
// This property is reserved by the protocol to allow clients and servers to
153
104
// attach additional metadata to their responses.
0 commit comments