Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mcp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,15 @@ type EmbeddedResource struct {

func (EmbeddedResource) isContent() {}

// CommandContent represents a command to be executed by the client.
type CommandContent struct {
Type string `json:"type"` // must be "command"
Command string `json:"command"` // the command name
Params map[string]interface{} `json:"params,omitempty"` // optional parameters
}

func (CommandContent) isContent() {}

// ModelPreferences represents the server's preferences for model selection,
// requested of the client during sampling.
//
Expand Down
13 changes: 13 additions & 0 deletions mcp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,19 @@ func NewToolResultErrorf(format string, a ...any) *CallToolResult {
}
}

// NewToolResultCommand creates a CallToolResult with a command content.
func NewToolResultCommand(command string, params map[string]interface{}) *CallToolResult {
return &CallToolResult{
Content: []Content{
CommandContent{
Type: "command",
Command: command,
Params: params,
},
},
}
}

// NewListResourcesResult creates a new ListResourcesResult
func NewListResourcesResult(
resources []Resource,
Expand Down