Skip to content

Commit 9d62b19

Browse files
authored
Pull out Annotations structure (#203)
1 parent 5a98f22 commit 9d62b19

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

mcp/resources.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ func WithMIMEType(mimeType string) ResourceOption {
4343
func WithAnnotations(audience []Role, priority float64) ResourceOption {
4444
return func(r *Resource) {
4545
if r.Annotations == nil {
46-
r.Annotations = &struct {
47-
Audience []Role `json:"audience,omitempty"`
48-
Priority float64 `json:"priority,omitempty"`
49-
}{}
46+
r.Annotations = &Annotations{}
5047
}
5148
r.Annotations.Audience = audience
5249
r.Annotations.Priority = priority
@@ -94,10 +91,7 @@ func WithTemplateMIMEType(mimeType string) ResourceTemplateOption {
9491
func WithTemplateAnnotations(audience []Role, priority float64) ResourceTemplateOption {
9592
return func(t *ResourceTemplate) {
9693
if t.Annotations == nil {
97-
t.Annotations = &struct {
98-
Audience []Role `json:"audience,omitempty"`
99-
Priority float64 `json:"priority,omitempty"`
100-
}{}
94+
t.Annotations = &Annotations{}
10195
}
10296
t.Annotations.Audience = audience
10397
t.Annotations.Priority = priority

mcp/types.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -659,24 +659,26 @@ type SamplingMessage struct {
659659
Content interface{} `json:"content"` // Can be TextContent or ImageContent
660660
}
661661

662+
type Annotations struct {
663+
// Describes who the intended customer of this object or data is.
664+
//
665+
// It can include multiple entries to indicate content useful for multiple
666+
// audiences (e.g., `["user", "assistant"]`).
667+
Audience []Role `json:"audience,omitempty"`
668+
669+
// Describes how important this data is for operating the server.
670+
//
671+
// A value of 1 means "most important," and indicates that the data is
672+
// effectively required, while 0 means "least important," and indicates that
673+
// the data is entirely optional.
674+
Priority float64 `json:"priority,omitempty"`
675+
}
676+
662677
// Annotated is the base for objects that include optional annotations for the
663678
// client. The client can use annotations to inform how objects are used or
664679
// displayed
665680
type Annotated struct {
666-
Annotations *struct {
667-
// Describes who the intended customer of this object or data is.
668-
//
669-
// It can include multiple entries to indicate content useful for multiple
670-
// audiences (e.g., `["user", "assistant"]`).
671-
Audience []Role `json:"audience,omitempty"`
672-
673-
// Describes how important this data is for operating the server.
674-
//
675-
// A value of 1 means "most important," and indicates that the data is
676-
// effectively required, while 0 means "least important," and indicates that
677-
// the data is entirely optional.
678-
Priority float64 `json:"priority,omitempty"`
679-
} `json:"annotations,omitempty"`
681+
Annotations *Annotations `json:"annotations,omitempty"`
680682
}
681683

682684
type Content interface {

0 commit comments

Comments
 (0)