Versions in this module Expand all Collapse all v0 v0.2.0 Jul 11, 2025 Changes in this version + func AddTool[In, Out any](s *Server, t *Tool, h ToolHandlerFor[In, Out]) + type Implementation struct + Name string + Title string + Version string type Server + func (s *Server) AddPrompt(p *Prompt, h PromptHandler) + func (s *Server) AddResource(r *Resource, h ResourceHandler) + func (s *Server) AddResourceTemplate(t *ResourceTemplate, h ResourceHandler) + func (s *Server) AddTool(t *Tool, h ToolHandler) v0.1.0 Jul 1, 2025 Changes in this version + const CodeResourceNotFound + const CodeUnsupportedMethod + const DefaultPageSize + const LevelAlert + const LevelCritical + const LevelDebug + const LevelEmergency + const LevelError + const LevelInfo + const LevelNotice + const LevelWarning + var ErrConnectionClosed = errors.New("connection closed") + func NewInMemoryTransports() (*InMemoryTransport, *InMemoryTransport) + func ResourceNotFoundError(uri string) error + type Annotations struct + Audience []Role + LastModified string + Priority float64 + type AudioContent struct + Annotations *Annotations + Data []byte + MIMEType string + Meta Meta + func (c AudioContent) MarshalJSON() ([]byte, error) + type CallToolParams = CallToolParamsFor[any] + type CallToolParamsFor struct + Arguments In + Name string + func (x *CallToolParamsFor[Out]) GetProgressToken() any + func (x *CallToolParamsFor[Out]) SetProgressToken(t any) + type CallToolResult = CallToolResultFor[any] + type CallToolResultFor struct + Content []Content + IsError bool + StructuredContent Out + func (x *CallToolResultFor[Out]) UnmarshalJSON(data []byte) error + type CancelledParams struct + Reason string + RequestID any + func (x *CancelledParams) GetProgressToken() any + func (x *CancelledParams) SetProgressToken(t any) + type Client struct + func NewClient(name, version string, opts *ClientOptions) *Client + func (c *Client) AddReceivingMiddleware(middleware ...Middleware[*ClientSession]) + func (c *Client) AddRoots(roots ...*Root) + func (c *Client) AddSendingMiddleware(middleware ...Middleware[*ClientSession]) + func (c *Client) Connect(ctx context.Context, t Transport) (cs *ClientSession, err error) + func (c *Client) RemoveRoots(uris ...string) + type ClientCapabilities struct + Elicitation *ElicitationCapabilities + Experimental map[string]struct{} + Roots struct{ ... } + Sampling *SamplingCapabilities + type ClientOptions struct + CreateMessageHandler func(context.Context, *ClientSession, *CreateMessageParams) (*CreateMessageResult, error) + KeepAlive time.Duration + LoggingMessageHandler func(context.Context, *ClientSession, *LoggingMessageParams) + ProgressNotificationHandler func(context.Context, *ClientSession, *ProgressNotificationParams) + PromptListChangedHandler func(context.Context, *ClientSession, *PromptListChangedParams) + ResourceListChangedHandler func(context.Context, *ClientSession, *ResourceListChangedParams) + ToolListChangedHandler func(context.Context, *ClientSession, *ToolListChangedParams) + type ClientSession struct + func (cs *ClientSession) CallTool(ctx context.Context, params *CallToolParams) (*CallToolResult, error) + func (cs *ClientSession) Close() error + func (cs *ClientSession) Complete(ctx context.Context, params *CompleteParams) (*CompleteResult, error) + func (cs *ClientSession) GetPrompt(ctx context.Context, params *GetPromptParams) (*GetPromptResult, error) + func (cs *ClientSession) ID() string + func (cs *ClientSession) ListPrompts(ctx context.Context, params *ListPromptsParams) (*ListPromptsResult, error) + func (cs *ClientSession) ListResourceTemplates(ctx context.Context, params *ListResourceTemplatesParams) (*ListResourceTemplatesResult, error) + func (cs *ClientSession) ListResources(ctx context.Context, params *ListResourcesParams) (*ListResourcesResult, error) + func (cs *ClientSession) ListTools(ctx context.Context, params *ListToolsParams) (*ListToolsResult, error) + func (cs *ClientSession) NotifyProgress(ctx context.Context, params *ProgressNotificationParams) error + func (cs *ClientSession) Ping(ctx context.Context, params *PingParams) error + func (cs *ClientSession) Prompts(ctx context.Context, params *ListPromptsParams) iter.Seq2[*Prompt, error] + func (cs *ClientSession) ReadResource(ctx context.Context, params *ReadResourceParams) (*ReadResourceResult, error) + func (cs *ClientSession) ResourceTemplates(ctx context.Context, params *ListResourceTemplatesParams) iter.Seq2[*ResourceTemplate, error] + func (cs *ClientSession) Resources(ctx context.Context, params *ListResourcesParams) iter.Seq2[*Resource, error] + func (cs *ClientSession) SetLevel(ctx context.Context, params *SetLevelParams) error + func (cs *ClientSession) Tools(ctx context.Context, params *ListToolsParams) iter.Seq2[*Tool, error] + func (cs *ClientSession) Wait() error + type CommandTransport struct + func NewCommandTransport(cmd *exec.Cmd) *CommandTransport + func (t *CommandTransport) Connect(ctx context.Context) (Connection, error) + type CompleteContext struct + Arguments map[string]string + type CompleteParams struct + Argument CompleteParamsArgument + Context *CompleteContext + Ref *CompleteReference + type CompleteParamsArgument struct + Name string + Value string + type CompleteReference struct + Name string + Type string + URI string + func (r *CompleteReference) MarshalJSON() ([]byte, error) + func (r *CompleteReference) UnmarshalJSON(data []byte) error + type CompleteResult struct + Completion CompletionResultDetails + type CompletionResultDetails struct + HasMore bool + Total int + Values []string + type Connection interface + Close func() error + Read func(context.Context) (JSONRPCMessage, error) + SessionID func() string + Write func(context.Context, JSONRPCMessage) error + type Content interface + MarshalJSON func() ([]byte, error) + type CreateMessageParams struct + IncludeContext string + MaxTokens int64 + Messages []*SamplingMessage + Metadata struct{} + ModelPreferences *ModelPreferences + StopSequences []string + SystemPrompt string + Temperature float64 + func (x *CreateMessageParams) GetProgressToken() any + func (x *CreateMessageParams) SetProgressToken(t any) + type CreateMessageResult struct + Content Content + Model string + Role Role + StopReason string + type ElicitationCapabilities struct + type EmbeddedResource struct + Annotations *Annotations + Meta Meta + Resource *ResourceContents + func (c *EmbeddedResource) MarshalJSON() ([]byte, error) + type GetPromptParams struct + Arguments map[string]string + Name string + func (x *GetPromptParams) GetProgressToken() any + func (x *GetPromptParams) SetProgressToken(t any) + type GetPromptResult struct + Description string + Messages []*PromptMessage + type ImageContent struct + Annotations *Annotations + Data []byte + MIMEType string + Meta Meta + func (c *ImageContent) MarshalJSON() ([]byte, error) + type InMemoryTransport struct + func (t *InMemoryTransport) Connect(context.Context) (Connection, error) + type InitializeParams struct + Capabilities *ClientCapabilities + ClientInfo *implementation + ProtocolVersion string + func (x *InitializeParams) GetProgressToken() any + func (x *InitializeParams) SetProgressToken(t any) + type InitializeResult struct + Capabilities *serverCapabilities + Instructions string + ProtocolVersion string + ServerInfo *implementation + type InitializedParams struct + func (x *InitializedParams) GetProgressToken() any + func (x *InitializedParams) SetProgressToken(t any) + type JSONRPCID = jsonrpc2.ID + type JSONRPCMessage = jsonrpc2.Message + type JSONRPCRequest = jsonrpc2.Request + type JSONRPCResponse = jsonrpc2.Response + type ListPromptsParams struct + Cursor string + func (x *ListPromptsParams) GetProgressToken() any + func (x *ListPromptsParams) SetProgressToken(t any) + type ListPromptsResult struct + NextCursor string + Prompts []*Prompt + type ListResourceTemplatesParams struct + Cursor string + func (x *ListResourceTemplatesParams) GetProgressToken() any + func (x *ListResourceTemplatesParams) SetProgressToken(t any) + type ListResourceTemplatesResult struct + NextCursor string + ResourceTemplates []*ResourceTemplate + type ListResourcesParams struct + Cursor string + func (x *ListResourcesParams) GetProgressToken() any + func (x *ListResourcesParams) SetProgressToken(t any) + type ListResourcesResult struct + NextCursor string + Resources []*Resource + type ListRootsParams struct + func (x *ListRootsParams) GetProgressToken() any + func (x *ListRootsParams) SetProgressToken(t any) + type ListRootsResult struct + Roots []*Root + type ListToolsParams struct + Cursor string + func (x *ListToolsParams) GetProgressToken() any + func (x *ListToolsParams) SetProgressToken(t any) + type ListToolsResult struct + NextCursor string + Tools []*Tool + type LoggingHandler struct + func NewLoggingHandler(ss *ServerSession, opts *LoggingHandlerOptions) *LoggingHandler + func (h *LoggingHandler) Enabled(ctx context.Context, level slog.Level) bool + func (h *LoggingHandler) Handle(ctx context.Context, r slog.Record) error + func (h *LoggingHandler) WithAttrs(as []slog.Attr) slog.Handler + func (h *LoggingHandler) WithGroup(name string) slog.Handler + type LoggingHandlerOptions struct + LoggerName string + MinInterval time.Duration + type LoggingLevel string + type LoggingMessageParams struct + Data any + Level LoggingLevel + Logger string + func (x *LoggingMessageParams) GetProgressToken() any + func (x *LoggingMessageParams) SetProgressToken(t any) + type LoggingTransport struct + func NewLoggingTransport(delegate Transport, w io.Writer) *LoggingTransport + func (t *LoggingTransport) Connect(ctx context.Context) (Connection, error) + type Meta map[string]any + func (m *Meta) SetMeta(x map[string]any) + func (m Meta) GetMeta() map[string]any + type MethodHandler func(ctx context.Context, _ S, method string, params Params) (result Result, err error) + type Middleware func(MethodHandler[S]) MethodHandler[S] + type ModelHint struct + Name string + type ModelPreferences struct + CostPriority float64 + Hints []*ModelHint + IntelligencePriority float64 + SpeedPriority float64 + type Params interface + GetMeta func() map[string]any + SetMeta func(map[string]any) + type PingParams struct + func (x *PingParams) GetProgressToken() any + func (x *PingParams) SetProgressToken(t any) + type ProgressNotificationParams struct + Message string + Progress float64 + ProgressToken any + Total float64 + type Prompt struct + Arguments []*PromptArgument + Description string + Name string + Title string + type PromptArgument struct + Description string + Name string + Required bool + Title string + type PromptHandler func(context.Context, *ServerSession, *GetPromptParams) (*GetPromptResult, error) + type PromptListChangedParams struct + func (x *PromptListChangedParams) GetProgressToken() any + func (x *PromptListChangedParams) SetProgressToken(t any) + type PromptMessage struct + Content Content + Role Role + func (m *PromptMessage) UnmarshalJSON(data []byte) error + type ReadResourceParams struct + URI string + func (x *ReadResourceParams) GetProgressToken() any + func (x *ReadResourceParams) SetProgressToken(t any) + type ReadResourceResult struct + Contents []*ResourceContents + type RequestParams interface + GetProgressToken func() any + SetProgressToken func(any) + type Resource struct + Annotations *Annotations + Description string + MIMEType string + Name string + Size int64 + Title string + URI string + type ResourceContents struct + Blob []byte + MIMEType string + Meta Meta + Text string + URI string + func (r ResourceContents) MarshalJSON() ([]byte, error) + type ResourceHandler func(context.Context, *ServerSession, *ReadResourceParams) (*ReadResourceResult, error) + type ResourceLink struct + Annotations *Annotations + Description string + MIMEType string + Meta Meta + Name string + Size *int64 + Title string + URI string + func (c *ResourceLink) MarshalJSON() ([]byte, error) + type ResourceListChangedParams struct + func (x *ResourceListChangedParams) GetProgressToken() any + func (x *ResourceListChangedParams) SetProgressToken(t any) + type ResourceTemplate struct + Annotations *Annotations + Description string + MIMEType string + Name string + Title string + URITemplate string + type Result interface + GetMeta func() map[string]any + SetMeta func(map[string]any) + type Role string + type Root struct + Name string + URI string + type RootsListChangedParams struct + func (x *RootsListChangedParams) GetProgressToken() any + func (x *RootsListChangedParams) SetProgressToken(t any) + type SSEClientTransport struct + func NewSSEClientTransport(baseURL string, opts *SSEClientTransportOptions) *SSEClientTransport + func (c *SSEClientTransport) Connect(ctx context.Context) (Connection, error) + type SSEClientTransportOptions struct + HTTPClient *http.Client + type SSEHandler struct + func NewSSEHandler(getServer func(request *http.Request) *Server) *SSEHandler + func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) + type SSEServerTransport struct + func NewSSEServerTransport(endpoint string, w http.ResponseWriter) *SSEServerTransport + func (t *SSEServerTransport) Connect(context.Context) (Connection, error) + func (t *SSEServerTransport) ServeHTTP(w http.ResponseWriter, req *http.Request) + type SamplingCapabilities struct + type SamplingMessage struct + Content Content + Role Role + func (m *SamplingMessage) UnmarshalJSON(data []byte) error + type SchemaOption interface + func Description(desc string) SchemaOption + func Enum(values ...any) SchemaOption + func Property(name string, opts ...SchemaOption) SchemaOption + func Required(v bool) SchemaOption + func Schema(schema *jsonschema.Schema) SchemaOption + type Server struct + func NewServer(name, version string, opts *ServerOptions) *Server + func (s *Server) AddPrompts(prompts ...*ServerPrompt) + func (s *Server) AddReceivingMiddleware(middleware ...Middleware[*ServerSession]) + func (s *Server) AddResourceTemplates(templates ...*ServerResourceTemplate) + func (s *Server) AddResources(resources ...*ServerResource) + func (s *Server) AddSendingMiddleware(middleware ...Middleware[*ServerSession]) + func (s *Server) AddTools(tools ...*ServerTool) + func (s *Server) Connect(ctx context.Context, t Transport) (*ServerSession, error) + func (s *Server) RemovePrompts(names ...string) + func (s *Server) RemoveResourceTemplates(uriTemplates ...string) + func (s *Server) RemoveResources(uris ...string) + func (s *Server) RemoveTools(names ...string) + func (s *Server) Run(ctx context.Context, t Transport) error + func (s *Server) Sessions() iter.Seq[*ServerSession] + type ServerOptions struct + CompletionHandler func(context.Context, *ServerSession, *CompleteParams) (*CompleteResult, error) + InitializedHandler func(context.Context, *ServerSession, *InitializedParams) + Instructions string + KeepAlive time.Duration + PageSize int + ProgressNotificationHandler func(context.Context, *ServerSession, *ProgressNotificationParams) + RootsListChangedHandler func(context.Context, *ServerSession, *RootsListChangedParams) + type ServerPrompt struct + Handler PromptHandler + Prompt *Prompt + type ServerResource struct + Handler ResourceHandler + Resource *Resource + type ServerResourceTemplate struct + Handler ResourceHandler + ResourceTemplate *ResourceTemplate + func (sr *ServerResourceTemplate) Matches(uri string) bool + type ServerSession struct + func (ss *ServerSession) Close() error + func (ss *ServerSession) CreateMessage(ctx context.Context, params *CreateMessageParams) (*CreateMessageResult, error) + func (ss *ServerSession) ID() string + func (ss *ServerSession) ListRoots(ctx context.Context, params *ListRootsParams) (*ListRootsResult, error) + func (ss *ServerSession) Log(ctx context.Context, params *LoggingMessageParams) error + func (ss *ServerSession) NotifyProgress(ctx context.Context, params *ProgressNotificationParams) error + func (ss *ServerSession) Ping(ctx context.Context, params *PingParams) error + func (ss *ServerSession) Wait() error + type ServerTool struct + Handler ToolHandler + Tool *Tool + func NewServerTool[In, Out any](name, description string, handler ToolHandlerFor[In, Out], opts ...ToolOption) *ServerTool + type Session interface + ID func() string + type SetLevelParams struct + Level LoggingLevel + func (x *SetLevelParams) GetProgressToken() any + func (x *SetLevelParams) SetProgressToken(t any) + type StdioTransport struct + func NewStdioTransport() *StdioTransport + func (t *StdioTransport) Connect(context.Context) (Connection, error) + type StreamableClientTransport struct + func NewStreamableClientTransport(url string, opts *StreamableClientTransportOptions) *StreamableClientTransport + func (t *StreamableClientTransport) Connect(ctx context.Context) (Connection, error) + type StreamableClientTransportOptions struct + HTTPClient *http.Client + type StreamableHTTPHandler struct + func NewStreamableHTTPHandler(getServer func(*http.Request) *Server, opts *StreamableHTTPOptions) *StreamableHTTPHandler + func (h *StreamableHTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) + type StreamableHTTPOptions struct + type StreamableServerTransport struct + func NewStreamableServerTransport(sessionID string) *StreamableServerTransport + func (s *StreamableServerTransport) Connect(context.Context) (Connection, error) + func (t *StreamableServerTransport) Close() error + func (t *StreamableServerTransport) Read(ctx context.Context) (JSONRPCMessage, error) + func (t *StreamableServerTransport) ServeHTTP(w http.ResponseWriter, req *http.Request) + func (t *StreamableServerTransport) SessionID() string + func (t *StreamableServerTransport) Write(ctx context.Context, msg JSONRPCMessage) error + type TextContent struct + Annotations *Annotations + Meta Meta + Text string + func (c *TextContent) MarshalJSON() ([]byte, error) + type Tool struct + Annotations *ToolAnnotations + Description string + InputSchema *jsonschema.Schema + Name string + OutputSchema *jsonschema.Schema + Title string + type ToolAnnotations struct + DestructiveHint *bool + IdempotentHint bool + OpenWorldHint *bool + ReadOnlyHint bool + Title string + type ToolHandler func(context.Context, *ServerSession, *CallToolParamsFor[map[string]any]) (*CallToolResult, error) + type ToolHandlerFor func(context.Context, *ServerSession, *CallToolParamsFor[In]) (*CallToolResultFor[Out], error) + type ToolListChangedParams struct + func (x *ToolListChangedParams) GetProgressToken() any + func (x *ToolListChangedParams) SetProgressToken(t any) + type ToolOption interface + func Input(opts ...SchemaOption) ToolOption + type Transport interface + Connect func(ctx context.Context) (Connection, error)