Documentation
¶
Overview ¶
Code generated from MCP schema. DO NOT EDIT.
Index ¶
- Variables
- type Annotations
- type AudioContent
- type BlobResourceContents
- type CallToolRequest
- type CallToolResult
- type CancelledNotification
- type ClientCapabilities
- type ClientNotification
- type ClientRequest
- type ClientResult
- type CompleteRequest
- type CompleteResult
- type CreateMessageRequest
- type CreateMessageResult
- type Cursor
- type EmbeddedResource
- type EmptyResult
- type GetPromptRequest
- type GetPromptResult
- type ImageContent
- type Implementation
- type InitializeRequest
- type InitializeResult
- type InitializedNotification
- type JSONRPCBatchRequest
- type JSONRPCBatchResponse
- type JSONRPCError
- type JSONRPCMessage
- type JSONRPCNotification
- type JSONRPCRequest
- type JSONRPCResponse
- type ListPromptsRequest
- type ListPromptsResult
- type ListResourceTemplatesRequest
- type ListResourceTemplatesResult
- type ListResourcesRequest
- type ListResourcesResult
- type ListRootsRequest
- type ListRootsResult
- type ListToolsRequest
- type ListToolsResult
- type LoggingLevel
- type LoggingMessageNotification
- type MCPClient
- func (mc *MCPClient) ConvertMCPToolsToChatCompletionTools(serverTools []Tool) []providers.ChatCompletionTool
- func (mc *MCPClient) ExecuteTool(ctx context.Context, request Request, serverURL string) (*CallToolResult, error)
- func (mc *MCPClient) GetAllChatCompletionTools() []providers.ChatCompletionTool
- func (mc *MCPClient) GetServerCapabilities() map[string]ServerCapabilities
- func (mc *MCPClient) GetServerTools(serverURL string) ([]Tool, error)
- func (mc *MCPClient) GetServers() []string
- func (mc *MCPClient) InitializeAll(ctx context.Context) error
- func (mc *MCPClient) IsInitialized() bool
- func (mc *MCPClient) NewClient(url string) *m.Client
- type MCPClientInterface
- type ModelHint
- type ModelPreferences
- type Notification
- type PaginatedRequest
- type PaginatedResult
- type PingRequest
- type ProgressNotification
- type ProgressToken
- type Prompt
- type PromptArgument
- type PromptListChangedNotification
- type PromptMessage
- type PromptReference
- type ReadResourceRequest
- type ReadResourceResult
- type Request
- type RequestId
- type Resource
- type ResourceContents
- type ResourceListChangedNotification
- type ResourceReference
- type ResourceTemplate
- type ResourceUpdatedNotification
- type Result
- type Role
- type Root
- type RootsListChangedNotification
- type SamplingMessage
- type ServerCapabilities
- type ServerNotification
- type ServerRequest
- type ServerResult
- type SetLevelRequest
- type SubscribeRequest
- type TextContent
- type TextResourceContents
- type Tool
- type ToolAnnotations
- type ToolListChangedNotification
- type UnsubscribeRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientNotInitialized is returned when a client method is called before initialization ErrClientNotInitialized = errors.New("mcp client not initialized") // ErrServerNotFound is returned when trying to use a server that doesn't exist ErrServerNotFound = errors.New("mcp server not found") // ErrNoServerURLs is returned when trying to initialize without any server URLs ErrNoServerURLs = errors.New("no mcp server urls provided") // ErrNoClientsInitialized is returned when no clients could be initialized ErrNoClientsInitialized = errors.New("no mcp clients could be initialized") )
Functions ¶
This section is empty.
Types ¶
type Annotations ¶
Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
type AudioContent ¶
type AudioContent struct { Annotations Annotations `json:"annotations"` Data string `json:"data"` Mimetype string `json:"mimeType"` Type string `json:"type"` }
Audio provided to or from an LLM.
type BlobResourceContents ¶
type CallToolRequest ¶
type CallToolRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Used by the client to invoke a tool provided by the server.
type CallToolResult ¶
type CallToolResult struct { Meta map[string]interface{} `json:"_meta"` Content []interface{} `json:"content"` Iserror bool `json:"isError"` Structuredcontent map[string]interface{} `json:"structuredContent"` }
The server's response to a tool call.
type CancelledNotification ¶
type CancelledNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
This notification indicates that the result will be unused, so any associated processing SHOULD cease.
A client MUST NOT attempt to cancel its `initialize` request.
type ClientCapabilities ¶
type ClientCapabilities struct { Experimental map[string]interface{} `json:"experimental"` Roots map[string]interface{} `json:"roots"` Sampling map[string]interface{} `json:"sampling"` }
Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
type ClientNotification ¶
type ClientNotification struct { }
type ClientRequest ¶
type ClientRequest struct { }
type ClientResult ¶
type ClientResult struct { }
type CompleteRequest ¶
type CompleteRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A request from the client to the server, to ask for completion options.
type CompleteResult ¶
type CompleteResult struct { Meta map[string]interface{} `json:"_meta"` Completion map[string]interface{} `json:"completion"` }
The server's response to a completion/complete request
type CreateMessageRequest ¶
type CreateMessageRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
type CreateMessageResult ¶
type CreateMessageResult struct { Meta map[string]interface{} `json:"_meta"` Content interface{} `json:"content"` Model string `json:"model"` Role Role `json:"role"` Stopreason string `json:"stopReason"` }
The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
type EmbeddedResource ¶
type EmbeddedResource struct { Annotations Annotations `json:"annotations"` Resource interface{} `json:"resource"` Type string `json:"type"` }
The contents of a resource, embedded into a prompt or tool call result.
It is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.
type EmptyResult ¶
type EmptyResult struct { }
type GetPromptRequest ¶
type GetPromptRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Used by the client to get a prompt provided by the server.
type GetPromptResult ¶
type GetPromptResult struct { Meta map[string]interface{} `json:"_meta"` Description string `json:"description"` Messages []PromptMessage `json:"messages"` }
The server's response to a prompts/get request from the client.
type ImageContent ¶
type ImageContent struct { Annotations Annotations `json:"annotations"` Data string `json:"data"` Mimetype string `json:"mimeType"` Type string `json:"type"` }
An image provided to or from an LLM.
type Implementation ¶
Describes the name and version of an MCP implementation.
type InitializeRequest ¶
type InitializeRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
This request is sent from the client to the server when it first connects, asking it to begin initialization.
type InitializeResult ¶
type InitializeResult struct { Meta map[string]interface{} `json:"_meta"` Capabilities ServerCapabilities `json:"capabilities"` Instructions string `json:"instructions"` Protocolversion string `json:"protocolVersion"` Serverinfo Implementation `json:"serverInfo"` }
After receiving an initialize request from the client, the server sends this response.
type InitializedNotification ¶
type InitializedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
This notification is sent from the client to the server after initialization has finished.
type JSONRPCBatchRequest ¶
type JSONRPCBatchRequest struct { }
A JSON-RPC batch request, as described in https://www.jsonrpc.org/specification#batch.
type JSONRPCBatchResponse ¶
type JSONRPCBatchResponse struct { }
A JSON-RPC batch response, as described in https://www.jsonrpc.org/specification#batch.
type JSONRPCError ¶
type JSONRPCError struct { Error map[string]interface{} `json:"error"` ID RequestId `json:"id"` JSONRPC string `json:"jsonrpc"` }
A response to a request that indicates an error occurred.
type JSONRPCMessage ¶
type JSONRPCMessage struct { }
Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
type JSONRPCNotification ¶
type JSONRPCNotification struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A notification which does not expect a response.
type JSONRPCRequest ¶
type JSONRPCRequest struct { ID RequestId `json:"id"` JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A request that expects a response.
type JSONRPCResponse ¶
type JSONRPCResponse struct { ID RequestId `json:"id"` JSONRPC string `json:"jsonrpc"` Result Result `json:"result"` }
A successful (non-error) response to a request.
type ListPromptsRequest ¶
type ListPromptsRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request a list of prompts and prompt templates the server has.
type ListPromptsResult ¶
type ListPromptsResult struct { Meta map[string]interface{} `json:"_meta"` Nextcursor string `json:"nextCursor"` Prompts []Prompt `json:"prompts"` }
The server's response to a prompts/list request from the client.
type ListResourceTemplatesRequest ¶
type ListResourceTemplatesRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request a list of resource templates the server has.
type ListResourceTemplatesResult ¶
type ListResourceTemplatesResult struct { Meta map[string]interface{} `json:"_meta"` Nextcursor string `json:"nextCursor"` Resourcetemplates []ResourceTemplate `json:"resourceTemplates"` }
The server's response to a resources/templates/list request from the client.
type ListResourcesRequest ¶
type ListResourcesRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request a list of resources the server has.
type ListResourcesResult ¶
type ListResourcesResult struct { Meta map[string]interface{} `json:"_meta"` Nextcursor string `json:"nextCursor"` Resources []Resource `json:"resources"` }
The server's response to a resources/list request from the client.
type ListRootsRequest ¶
type ListRootsRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the server to request a list of root URIs from the client. Roots allow servers to ask for specific directories or files to operate on. A common example for roots is providing a set of repositories or directories a server should operate on.
This request is typically used when the server needs to understand the file system structure or access specific locations that the client has permission to read from.
type ListRootsResult ¶
type ListRootsResult struct { Meta map[string]interface{} `json:"_meta"` Roots []Root `json:"roots"` }
The client's response to a roots/list request from the server. This result contains an array of Root objects, each representing a root directory or file that the server can operate on.
type ListToolsRequest ¶
type ListToolsRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request a list of tools the server has.
type ListToolsResult ¶
type ListToolsResult struct { Meta map[string]interface{} `json:"_meta"` Nextcursor string `json:"nextCursor"` Tools []Tool `json:"tools"` }
The server's response to a tools/list request from the client.
type LoggingLevel ¶
type LoggingLevel string
The severity of a log message.
These map to syslog message severities, as specified in RFC-5424: https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
const ( LoggingLevelAlert LoggingLevel = "alert" LoggingLevelCritical LoggingLevel = "critical" LoggingLevelDebug LoggingLevel = "debug" LoggingLevelEmergency LoggingLevel = "emergency" LoggingLevelError LoggingLevel = "error" LoggingLevelInfo LoggingLevel = "info" LoggingLevelNotice LoggingLevel = "notice" LoggingLevelWarning LoggingLevel = "warning" )
LoggingLevel enum values
type LoggingMessageNotification ¶
type LoggingMessageNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
type MCPClient ¶
type MCPClient struct { ServerURLs []string Clients map[string]*m.Client Logger logger.Logger Config config.Config ServerCapabilities map[string]ServerCapabilities ServerTools map[string][]Tool ChatCompletionTools []providers.ChatCompletionTool Initialized bool }
MCPClient provides methods to interact with MCP servers
func (*MCPClient) ConvertMCPToolsToChatCompletionTools ¶
func (mc *MCPClient) ConvertMCPToolsToChatCompletionTools(serverTools []Tool) []providers.ChatCompletionTool
ConvertMCPToolsToChatCompletionTools converts MCP server tools to chat completion tools
func (*MCPClient) ExecuteTool ¶
func (mc *MCPClient) ExecuteTool(ctx context.Context, request Request, serverURL string) (*CallToolResult, error)
ExecuteTool implements MCPClientInterface.
func (*MCPClient) GetAllChatCompletionTools ¶
func (mc *MCPClient) GetAllChatCompletionTools() []providers.ChatCompletionTool
GetAllChatCompletionTools returns all pre-converted chat completion tools from all servers
func (*MCPClient) GetServerCapabilities ¶
func (mc *MCPClient) GetServerCapabilities() map[string]ServerCapabilities
GetServerCapabilities implements MCPClientInterface.
func (*MCPClient) GetServerTools ¶
func (*MCPClient) GetServers ¶
func (*MCPClient) InitializeAll ¶
InitializeAll implements MCPClientInterface.
func (*MCPClient) IsInitialized ¶
IsInitialized implements MCPClientInterface.
type MCPClientInterface ¶
type MCPClientInterface interface { // InitializeAll establishes connection with MCP servers and performs handshake InitializeAll(ctx context.Context) error // IsInitialized returns whether the client has been successfully initialized IsInitialized() bool // ExecuteTool invokes a tool on the appropriate MCP server ExecuteTool(ctx context.Context, request Request, serverURL string) (*CallToolResult, error) // GetServerCapabilities returns the server capabilities map GetServerCapabilities() map[string]ServerCapabilities // GetServers returns the list of MCP server URLs GetServers() []string // GetServerTools returns the tools available on the specified server GetServerTools(serverURL string) ([]Tool, error) // GetAllChatCompletionTools returns all pre-converted chat completion tools from all servers GetAllChatCompletionTools() []providers.ChatCompletionTool // ConvertMCPToolsToChatCompletionTools converts MCP server tools to chat completion tools ConvertMCPToolsToChatCompletionTools([]Tool) []providers.ChatCompletionTool }
MCPClientInterface defines the interface for MCP client implementations
func NewMCPClient ¶
NewMCPClient is a variable holding the function to create a new MCP client
type ModelHint ¶
type ModelHint struct {
Name string `json:"name"`
}
Hints to use for model selection.
Keys not declared here are currently left unspecified by the spec and are up to the client to interpret.
type ModelPreferences ¶
type ModelPreferences struct { Costpriority float64 `json:"costPriority"` Hints []ModelHint `json:"hints"` Intelligencepriority float64 `json:"intelligencePriority"` Speedpriority float64 `json:"speedPriority"` }
The server's preferences for model selection, requested of the client during sampling.
Because LLMs can vary along multiple dimensions, choosing the "best" model is rarely straightforward. Different models excel in different areas—some are faster but less capable, others are more capable but more expensive, and so on. This interface allows servers to express their priorities across multiple dimensions to help clients make an appropriate selection for their use case.
These preferences are always advisory. The client MAY ignore them. It is also up to the client to decide how to interpret these preferences and how to balance them against other considerations.
type Notification ¶
type PaginatedRequest ¶
type PaginatedResult ¶
type PingRequest ¶
type PingRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
type ProgressNotification ¶
type ProgressNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
type ProgressToken ¶
type ProgressToken struct { }
A progress token, used to associate progress notifications with the original request.
type Prompt ¶
type Prompt struct { Arguments []PromptArgument `json:"arguments"` Description string `json:"description"` Name string `json:"name"` }
A prompt or prompt template that the server offers.
type PromptArgument ¶
type PromptArgument struct { Description string `json:"description"` Name string `json:"name"` Required bool `json:"required"` }
Describes an argument that a prompt can accept.
type PromptListChangedNotification ¶
type PromptListChangedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
type PromptMessage ¶
type PromptMessage struct { Content interface{} `json:"content"` Role Role `json:"role"` }
Describes a message returned as part of a prompt.
This is similar to `SamplingMessage`, but also supports the embedding of resources from the MCP server.
type PromptReference ¶
Identifies a prompt.
type ReadResourceRequest ¶
type ReadResourceRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to the server, to read a specific resource URI.
type ReadResourceResult ¶
type ReadResourceResult struct { Meta map[string]interface{} `json:"_meta"` Contents []interface{} `json:"contents"` }
The server's response to a resources/read request from the client.
type Resource ¶
type Resource struct { Annotations Annotations `json:"annotations"` Description string `json:"description"` Mimetype string `json:"mimeType"` Name string `json:"name"` Size int `json:"size"` URI string `json:"uri"` }
A known resource that the server is capable of reading.
type ResourceContents ¶
The contents of a specific resource or sub-resource.
type ResourceListChangedNotification ¶
type ResourceListChangedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
type ResourceReference ¶
A reference to a resource or resource template definition.
type ResourceTemplate ¶
type ResourceTemplate struct { Annotations Annotations `json:"annotations"` Description string `json:"description"` Mimetype string `json:"mimeType"` Name string `json:"name"` Uritemplate string `json:"uriTemplate"` }
A template description for resources available on the server.
type ResourceUpdatedNotification ¶
type ResourceUpdatedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
type RootsListChangedNotification ¶
type RootsListChangedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A notification from the client to the server, informing it that the list of roots has changed. This notification should be sent whenever the client adds, removes, or modifies any root. The server should then request an updated list of roots using the ListRootsRequest.
type SamplingMessage ¶
type SamplingMessage struct { Content interface{} `json:"content"` Role Role `json:"role"` }
Describes a message issued to or received from an LLM API.
type ServerCapabilities ¶
type ServerCapabilities struct { Completions map[string]interface{} `json:"completions"` Experimental map[string]interface{} `json:"experimental"` Logging map[string]interface{} `json:"logging"` Prompts map[string]interface{} `json:"prompts"` Resources map[string]interface{} `json:"resources"` Tools map[string]interface{} `json:"tools"` }
Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
type ServerNotification ¶
type ServerNotification struct { }
type ServerRequest ¶
type ServerRequest struct { }
type ServerResult ¶
type ServerResult struct { }
type SetLevelRequest ¶
type SetLevelRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
A request from the client to the server, to enable or adjust logging.
type SubscribeRequest ¶
type SubscribeRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
type TextContent ¶
type TextContent struct { Annotations Annotations `json:"annotations"` Text string `json:"text"` Type string `json:"type"` }
Text provided to or from an LLM.
type TextResourceContents ¶
type Tool ¶
type Tool struct { Annotations ToolAnnotations `json:"annotations"` Description string `json:"description"` Inputschema map[string]interface{} `json:"inputSchema"` Name string `json:"name"` Outputschema map[string]interface{} `json:"outputSchema"` }
Definition for a tool the client can call.
type ToolAnnotations ¶
type ToolAnnotations struct { Destructivehint bool `json:"destructiveHint"` Idempotenthint bool `json:"idempotentHint"` Openworldhint bool `json:"openWorldHint"` Readonlyhint bool `json:"readOnlyHint"` Title string `json:"title"` }
Additional properties describing a Tool to clients.
NOTE: all properties in ToolAnnotations are **hints**. They are not guaranteed to provide a faithful description of tool behavior (including descriptive properties like `title`).
Clients should never make tool use decisions based on ToolAnnotations received from untrusted servers.
type ToolListChangedNotification ¶
type ToolListChangedNotification struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
type UnsubscribeRequest ¶
type UnsubscribeRequest struct { Method string `json:"method"` Params map[string]interface{} `json:"params"` }
Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.