Documentation
¶
Overview ¶
Package resources provides the resource registry for the MCP server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContentBlock ¶
type ContentBlock struct {
Blob string `json:"blob,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
URI string `json:"uri"`
}
ContentBlock represents a single content item in a resource read result.
type Option ¶
type Option func(*Resource)
Option configures a Resource during registration.
func WithMimeType ¶
WithMimeType returns an Option that sets the resource's MIME type.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds registered resources sorted alphabetically by URI. Not safe for concurrent use — register all resources before starting the server.
func (*Registry) LookupTemplate ¶ added in v0.6.3
func (r *Registry) LookupTemplate(uri string) (ResourceTemplate, bool)
LookupTemplate finds the first template whose URI pattern matches the given URI. Returns the template and true if a match is found. Templates use RFC 6570 Level 1 syntax: literal segments plus {variable} placeholders that each match one or more characters.
func (*Registry) Resources ¶
Resources returns a copy of all registered static resources in alphabetical order.
func (*Registry) Templates ¶
func (r *Registry) Templates() []ResourceTemplate
Templates returns a copy of all registered resource templates in alphabetical order.
type Resource ¶
type Resource struct {
Description string `json:"description,omitempty"`
Handler resourceHandler `json:"-"`
MimeType string `json:"mimeType,omitempty"`
Name string `json:"name"`
URI string `json:"uri"`
}
Resource represents a registered MCP resource.
type ResourceTemplate ¶
type ResourceTemplate struct {
Description string `json:"description,omitempty"`
Handler templateHandler `json:"-"`
MimeType string `json:"mimeType,omitempty"`
Name string `json:"name"`
URITemplate string `json:"uriTemplate"`
}
ResourceTemplate represents a URI template for dynamic resources.
type Result ¶
type Result struct {
Contents []ContentBlock `json:"contents"`
}
Result is the outcome of reading a resource.
func BlobResult ¶
BlobResult creates a Result with a single base64-encoded content block.
func TextResult ¶
TextResult creates a Result with a single text content block.