Documentation
¶
Index ¶
- Constants
- type Annotations
- type CompleteRequest
- type CompleteResponse
- type Content
- type CreateMessageRequest
- type CreateMessageResponse
- type GetPromptRequest
- type GetPromptResponse
- type InitializeRequest
- type InitializeResponse
- type InitializedNotification
- type InputSchema
- type ListPromptsRequest
- type ListPromptsResponse
- type ListResourceTemplatesRequest
- type ListResourceTemplatesResponse
- type ListResourcesRequest
- type ListResourcesResponse
- type ListRootsRequest
- type ListRootsResponse
- type LogNotification
- type ModelHint
- type ModelPreferences
- type PingRequest
- type PingResponse
- type ProgressNotification
- type Prompt
- type PromptArgument
- type PromptListChangedNotification
- type PromptMessage
- type ReadResourceRequest
- type ReadResourceResponse
- type Resource
- type ResourceContents
- type ResourceListChangedNotification
- type ResourceTemplate
- type ResourceUpdatedNotification
- type Role
- type Root
- type RootsListChangedNotification
- type SamplingMessage
- type Server
- type ServerCapabilities
- type ServerInfo
- type ServerOption
- type SetLevelRequest
- type SubscribeRequest
- type Tool
- type ToolCallRequest
- type ToolCallResponse
- type ToolsChangedNotification
- type ToolsListRequest
- type ToolsListResponse
- type Transport
- type UnsubscribeRequest
Constants ¶
const Version = "2024-11-05"
Version is the Model Context Protocol version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotations ¶
type Annotations struct {
// Describes who the intended customer of this object or data is
Audience []Role `json:"audience,omitempty"`
// Describes how important this data is for operating the server (0-1)
Priority *float64 `json:"priority,omitempty"`
}
Annotations represents optional annotations for objects
type CompleteRequest ¶
type CompleteRequest struct {
Ref interface{} `json:"ref"`
Argument struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"argument"`
}
CompleteRequest represents a request for completion options
type CompleteResponse ¶
type CompleteResponse struct {
Completion struct {
Values []string `json:"values"`
Total int `json:"total,omitempty"`
HasMore bool `json:"hasMore,omitempty"`
} `json:"completion"`
}
CompleteResponse represents the response for completion/complete
type Content ¶
type Content struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}
Content represents the base content type
func NewImageContent ¶
NewImageContent creates a new ImageContent with the given data and optional annotations
type CreateMessageRequest ¶
type CreateMessageRequest struct {
Messages []SamplingMessage `json:"messages"`
ModelPreferences *ModelPreferences `json:"modelPreferences,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
IncludeContext string `json:"includeContext,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"maxTokens"`
StopSequences []string `json:"stopSequences,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateMessageRequest represents a request to create a message via sampling
type CreateMessageResponse ¶
type CreateMessageResponse struct {
Role Role `json:"role"`
Content Content `json:"content"`
Model string `json:"model"`
StopReason string `json:"stopReason,omitempty"`
}
CreateMessageResponse represents the response for sampling/createMessage
type GetPromptRequest ¶
type GetPromptRequest struct {
Name string `json:"name"`
Arguments map[string]string `json:"arguments,omitempty"`
}
GetPromptRequest represents a request to get a specific prompt
type GetPromptResponse ¶
type GetPromptResponse struct {
Description string `json:"description,omitempty"`
Messages []PromptMessage `json:"messages"`
}
GetPromptResponse represents the response for prompts/get
type InitializeRequest ¶
type InitializeRequest struct{}
InitializeRequest represents a request to initialize the server
type InitializeResponse ¶
type InitializeResponse struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
Instructions string `json:"instructions,omitempty"`
}
InitializeResponse represents the server's response to an initialize request
type InitializedNotification ¶
type InitializedNotification struct{}
InitializedNotification represents a notification that initialization is complete
type InputSchema ¶
type InputSchema struct {
Type string `json:"type"`
Properties map[string]interface{} `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
InputSchema represents the JSON Schema for tool parameters
type ListPromptsRequest ¶
type ListPromptsRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ListPromptsRequest represents a request to list available prompts
type ListPromptsResponse ¶
type ListPromptsResponse struct {
Prompts []Prompt `json:"prompts"`
NextCursor string `json:"nextCursor,omitempty"`
}
ListPromptsResponse represents the response for prompts/list
type ListResourceTemplatesRequest ¶
type ListResourceTemplatesRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ListResourceTemplatesRequest represents a request to list resource templates
type ListResourceTemplatesResponse ¶
type ListResourceTemplatesResponse struct {
ResourceTemplates []ResourceTemplate `json:"resourceTemplates"`
NextCursor string `json:"nextCursor,omitempty"`
}
ListResourceTemplatesResponse represents the response for resources/templates/list
type ListResourcesRequest ¶
type ListResourcesRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ListResourcesRequest represents a request to list available resources
type ListResourcesResponse ¶
type ListResourcesResponse struct {
Resources []Resource `json:"resources"`
NextCursor string `json:"nextCursor,omitempty"`
}
ListResourcesResponse represents the response for resources/list
type ListRootsRequest ¶
type ListRootsRequest struct{}
ListRootsRequest represents a request to list root directories
type ListRootsResponse ¶
type ListRootsResponse struct {
Roots []Root `json:"roots"`
}
ListRootsResponse represents the response for roots/list
type LogNotification ¶
type LogNotification struct {
Level string `json:"level"`
Logger string `json:"logger,omitempty"`
Data interface{} `json:"data"`
}
LogNotification represents a log message from the server
type ModelHint ¶
type ModelHint struct {
Name string `json:"name,omitempty"`
}
ModelHint represents hints for model selection
type ModelPreferences ¶
type ModelPreferences struct {
Hints []ModelHint `json:"hints,omitempty"`
CostPriority float64 `json:"costPriority,omitempty"`
SpeedPriority float64 `json:"speedPriority,omitempty"`
IntelligencePriority float64 `json:"intelligencePriority,omitempty"`
}
ModelPreferences represents preferences for model selection
type ProgressNotification ¶
type ProgressNotification struct {
ProgressToken string `json:"progressToken"`
Progress float64 `json:"progress"`
Total float64 `json:"total,omitempty"`
}
ProgressNotification represents a progress update for a long-running request
type Prompt ¶
type Prompt struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Arguments []PromptArgument `json:"arguments,omitempty"`
}
Prompt represents a prompt or prompt template
type PromptArgument ¶
type PromptArgument struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
PromptArgument represents an argument for a prompt
type PromptListChangedNotification ¶
type PromptListChangedNotification struct{}
PromptListChangedNotification represents a notification that the prompt list has changed
type PromptMessage ¶
PromptMessage represents a message in a prompt
type ReadResourceRequest ¶
type ReadResourceRequest struct {
URI string `json:"uri"`
}
ReadResourceRequest represents a request to read a resource
type ReadResourceResponse ¶
type ReadResourceResponse struct {
Contents []ResourceContents `json:"contents"`
}
ReadResourceResponse represents the response for resources/read
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Size int64 `json:"size,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
}
Resource represents a known resource that the server can read
type ResourceContents ¶
type ResourceContents struct {
URI string `json:"uri"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"`
}
ResourceContents represents the contents of a specific resource
type ResourceListChangedNotification ¶
type ResourceListChangedNotification struct{}
ResourceListChangedNotification represents a notification that the resource list has changed
type ResourceTemplate ¶
type ResourceTemplate struct {
URITemplate string `json:"uriTemplate"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
}
ResourceTemplate represents a template for resources
type ResourceUpdatedNotification ¶
type ResourceUpdatedNotification struct {
URI string `json:"uri"`
}
ResourceUpdatedNotification represents a notification that a resource has been updated
type Role ¶
type Role string
Role represents the sender or recipient of messages and data in a conversation
type RootsListChangedNotification ¶
type RootsListChangedNotification struct{}
RootsListChangedNotification represents a notification that the roots list has changed
type SamplingMessage ¶
SamplingMessage represents a message for LLM sampling
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an MCP server that processes JSON-RPC requests
func NewServer ¶
func NewServer(opts ...ServerOption) (*Server, error)
NewServer creates a new MCP server instance
type ServerCapabilities ¶
type ServerCapabilities struct {
Experimental map[string]interface{} `json:"experimental,omitempty"`
Logging *struct{} `json:"logging,omitempty"`
Prompts *struct {
ListChanged bool `json:"listChanged"`
} `json:"prompts,omitempty"`
Resources *struct {
Subscribe bool `json:"subscribe"`
ListChanged bool `json:"listChanged"`
} `json:"resources,omitempty"`
Tools *struct {
ListChanged bool `json:"listChanged"`
} `json:"tools,omitempty"`
}
ServerCapabilities represents the server's supported capabilities
type ServerInfo ¶
ServerInfo represents information about an MCP implementation
type ServerOption ¶
ServerOption configures a Server
func WithAuth ¶
func WithAuth(auth string) ServerOption
WithAuth sets the authentication header for the server
func WithLogger ¶
func WithLogger(logger *slog.Logger) ServerOption
WithLogger sets the logger for the server
func WithServerInfo ¶
func WithServerInfo(name, version string) ServerOption
WithServerInfo sets server info
func WithSpecData ¶
func WithSpecData(data []byte) ServerOption
WithSpecData sets the OpenAPI spec from a byte slice
type SetLevelRequest ¶
type SetLevelRequest struct {
Level string `json:"level"`
}
SetLevelRequest represents a request to set logging level
type SubscribeRequest ¶
type SubscribeRequest struct {
URI string `json:"uri"`
}
SubscribeRequest represents a request to subscribe to resource updates
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema InputSchema `json:"inputSchema"`
}
Tool represents a single tool in the tools/list response
type ToolCallRequest ¶
type ToolCallRequest struct {
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments,omitempty"`
}
ToolCallRequest represents a request to call a specific tool
type ToolCallResponse ¶
type ToolCallResponse struct {
Content []Content `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResponse represents the response from a tool call
type ToolsChangedNotification ¶
type ToolsChangedNotification struct{}
ToolsChangedNotification represents a notification that the tools list has changed
type ToolsListRequest ¶
type ToolsListRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ToolsListRequest represents a request to list available tools
type ToolsListResponse ¶
type ToolsListResponse struct {
Tools []Tool `json:"tools"`
NextCursor string `json:"nextCursor,omitempty"`
}
ToolsListResponse represents the response for the tools/list method
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport handles the communication between stdin/stdout and the MCP server
func NewStdioTransport ¶
NewStdioTransport creates a new stdio transport
type UnsubscribeRequest ¶
type UnsubscribeRequest struct {
URI string `json:"uri"`
}
UnsubscribeRequest represents a request to unsubscribe from resource updates