Skip to content

Commit 3f10c19

Browse files
authored
mcp: replace type struct{} with any for user-defined fields (#334)
This change adopts a clearer convention: - any is used for fields where the structure is defined by the client or server implementer. - an named empty struct type is the place holder type to be defined by the MCP spec in the future. The "Experimental" fields in "ClientCapabilities" and "ServerCapabilities" now use "map[string]any". This allows clients and servers to negotiate custom capabilities that contain complex data, rather than being restricted to a simple on/off flag. The "Metadata" field in "CreateMessageParams" was also changed to "any" to properly serve its purpose as a flexible container for server-defined data.
1 parent 73b8a7f commit 3f10c19

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mcp/protocol.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (x *CancelledParams) SetProgressToken(t any) { setProgressToken(x, t) }
126126
// additional capabilities.
127127
type ClientCapabilities struct {
128128
// Experimental, non-standard capabilities that the client supports.
129-
Experimental map[string]struct{} `json:"experimental,omitempty"`
129+
Experimental map[string]any `json:"experimental,omitempty"`
130130
// Present if the client supports listing roots.
131131
Roots struct {
132132
// Whether the client supports notifications for changes to the roots list.
@@ -242,7 +242,7 @@ type CreateMessageParams struct {
242242
Messages []*SamplingMessage `json:"messages"`
243243
// Optional metadata to pass through to the LLM provider. The format of this
244244
// metadata is provider-specific.
245-
Metadata struct{} `json:"metadata,omitempty"`
245+
Metadata any `json:"metadata,omitempty"`
246246
// The server's preferences for which model to select. The client may ignore
247247
// these preferences.
248248
ModelPreferences *ModelPreferences `json:"modelPreferences,omitempty"`
@@ -997,7 +997,7 @@ type ServerCapabilities struct {
997997
// Present if the server supports argument autocompletion suggestions.
998998
Completions *CompletionCapabilities `json:"completions,omitempty"`
999999
// Experimental, non-standard capabilities that the server supports.
1000-
Experimental map[string]struct{} `json:"experimental,omitempty"`
1000+
Experimental map[string]any `json:"experimental,omitempty"`
10011001
// Present if the server supports sending log messages to the client.
10021002
Logging *LoggingCapabilities `json:"logging,omitempty"`
10031003
// Present if the server offers any prompt templates.

0 commit comments

Comments
 (0)