@@ -98,6 +98,11 @@ func AsBlobResourceContents(content any) (*BlobResourceContents, bool) {
98
98
return asType [BlobResourceContents ](content )
99
99
}
100
100
101
+ // AsCommandContent attempts to cast the given interface to CommandContent
102
+ func AsCommandContent (content any ) (* CommandContent , bool ) {
103
+ return asType [CommandContent ](content )
104
+ }
105
+
101
106
// Helper function for JSON-RPC
102
107
103
108
// NewJSONRPCResponse creates a new JSONRPCResponse with the given id and result
@@ -354,7 +359,7 @@ func NewToolResultErrorf(format string, a ...any) *CallToolResult {
354
359
}
355
360
356
361
// NewToolResultCommand creates a CallToolResult with a command content.
357
- func NewToolResultCommand (command string , params map [string ]interface {} ) * CallToolResult {
362
+ func NewToolResultCommand (command string , params map [string ]any ) * CallToolResult {
358
363
return & CallToolResult {
359
364
Content : []Content {
360
365
CommandContent {
@@ -522,6 +527,18 @@ func ParseContent(contentMap map[string]any) (Content, error) {
522
527
}
523
528
524
529
return NewEmbeddedResource (resourceContents ), nil
530
+
531
+ case "command" :
532
+ command := ExtractString (contentMap , "command" )
533
+ if command == "" {
534
+ return nil , fmt .Errorf ("command name is missing" )
535
+ }
536
+ params := ExtractMap (contentMap , "params" )
537
+ return CommandContent {
538
+ Type : "command" ,
539
+ Command : command ,
540
+ Params : params ,
541
+ }, nil
525
542
}
526
543
527
544
return nil , fmt .Errorf ("unsupported content type: %s" , contentType )
0 commit comments