Documentation
¶
Index ¶
- type Annotations
- type AudioContent
- type CancelledParams
- type Capabilities
- type ClientInfo
- type CompleteArgument
- type CompleteContext
- type CompleteRequest
- type CompleteResult
- type CompletionHandler
- type CompletionHandlers
- type CompletionRef
- type CompletionValues
- type CompletionsCapability
- type EmbeddedResourceContent
- type EmptyResult
- type GetPromptResult
- type HealthCheckResponse
- type Icon
- type ImageContent
- type InitializeParams
- type InitializeResult
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- type LogMessageParams
- type LoggingCapability
- type MCP
- func (s *MCP) AddCompletionHandler(refKey string, handler CompletionHandler)
- func (s *MCP) AddPrompt(prompt Prompt, handler PromptHandler)
- func (s *MCP) AddResource(resource Resource, handler ResourceHandler)
- func (s *MCP) AddResourceTemplate(template ResourceTemplate)
- func (s *MCP) AddTool(tool Tool, handler ToolHandler)
- func (s *MCP) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Prompt
- type PromptArg
- type PromptContent
- type PromptHandler
- type PromptMessage
- type Prompts
- type PromptsCapability
- type PromptsGetParams
- type PromptsListResult
- type Resource
- type ResourceContent
- type ResourceHandler
- type ResourceLinkContent
- type ResourceTemplate
- type ResourceTemplates
- type ResourceTemplatesListResult
- type ResourceUpdatedNotification
- type Resources
- type ResourcesCapability
- type ResourcesListResult
- type ResourcesReadParams
- type ResourcesReadResult
- type ServerInfo
- type SetLevelRequest
- type SubscribeRequest
- type TaskStatusNotification
- type TextContent
- type Tool
- type ToolCallParams
- type ToolCallResult
- type ToolHandler
- type Tools
- type ToolsCapability
- type ToolsListResult
- type UnsubscribeRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotations ¶
type Annotations struct {
Audience []string `json:"audience,omitempty"`
Priority *float64 `json:"priority,omitempty"`
LastModified string `json:"lastModified,omitempty"`
}
Annotations provide hints to clients about how to use or display content.
type AudioContent ¶
type AudioContent struct {
Type string `json:"type"` // "audio"
Data string `json:"data"`
MimeType string `json:"mimeType"`
Annotations *Annotations `json:"annotations,omitempty"`
}
AudioContent represents base64-encoded audio content.
func NewAudioContent ¶
func NewAudioContent(data string, mimeType string) AudioContent
NewAudioContent creates a new AudioContent with the type field set.
type CancelledParams ¶
type CancelledParams struct {
RequestID any `json:"requestId"`
Reason string `json:"reason,omitempty"`
}
CancelledParams represents the parameters for a notifications/cancelled notification.
type Capabilities ¶
type Capabilities struct {
Tools *ToolsCapability `json:"tools,omitempty"`
Resources *ResourcesCapability `json:"resources,omitempty"`
Prompts *PromptsCapability `json:"prompts,omitempty"`
Logging *LoggingCapability `json:"logging,omitempty"`
Completions *CompletionsCapability `json:"completions,omitempty"`
}
type ClientInfo ¶
type CompleteArgument ¶
type CompleteContext ¶
type CompleteRequest ¶
type CompleteRequest struct {
Ref CompletionRef `json:"ref"`
Argument CompleteArgument `json:"argument"`
Context *CompleteContext `json:"context,omitempty"`
}
type CompleteResult ¶
type CompleteResult struct {
Completion CompletionValues `json:"completion"`
}
type CompletionHandler ¶
type CompletionHandler func(req CompleteRequest) (CompletionValues, error)
CompletionHandler represents a function that provides completion suggestions.
type CompletionHandlers ¶
type CompletionHandlers struct {
// contains filtered or unexported fields
}
CompletionHandlers holds registered completion handlers.
func (*CompletionHandlers) Add ¶
func (ch *CompletionHandlers) Add(refKey string, handler CompletionHandler)
func (*CompletionHandlers) GetHandler ¶
func (ch *CompletionHandlers) GetHandler(refKey string) CompletionHandler
type CompletionRef ¶
type CompletionValues ¶
type CompletionsCapability ¶
type CompletionsCapability struct{}
type EmbeddedResourceContent ¶
type EmbeddedResourceContent struct {
Type string `json:"type"` // "resource"
Resource ResourceContent `json:"resource"`
Annotations *Annotations `json:"annotations,omitempty"`
}
EmbeddedResourceContent represents an embedded resource in content.
func NewEmbeddedResourceContent ¶
func NewEmbeddedResourceContent(resource ResourceContent) EmbeddedResourceContent
NewEmbeddedResourceContent creates a new EmbeddedResourceContent with the type field set.
type GetPromptResult ¶
type GetPromptResult struct {
Description string `json:"description,omitempty"`
Messages []PromptMessage `json:"messages"`
}
type HealthCheckResponse ¶
type Icon ¶
type Icon struct {
Src string `json:"src"`
MimeType string `json:"mimeType,omitempty"`
Sizes []string `json:"sizes,omitempty"`
}
Icon represents an icon for display in user interfaces.
type ImageContent ¶
type ImageContent struct {
Type string `json:"type"` // "image"
Data string `json:"data"`
MimeType string `json:"mimeType"`
Annotations *Annotations `json:"annotations,omitempty"`
}
ImageContent represents base64-encoded image content.
func NewImageContent ¶
func NewImageContent(data string, mimeType string) ImageContent
NewImageContent creates a new ImageContent with the type field set.
type InitializeParams ¶
type InitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities map[string]any `json:"capabilities"`
ClientInfo ClientInfo `json:"clientInfo"`
}
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities Capabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
Instructions string `json:"instructions,omitempty"`
}
type JSONRPCError ¶
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id,omitempty"`
Result any `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
type LogMessageParams ¶
type LoggingCapability ¶
type LoggingCapability struct{}
type MCP ¶
type MCP struct {
Tools Tools
Resources Resources
ResourceTemplates ResourceTemplates
Prompts Prompts
CompletionHandlers CompletionHandlers
ServerName string
ServerVersion string
Instructions string
}
func (*MCP) AddCompletionHandler ¶
func (s *MCP) AddCompletionHandler(refKey string, handler CompletionHandler)
AddCompletionHandler registers a completion handler for a reference key. Use "prompt:<name>" for prompt completions and "resource:<uri>" for resource completions.
func (*MCP) AddPrompt ¶
func (s *MCP) AddPrompt(prompt Prompt, handler PromptHandler)
AddPrompt registers a prompt and its handler.
func (*MCP) AddResource ¶
func (s *MCP) AddResource(resource Resource, handler ResourceHandler)
AddResource registers a resource and its handler.
func (*MCP) AddResourceTemplate ¶
func (s *MCP) AddResourceTemplate(template ResourceTemplate)
AddResourceTemplate registers a resource template.
func (*MCP) AddTool ¶
func (s *MCP) AddTool(tool Tool, handler ToolHandler)
AddTool registers a tool and its handler.
type PromptContent ¶
type PromptHandler ¶
type PromptHandler func(args map[string]string) (GetPromptResult, error)
PromptHandler represents a function that generates prompt content.
type PromptMessage ¶
type PromptMessage struct {
Role string `json:"role"`
Content PromptContent `json:"content"`
}
type Prompts ¶
type Prompts struct {
// contains filtered or unexported fields
}
func (*Prompts) Add ¶
func (p *Prompts) Add(prompt Prompt, handler PromptHandler)
func (*Prompts) GetHandler ¶
func (p *Prompts) GetHandler(name string) PromptHandler
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
type PromptsGetParams ¶
type PromptsGetParams struct {
Name string `json:"name"`
Arguments map[string]string `json:"arguments,omitempty"`
}
PromptsGetParams represents the parameters for a prompts/get request.
type PromptsListResult ¶
type PromptsListResult struct {
Prompts []Prompt `json:"prompts"`
NextCursor string `json:"nextCursor,omitempty"`
}
PromptsListResult is the result of a prompts/list request.
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Icons []Icon `json:"icons,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Size *int64 `json:"size,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
type ResourceContent ¶
type ResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
ResourceContent represents the contents of a resource (text or binary).
type ResourceHandler ¶
type ResourceHandler func(uri string) (ResourceContent, error)
ResourceHandler represents a function that provides resource content.
type ResourceLinkContent ¶
type ResourceLinkContent struct {
Type string `json:"type"` // "resource_link"
URI string `json:"uri"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
ResourceLinkContent represents a link to a resource.
func NewResourceLinkContent ¶
func NewResourceLinkContent(uri string) ResourceLinkContent
NewResourceLinkContent creates a new ResourceLinkContent with the type field set.
type ResourceTemplate ¶
type ResourceTemplate struct {
URITemplate string `json:"uriTemplate"`
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Icons []Icon `json:"icons,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
type ResourceTemplates ¶
type ResourceTemplates struct {
// contains filtered or unexported fields
}
func (*ResourceTemplates) Add ¶
func (rt *ResourceTemplates) Add(template ResourceTemplate)
func (*ResourceTemplates) List ¶
func (rt *ResourceTemplates) List() []ResourceTemplate
type ResourceTemplatesListResult ¶
type ResourceTemplatesListResult struct {
ResourceTemplates []ResourceTemplate `json:"resourceTemplates"`
NextCursor string `json:"nextCursor,omitempty"`
}
ResourceTemplatesListResult is the result of a resources/templates/list request.
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
func (*Resources) Add ¶
func (r *Resources) Add(resource Resource, handler ResourceHandler)
func (*Resources) GetHandler ¶
func (r *Resources) GetHandler(uri string) ResourceHandler
type ResourcesCapability ¶
type ResourcesListResult ¶
type ResourcesListResult struct {
Resources []Resource `json:"resources"`
NextCursor string `json:"nextCursor,omitempty"`
}
ResourcesListResult is the result of a resources/list request.
type ResourcesReadParams ¶
type ResourcesReadParams struct {
URI string `json:"uri"`
}
ResourcesReadParams represents the parameters for a resources/read request.
type ResourcesReadResult ¶
type ResourcesReadResult struct {
Contents []ResourceContent `json:"contents"`
}
ResourcesReadResult is the result of a resources/read request.
type ServerInfo ¶
type SetLevelRequest ¶
type SetLevelRequest struct {
Level string `json:"level"`
}
type SubscribeRequest ¶
type SubscribeRequest struct {
URI string `json:"uri"`
}
type TaskStatusNotification ¶
type TaskStatusNotification struct {
TaskID string `json:"taskId"`
Status string `json:"status"`
StatusMessage string `json:"statusMessage,omitempty"`
CreatedAt string `json:"createdAt"`
LastUpdatedAt string `json:"lastUpdatedAt,omitempty"`
TTL *int64 `json:"ttl,omitempty"`
PollInterval *int64 `json:"pollInterval,omitempty"`
}
TaskStatusNotification represents the parameters for a notifications/tasks/status notification.
type TextContent ¶
type TextContent struct {
Type string `json:"type"` // "text"
Text string `json:"text"`
Annotations *Annotations `json:"annotations,omitempty"`
}
TextContent represents plain text content.
func NewTextContent ¶
func NewTextContent(text string) TextContent
NewTextContent creates a new TextContent with the type field set.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description"`
Icons []Icon `json:"icons,omitempty"`
InputSchema map[string]any `json:"inputSchema"`
OutputSchema map[string]any `json:"outputSchema,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
type ToolCallParams ¶
type ToolCallParams struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
}
ToolCallParams represents the parameters for a tools/call request.
type ToolCallResult ¶
type ToolCallResult struct {
Content []any `json:"content,omitempty"`
StructuredContent any `json:"structuredContent,omitempty"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResult is the result of a tools/call request.
func NewToolCallErrorResult ¶
func NewToolCallErrorResult(text string) ToolCallResult
NewToolCallErrorResult creates a ToolCallResult with isError set to true.
func NewToolCallResult ¶
func NewToolCallResult(text string) ToolCallResult
NewToolCallResult creates a ToolCallResult with a single text content.
type ToolHandler ¶
type ToolHandler func(args map[string]any) (ToolCallResult, error)
ToolHandler represents a function that handles tool calls.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
func (*Tools) Add ¶
func (t *Tools) Add(tool Tool, handler ToolHandler)
func (*Tools) GetHandler ¶
func (t *Tools) GetHandler(name string) ToolHandler
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
type ToolsListResult ¶
type ToolsListResult struct {
Tools []Tool `json:"tools"`
NextCursor string `json:"nextCursor,omitempty"`
}
ToolsListResult is the result of a tools/list request.
type UnsubscribeRequest ¶
type UnsubscribeRequest struct {
URI string `json:"uri"`
}