mcp_golang package - github.com/metoro-io/mcp-golang - Go Packages (original) (raw)

This section is empty.

This section is empty.

This section is empty.

type Annotations struct {

Audience [][Role](#Role) `json:"audience,omitempty" yaml:"audience,omitempty" mapstructure:"audience,omitempty"`


Priority *[float64](/builtin#float64) `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority,omitempty"`

}

type BlobResourceContents

type BlobResourceContents struct {

Blob [string](/builtin#string) `json:"blob" yaml:"blob" mapstructure:"blob"`


MimeType *[string](/builtin#string) `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"`


Uri [string](/builtin#string) `json:"uri" yaml:"uri" mapstructure:"uri"`

}

Client represents an MCP client that can connect to and interact with MCP servers

NewClient creates a new MCP client with the specified transport

NewClientWithInfo create a new client with info. This is required by anthorpic mcp tools

CallTool calls a specific tool on the server with the provided arguments

func (c *Client) GetCapabilities() *ServerCapabilities

GetCapabilities returns the server capabilities obtained during initialization

GetPrompt retrieves a specific prompt from the server

Initialize connects to the server and retrieves its capabilities

ListPrompts retrieves the list of available prompts from the server

ListResources retrieves the list of available resources from the server

ListTools retrieves the list of available tools from the server

Ping sends a ping request to the server to check connectivity

ReadResource reads a specific resource from the server

type ClientInfo struct { Name string json:"name" Version string json:"version" }

type Content

type Content struct { Type ContentType TextContent *TextContent ImageContent *ImageContent EmbeddedResource *EmbeddedResource Annotations *Annotations }

func NewBlobResourceContent

NewBlobResourceContent creates a new ToolResponse that is a blob of binary data. The given data is base64-encoded; the client will decode it. The client will render this as a blob; it will not be human-readable.

func NewImageContent

func NewImageContent(base64EncodedStringData string, mimeType string) *Content

NewImageContent creates a new ToolResponse that is an image. The given data is base64-encoded

func NewTextContent

func NewTextContent(content string) *Content

NewTextContent creates a new ToolResponse that is a simple text string. The client will render this as a single string.

func NewTextResourceContent

NewTextResourceContent creates a new ToolResponse that is an embedded resource of type "text". The given text is embedded in the response as a TextResourceContents, which contains the given MIME type and URI. The text is not base64-encoded.

func (Content) MarshalJSON

Custom JSON marshaling for ToolResponse Content

type ContentType

const (

ContentTypeText             [ContentType](#ContentType) = "text"
ContentTypeImage            [ContentType](#ContentType) = "image"
ContentTypeEmbeddedResource [ContentType](#ContentType) = "resource"

)

type EmbeddedResource struct { EmbeddedResourceType embeddedResourceType TextResourceContents *TextResourceContents BlobResourceContents *BlobResourceContents }

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.

Custom JSON marshaling for EmbeddedResource

Custom JSON unmarshaling for EmbeddedResource

type ImageContent

type ImageContent struct {

Data [string](/builtin#string) `json:"data" yaml:"data" mapstructure:"data"`


MimeType [string](/builtin#string) `json:"mimeType" yaml:"mimeType" mapstructure:"mimeType"`

}

An image provided to or from an LLM.

type InitializeResponse struct {

Meta initializeResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`


Capabilities [ServerCapabilities](#ServerCapabilities) `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"`


Instructions *[string](/builtin#string) `json:"instructions,omitempty" yaml:"instructions,omitempty" mapstructure:"instructions,omitempty"`


ProtocolVersion [string](/builtin#string) `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"`


ServerInfo implementation `json:"serverInfo" yaml:"serverInfo" mapstructure:"serverInfo"`

}

After receiving an initialize request from the client, the server sends this response.

UnmarshalJSON implements json.Unmarshaler.

type ListPromptsResponse struct {

Prompts []*[PromptSchema](#PromptSchema) `json:"prompts" yaml:"prompts" mapstructure:"prompts"`

NextCursor *[string](/builtin#string) `json:"nextCursor,omitempty" yaml:"nextCursor,omitempty" mapstructure:"nextCursor,omitempty"`

}

The server's response to a prompts/list request from the client.

type ListResourceTemplatesResponse struct {

Templates []*[ResourceTemplateSchema](#ResourceTemplateSchema) `json:"resourceTemplates" yaml:"resourceTemplates" mapstructure:"resourceTemplates"`

NextCursor *[string](/builtin#string) `json:"nextCursor,omitempty" yaml:"nextCursor,omitempty" mapstructure:"nextCursor,omitempty"`

}

The server's response to a resources/templates/list request from the client.

type ListResourcesResponse struct {

Resources []*[ResourceSchema](#ResourceSchema) `json:"resources" yaml:"resources" mapstructure:"resources"`

NextCursor *[string](/builtin#string) `json:"nextCursor,omitempty" yaml:"nextCursor,omitempty" mapstructure:"nextCursor,omitempty"`

}

The server's response to a resources/list request from the client.

type PromptMessage struct { Content *Content json:"content" yaml:"content" mapstructure:"content" Role Role json:"role" yaml:"role" mapstructure:"role" }

func NewPromptMessage(content *Content, role Role) *PromptMessage

type PromptResponse struct {

Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


Messages []*[PromptMessage](#PromptMessage) `json:"messages" yaml:"messages" mapstructure:"messages"`

}

The server's response to a prompts/get request from the client.

func NewPromptResponse(description string, messages ...*PromptMessage) *PromptResponse

type PromptSchema struct {

Arguments [][PromptSchemaArgument](#PromptSchemaArgument) `json:"arguments,omitempty" yaml:"arguments,omitempty" mapstructure:"arguments,omitempty"`


Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


Name [string](/builtin#string) `json:"name" yaml:"name" mapstructure:"name"`

}

A PromptSchema or prompt template that the server offers.

type PromptSchemaArgument struct {

Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


Name [string](/builtin#string) `json:"name" yaml:"name" mapstructure:"name"`


Required *[bool](/builtin#bool) `json:"required,omitempty" yaml:"required,omitempty" mapstructure:"required,omitempty"`

}

type ResourceResponse struct { Contents []*EmbeddedResource json:"contents" }

func NewResourceResponse(contents ...*EmbeddedResource) *ResourceResponse

type ResourceSchema struct {

Annotations *[Annotations](#Annotations) `json:"annotations,omitempty" yaml:"annotations,omitempty" mapstructure:"annotations,omitempty"`


Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


MimeType *[string](/builtin#string) `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"`


Name [string](/builtin#string) `json:"name" yaml:"name" mapstructure:"name"`


Uri [string](/builtin#string) `json:"uri" yaml:"uri" mapstructure:"uri"`

}

A known resource that the server is capable of reading.

type ResourceTemplateSchema struct {

Annotations *[Annotations](#Annotations) `json:"annotations,omitempty" yaml:"annotations,omitempty" mapstructure:"annotations,omitempty"`


Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


MimeType *[string](/builtin#string) `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"`


Name [string](/builtin#string) `json:"name" yaml:"name" mapstructure:"name"`


UriTemplate [string](/builtin#string) `json:"uriTemplate" yaml:"uriTemplate" mapstructure:"uriTemplate"`

}

A resource template that defines a pattern for dynamic resources.

const RoleAssistant Role = "assistant"

const RoleUser Role = "user"

func (s *Server) CheckResourceTemplateRegistered(uriTemplate string) bool

func (s *Server) DeregisterResourceTemplate(uriTemplate string) error

RegisterTool registers a new tool with the server

type ServerCapabilities struct {

Experimental [ServerCapabilitiesExperimental](#ServerCapabilitiesExperimental) `json:"experimental,omitempty" yaml:"experimental,omitempty" mapstructure:"experimental,omitempty"`


Logging [ServerCapabilitiesLogging](#ServerCapabilitiesLogging) `json:"logging,omitempty" yaml:"logging,omitempty" mapstructure:"logging,omitempty"`


Prompts *[ServerCapabilitiesPrompts](#ServerCapabilitiesPrompts) `json:"prompts,omitempty" yaml:"prompts,omitempty" mapstructure:"prompts,omitempty"`


Resources *[ServerCapabilitiesResources](#ServerCapabilitiesResources) `json:"resources,omitempty" yaml:"resources,omitempty" mapstructure:"resources,omitempty"`


Tools *[ServerCapabilitiesTools](#ServerCapabilitiesTools) `json:"tools,omitempty" yaml:"tools,omitempty" mapstructure:"tools,omitempty"`

}

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 ServerCapabilitiesExperimental map[string]map[string]interface{}

Experimental, non-standard capabilities that the server supports.

type ServerCapabilitiesLogging map[string]interface{}

Present if the server supports sending log messages to the client.

type ServerCapabilitiesPrompts struct {

ListChanged *[bool](/builtin#bool) `json:"listChanged,omitempty" yaml:"listChanged,omitempty" mapstructure:"listChanged,omitempty"`

}

Present if the server offers any prompt templates.

type ServerCapabilitiesResources struct {

ListChanged *[bool](/builtin#bool) `json:"listChanged,omitempty" yaml:"listChanged,omitempty" mapstructure:"listChanged,omitempty"`


Subscribe *[bool](/builtin#bool) `json:"subscribe,omitempty" yaml:"subscribe,omitempty" mapstructure:"subscribe,omitempty"`

}

Present if the server offers any resources to read.

type ServerCapabilitiesTools struct {

ListChanged *[bool](/builtin#bool) `json:"listChanged,omitempty" yaml:"listChanged,omitempty" mapstructure:"listChanged,omitempty"`

}

Present if the server offers any tools to call.

type ServerOptions func(*Server)

func WithInstructions(instructions string) ServerOptions

func WithPaginationLimit(limit int) ServerOptions

Beware: As of 2024-12-13, it looks like Claude does not support pagination yet

type TextContent

type TextContent struct {

Text [string](/builtin#string) `json:"text" yaml:"text" mapstructure:"text"`

}

Text provided to or from an LLM.

type TextResourceContents

type TextResourceContents struct {

MimeType *[string](/builtin#string) `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"`


Text [string](/builtin#string) `json:"text" yaml:"text" mapstructure:"text"`


Uri [string](/builtin#string) `json:"uri" yaml:"uri" mapstructure:"uri"`

}

type ToolResponse struct { Content []*Content json:"content" yaml:"content" mapstructure:"content" }

This is a union type of all the different ToolResponse that can be sent back to the client. We allow creation through constructors only to make sure that the ToolResponse is valid.

func NewToolResponse(content ...*Content) *ToolResponse

type ToolRetType struct {

Description *[string](/builtin#string) `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`


InputSchema interface{} `json:"inputSchema" yaml:"inputSchema" mapstructure:"inputSchema"`


Name [string](/builtin#string) `json:"name" yaml:"name" mapstructure:"name"`

}

Definition for a tool the client can call.

type ToolsResponse struct { Tools []ToolRetType json:"tools" yaml:"tools" mapstructure:"tools" NextCursor *string json:"nextCursor,omitempty" yaml:"nextCursor,omitempty" mapstructure:"nextCursor,omitempty" }