diff --git a/mcp/resources.go b/mcp/resources.go index 51cdd25d..07a59a32 100644 --- a/mcp/resources.go +++ b/mcp/resources.go @@ -43,10 +43,7 @@ func WithMIMEType(mimeType string) ResourceOption { func WithAnnotations(audience []Role, priority float64) ResourceOption { return func(r *Resource) { if r.Annotations == nil { - r.Annotations = &struct { - Audience []Role `json:"audience,omitempty"` - Priority float64 `json:"priority,omitempty"` - }{} + r.Annotations = &Annotations{} } r.Annotations.Audience = audience r.Annotations.Priority = priority @@ -94,10 +91,7 @@ func WithTemplateMIMEType(mimeType string) ResourceTemplateOption { func WithTemplateAnnotations(audience []Role, priority float64) ResourceTemplateOption { return func(t *ResourceTemplate) { if t.Annotations == nil { - t.Annotations = &struct { - Audience []Role `json:"audience,omitempty"` - Priority float64 `json:"priority,omitempty"` - }{} + t.Annotations = &Annotations{} } t.Annotations.Audience = audience t.Annotations.Priority = priority diff --git a/mcp/types.go b/mcp/types.go index 2b2c6f00..f9c51ee8 100644 --- a/mcp/types.go +++ b/mcp/types.go @@ -659,24 +659,26 @@ type SamplingMessage struct { Content interface{} `json:"content"` // Can be TextContent or ImageContent } +type Annotations struct { + // Describes who the intended customer of this object or data is. + // + // It can include multiple entries to indicate content useful for multiple + // audiences (e.g., `["user", "assistant"]`). + Audience []Role `json:"audience,omitempty"` + + // Describes how important this data is for operating the server. + // + // A value of 1 means "most important," and indicates that the data is + // effectively required, while 0 means "least important," and indicates that + // the data is entirely optional. + Priority float64 `json:"priority,omitempty"` +} + // Annotated is the base for objects that include optional annotations for the // client. The client can use annotations to inform how objects are used or // displayed type Annotated struct { - Annotations *struct { - // Describes who the intended customer of this object or data is. - // - // It can include multiple entries to indicate content useful for multiple - // audiences (e.g., `["user", "assistant"]`). - Audience []Role `json:"audience,omitempty"` - - // Describes how important this data is for operating the server. - // - // A value of 1 means "most important," and indicates that the data is - // effectively required, while 0 means "least important," and indicates that - // the data is entirely optional. - Priority float64 `json:"priority,omitempty"` - } `json:"annotations,omitempty"` + Annotations *Annotations `json:"annotations,omitempty"` } type Content interface {