Versions in this module Expand all Collapse all v0 v0.1.0 May 19, 2026 Changes in this version + const DefaultMaxHandlersPerMethod + const DefaultMaxNotificationMethods + const DefaultMaxSessionTools + const DefaultMaxSessions + const DefaultStreamBufferSize + const ErrCodeInternalError + const ErrCodeInvalidParams + const ErrCodeInvalidRequest + const ErrCodeMethodNotFound + const ErrCodeParseError + const ErrCodeTenantRequired + const ErrCodeUnauthorized + const MethodCancelled + const MethodCompletionComplete + const MethodElicitationCreate + const MethodInitialize + const MethodInitialized + const MethodLoggingMessage + const MethodLoggingSetLevel + const MethodPing + const MethodProgress + const MethodPromptsGet + const MethodPromptsList + const MethodPromptsListChanged + const MethodResourcesList + const MethodResourcesListChanged + const MethodResourcesRead + const MethodResourcesSubscribe + const MethodResourcesTemplatesList + const MethodResourcesUnsubscribe + const MethodResourcesUpdated + const MethodRootsList + const MethodRootsListChanged + const MethodSamplingCreateMessage + const MethodTasksCancel + const MethodTasksGet + const MethodTasksList + const MethodTasksResult + const MethodToolsCall + const MethodToolsList + const MethodToolsListChanged + const ProtocolVersion + const RefTypePrompt + const RefTypeResource + var ErrStreamClosed = errors.New("stream closed") + func BoolPtr(v bool) *bool + func DefaultSupportedVersions() []string + func GenerateSchema(t reflect.Type) map[string]any + func IsResponse(data []byte) bool + func IsSimulatedFromCtx(ctx context.Context) bool + func MetaFromCtx(ctx context.Context) map[string]any + func ReportProgress(ctx context.Context, progress, total float64) + func RequestID(ctx context.Context) any + func RolesFromCtx(ctx context.Context) []string + func SetResponseMeta(ctx context.Context, key string, value any) + func SimDepthFromCtx(ctx context.Context) int + func SkipValidationFromCtx(ctx context.Context) bool + func SubscriberIDFromCtx(ctx context.Context) string + func TenantIDFromCtx(ctx context.Context) string + func ToolName(ctx context.Context) string + func ToolRolesFromCtx(ctx context.Context) []string + func ToolSchemaFromCtx(ctx context.Context) any + func WithAuthInfo(ctx context.Context, info AuthInfo) context.Context + func WithMeta(ctx context.Context, meta map[string]any) context.Context + func WithNotificationSender(ctx context.Context, fn NotificationSender) context.Context + func WithRequestID(ctx context.Context, id any) context.Context + func WithRequestSender(ctx context.Context, fn RequestSender) context.Context + func WithRolesCtx(ctx context.Context, roles []string) context.Context + func WithSimDepth(ctx context.Context, depth int) context.Context + func WithSimulated(ctx context.Context) context.Context + func WithSubscriberID(ctx context.Context, id string) context.Context + func WithTenantID(ctx context.Context, id string) context.Context + func WithToolName(ctx context.Context, name string) context.Context + type AudioContent struct + Data []byte + MimeType string + func NewAudioContent(mimeType string, data []byte) AudioContent + func (c AudioContent) MarshalJSON() ([]byte, error) + type AuthChecker func(ctx context.Context) error + type AuthInfo struct + Meta map[string]any + Roles []string + Subject string + func AuthInfoFromCtx(ctx context.Context) *AuthInfo + type CallToolParams struct + Arguments json.RawMessage + Meta map[string]any + Name string + Task *TaskMetadata + type CallToolResult struct + Content []Content + IsError bool + Meta map[string]any + StructuredContent any + func NewAudioResult(mimeType string, data []byte) *CallToolResult + func NewEmbeddedResourceResult(rc ResourceContent) *CallToolResult + func NewErrorResult(text string) *CallToolResult + func NewImageResult(mimeType string, data []byte) *CallToolResult + func NewTextResult(text string) *CallToolResult + func (r *CallToolResult) UnmarshalJSON(data []byte) error + type CancelledParams struct + Meta map[string]any + RequestID any + type ClientCaps struct + Elicitation *ElicitationCapability + Sampling *SamplingCapability + type CompleteHandler func(ctx context.Context, params CompleteRequest) (*CompletionResult, error) + type CompleteParams struct + Argument CompletionArgument + Meta map[string]any + Ref CompletionRef + type CompleteRequest struct + Argument CompletionArgument + Ref CompletionRef + type CompleteResult struct + Completion CompletionResult + Meta map[string]any + type CompletionArgument struct + Name string + Value string + type CompletionCapability struct + type CompletionRef struct + Name string + Type string + URI string + type CompletionResult struct + HasMore bool + Total int + Values []string + type Content interface + func DecodeContent(raw json.RawMessage) (Content, error) + type CreateMessageParams struct + IncludeContext string + MaxTokens int + Messages []SamplingMessage + Meta map[string]any + Metadata map[string]any + ModelPreferences *ModelPreferences + StopSequences []string + SystemPrompt string + Temperature *float64 + type CreateMessageResult struct + Content json.RawMessage + Model string + Role string + StopReason string + type CreateTaskResult struct + Meta map[string]any + Task Task + type ElicitationCapability struct + type ElicitationParams struct + Default string + Meta map[string]any + Prompt string + Type string + type ElicitationResult struct + Cancelled bool + Value string + type EmbeddedResource struct + Resource ResourceContent + func NewEmbeddedResource(rc ResourceContent) EmbeddedResource + func (e EmbeddedResource) MarshalJSON() ([]byte, error) + type GetPromptParams struct + Arguments map[string]string + Meta map[string]any + Name string + type GetPromptResult struct + Description string + Messages []PromptMessage + Meta map[string]any + type Icon struct + MimeType string + Sizes []string + Src string + type ImageContent struct + Data []byte + MimeType string + func NewImageContent(mimeType string, data []byte) ImageContent + func (c ImageContent) MarshalJSON() ([]byte, error) + type InitializeParams struct + Capabilities ClientCaps + ClientInfo ProcessInfo + Meta map[string]any + ProtocolVersion string + type InitializeResult struct + Capabilities ServerCapabilities + Instructions string + Meta map[string]any + ProtocolVersion string + ServerInfo ProcessInfo + type ItemFilter struct + Prompt func(*Prompt) bool + Resource func(*Resource) bool + ResourceTemplate func(*ResourceTemplate) bool + TenantID string + Tool func(*Tool) bool + func (f *ItemFilter) AllowPrompt(p *Prompt) (allowed bool) + func (f *ItemFilter) AllowResource(r *Resource) (allowed bool) + func (f *ItemFilter) AllowResourceTemplate(t *ResourceTemplate) (allowed bool) + func (f *ItemFilter) AllowTool(t *Tool) (allowed bool) + type JSONRPCError struct + Code int + Data any + Message string + func (e *JSONRPCError) Error() string + type JSONRPCNotification struct + JSONRPC string + Method string + Params any + type JSONRPCRequest struct + ID any + JSONRPC string + Method string + Params json.RawMessage + func (r *JSONRPCRequest) IsNotification() bool + func (r *JSONRPCRequest) UnmarshalJSON(data []byte) error + type JSONRPCResponse struct + Error *JSONRPCError + ID any + JSONRPC string + Result any + func NewErrorResponse(id any, code int, msg string) *JSONRPCResponse + func NewResponse(id any, result any) *JSONRPCResponse + type Job struct + CompletedAt time.Time + CreatedAt time.Time + Error string + ID string + Result *CallToolResult + Status JobStatus + ToolName string + type JobStatus string + const JobStatusCancelled + const JobStatusComplete + const JobStatusFailed + const JobStatusPending + const JobStatusRunning + type JobStore struct + func NewJobStore(opts ...JobStoreOption) *JobStore + func (js *JobStore) Cancel(id string) error + func (js *JobStore) Complete(id string, result *CallToolResult) error + func (js *JobStore) Delete(id string) error + func (js *JobStore) Fail(id string, errMsg string) error + func (js *JobStore) Get(id string) (*Job, error) + func (js *JobStore) List() []*Job + func (js *JobStore) MarkRunning(id string) error + func (js *JobStore) Submit(id, toolName string) (*Job, error) + type JobStoreOption func(*JobStore) + type LifespanFunc func(ctx context.Context, s *Server) (context.Context, func(), error) + type ListParams struct + Cursor string + Limit int + Meta map[string]any + type ListPromptsResult struct + Meta map[string]any + NextCursor string + Prompts []PromptInfo + type ListResourceTemplatesResult struct + Meta map[string]any + NextCursor string + ResourceTemplates []ResourceTemplateInfo + type ListResourcesResult struct + Meta map[string]any + NextCursor string + Resources []ResourceInfo + type ListRootsResult struct + Meta map[string]any + NextCursor string + Roots []RootInfo + type ListTasksResult struct + Meta map[string]any + NextCursor string + Tasks []Task + type ListToolsResult struct + Meta map[string]any + NextCursor string + Tools []ToolInfo + type LogHandler func(ctx context.Context, level LogLevel) error + type LogLevel string + const LogLevelAlert + const LogLevelCritical + const LogLevelDebug + const LogLevelEmergency + const LogLevelError + const LogLevelInfo + const LogLevelNotice + const LogLevelWarning + type LogMessageParams struct + Data any + Level LogLevel + Logger string + type LoggingCapability struct + type MergeFunc func(ctx context.Context, results map[string]ParallelResult) ([]byte, error) + type Middleware func(ToolHandler) ToolHandler + type ModelHint struct + Name string + type ModelPreferences struct + CostPriority *float64 + Hints []ModelHint + IntelligencePriority *float64 + SpeedPriority *float64 + type NamedHandler struct + Handler ToolHandler + Name string + type NotificationHandlerFunc func(ctx context.Context, params json.RawMessage) + type NotificationPanicHandler func(method string, recovered any) + type NotificationSender func(n *JSONRPCNotification) + func NotificationSenderFromCtx(ctx context.Context) NotificationSender + type ParallelResult struct + Error string + Output json.RawMessage + type PendingRequests struct + func NewPendingRequests(writeFn func(data []byte) error) *PendingRequests + func (pr *PendingRequests) CloseAll() + func (pr *PendingRequests) Deliver(data []byte) bool + func (pr *PendingRequests) Send(ctx context.Context, method string, params any) (*JSONRPCResponse, error) + type ProcessInfo struct + Description string + Icons []Icon + Name string + Title string + Version string + WebsiteURL string + type ProgressParams struct + Content []json.RawMessage + Progress float64 + ProgressToken any + Total float64 + type ProgressReporter func(progress, total float64) + func ProgressReporterFromCtx(ctx context.Context) ProgressReporter + type Prompt struct + Arguments []PromptArgument + Completer CompleteHandler + Description string + Handler PromptHandler + Name string + func NewPrompt(name string, handler PromptHandler, opts ...PromptOption) (*Prompt, error) + type PromptArgument struct + Description string + Name string + Required bool + type PromptCapability struct + ListChanged bool + type PromptHandler func(ctx context.Context, args map[string]string) ([]PromptMessage, error) + type PromptInfo struct + Arguments []PromptArgument + Description string + Name string + type PromptMessage struct + Content Content + Role string + func NewAssistantMessage(text string) PromptMessage + func NewUserMessage(text string) PromptMessage + func (m *PromptMessage) UnmarshalJSON(data []byte) error + type PromptOption func(*Prompt) + func WithCompleter(handler CompleteHandler) PromptOption + func WithPromptArguments(args ...PromptArgument) PromptOption + func WithPromptDescription(desc string) PromptOption + type ReadResourceParams struct + Meta map[string]any + URI string + type ReadResourceResult struct + Contents []ResourceContent + Meta map[string]any + func ReadResourceResultFromText(uri, text string) *ReadResourceResult + func (r ReadResourceResult) MarshalJSON() ([]byte, error) + type RequestSender func(ctx context.Context, method string, params any) (*JSONRPCResponse, error) + func RequestSenderFromCtx(ctx context.Context) RequestSender + type Resource struct + Description string + Handler ResourceHandler + MimeType string + Name string + URI string + func NewResource(uri, name string, handler ResourceHandler, opts ...ResourceOption) (*Resource, error) + type ResourceCapability struct + ListChanged bool + Subscribe bool + type ResourceContent struct + Blob *string + MimeType string + Text *string + URI string + func NewBlobResourceContent(uri string, data []byte) ResourceContent + func NewTextResourceContent(uri, text string) ResourceContent + func (c ResourceContent) MarshalJSON() ([]byte, error) + func (c ResourceContent) Validate() error + type ResourceHandler func(ctx context.Context, uri string) ([]ResourceContent, error) + type ResourceInfo struct + Description string + MimeType string + Name string + URI string + type ResourceOption func(*Resource) + func WithResourceDescription(desc string) ResourceOption + func WithResourceMimeType(mime string) ResourceOption + type ResourceTemplate struct + Completer CompleteHandler + Description string + Handler ResourceHandler + MimeType string + Name string + URITemplate string + func NewResourceTemplate(uriTemplate, name string, handler ResourceHandler, ...) (*ResourceTemplate, error) + type ResourceTemplateInfo struct + Description string + MimeType string + Name string + URITemplate string + type ResourceTemplateOption func(*ResourceTemplate) + func WithTemplateCompleter(handler CompleteHandler) ResourceTemplateOption + func WithTemplateDescription(desc string) ResourceTemplateOption + func WithTemplateMimeType(mime string) ResourceTemplateOption + type ResourceUpdatedParams struct + URI string + type Root struct + Name string + URI string + func NewRoot(uri string, opts ...RootOption) (*Root, error) + type RootInfo struct + Name string + URI string + type RootOption func(*Root) + func WithRootName(name string) RootOption + type SamplingCapability struct + type SamplingMessage struct + Content Content + Role string + func (m *SamplingMessage) UnmarshalJSON(data []byte) error + func (m SamplingMessage) MarshalJSON() ([]byte, error) + type Server struct + func NewServer(name, version string, opts ...ServerOption) *Server + func (s *Server) AddSender(id string, sender NotificationSender) error + func (s *Server) AddSessionTool(ctx context.Context, sessionID string, tool *Tool) error + func (s *Server) CallTool(ctx context.Context, name string, input []byte) (*CallToolResult, error) + func (s *Server) CreateMessage(ctx context.Context, params CreateMessageParams) (*CreateMessageResult, error) + func (s *Server) ElicitUser(ctx context.Context, params ElicitationParams) (*ElicitationResult, error) + func (s *Server) GetPrompt(ctx context.Context, name string, args map[string]string) (*GetPromptResult, error) + func (s *Server) HandleMessage(ctx context.Context, data []byte) (*JSONRPCResponse, error) + func (s *Server) ListPrompts() []*Prompt + func (s *Server) ListResourceTemplates() []*ResourceTemplate + func (s *Server) ListResources() []*Resource + func (s *Server) ListRoots() []*Root + func (s *Server) ListTools() []*Tool + func (s *Server) Name() string + func (s *Server) NegotiatedVersion() string + func (s *Server) NotificationStats() map[string]int + func (s *Server) NotifyPromptsListChanged() + func (s *Server) NotifyResourceUpdated(uri string) + func (s *Server) NotifyResourcesListChanged() + func (s *Server) NotifyRootsListChanged() + func (s *Server) NotifyToolsListChanged() + func (s *Server) OnNotification(method string, handler NotificationHandlerFunc) + func (s *Server) OnSessionToolShadow(cb SessionToolShadowCallback) + func (s *Server) ReadResource(ctx context.Context, uri string) (*ReadResourceResult, error) + func (s *Server) RegisterPrompt(p *Prompt) error + func (s *Server) RegisterResource(r *Resource) error + func (s *Server) RegisterResourceTemplate(t *ResourceTemplate) error + func (s *Server) RegisterRoot(r *Root) error + func (s *Server) RegisterTool(tool *Tool) error + func (s *Server) RegisterTools(tools ...*Tool) error + func (s *Server) RemoveNotificationHandlers(method string) int + func (s *Server) RemoveSender(id string) + func (s *Server) RemoveSessionTool(sessionID, name string) error + func (s *Server) RemoveSessionTools(sessionID string) + func (s *Server) RemoveTool(name string) error + func (s *Server) SendLogMessage(ctx context.Context, level LogLevel, logger string, data any) error + func (s *Server) SessionTools(sessionID string) []*Tool + func (s *Server) SetAuthChecker(checker AuthChecker) + func (s *Server) SetLogHandler(handler LogHandler) + func (s *Server) SetTenantResolver(resolver TenantResolver) + func (s *Server) Shutdown(ctx context.Context) error + func (s *Server) Start(ctx context.Context, runFn func(ctx context.Context) error) error + func (s *Server) Subscribe(subscriberID, uri string, sender NotificationSender) error + func (s *Server) Unsubscribe(subscriberID, uri string) + func (s *Server) UnsubscribeAll(subscriberID string) + func (s *Server) Use(mw ...Middleware) + func (s *Server) Version() string + type ServerCapabilities struct + Completions *CompletionCapability + Logging *LoggingCapability + Prompts *PromptCapability + Resources *ResourceCapability + Tasks *TaskCapability + Tools *ToolCapability + type ServerOption func(*Server) + func WithIcons(icons ...Icon) ServerOption + func WithInstructions(instructions string) ServerOption + func WithLifespan(fn LifespanFunc) ServerOption + func WithMaxHandlersPerNotification(n int) ServerOption + func WithMaxNotificationMethods(n int) ServerOption + func WithMaxSessionTools(n int) ServerOption + func WithMaxSessions(n int) ServerOption + func WithNotificationPanicHandler(h NotificationPanicHandler) ServerOption + func WithResourceSubscriptions() ServerOption + func WithServerDescription(desc string) ServerOption + func WithServerTitle(title string) ServerOption + func WithStreamBufferSize(n int) ServerOption + func WithSupportedVersions(versions ...string) ServerOption + func WithTaskStore(ts *TaskStore) ServerOption + func WithWebsiteURL(url string) ServerOption + type SessionToolShadowCallback func(sessionID, toolName string) + type SetLevelParams struct + Level LogLevel + type SetLevelResult struct + type SimulatorFunc func(ctx context.Context, input []byte) ([]byte, error) + func ToolSimulatorFromCtx(ctx context.Context) SimulatorFunc + type StreamChunkData struct + Content json.RawMessage + Sequence int64 + type SubscribeParams struct + Meta map[string]any + URI string + type Task struct + CreatedAt string + LastUpdatedAt string + PollInterval *int + Status TaskStatus + StatusMessage *string + TTL *int + TaskID string + type TaskCapability struct + Cancel any + List any + Requests *TaskRequestsCapability + type TaskIdParams struct + Meta map[string]any + TaskID string + type TaskMetadata struct + TTL *int + type TaskOptions struct + OwnerID string + PollInterval *int + TTL *int + type TaskRequestsCapability struct + Tools *TaskToolsCapability + type TaskStatus string + const TaskStatusCancelled + const TaskStatusCompleted + const TaskStatusFailed + const TaskStatusInputRequired + const TaskStatusWorking + type TaskStore struct + func NewTaskStore(opts ...TaskStoreOption) *TaskStore + func (ts *TaskStore) Cancel(id string) (*Task, error) + func (ts *TaskStore) Complete(id string, result *CallToolResult) error + func (ts *TaskStore) Delete(id string) error + func (ts *TaskStore) Fail(id string, errMsg string) error + func (ts *TaskStore) GenerateID() string + func (ts *TaskStore) Get(id string) (*Task, error) + func (ts *TaskStore) GetResult(id string) (*CallToolResult, error) + func (ts *TaskStore) List() []Task + func (ts *TaskStore) ListByOwner(ownerID string) []Task + func (ts *TaskStore) Submit(id string) (*Task, error) + func (ts *TaskStore) SubmitWithOptions(id string, opts TaskOptions) (*Task, error) + type TaskStoreOption func(*TaskStore) + func WithMaxTasks(n int) TaskStoreOption + type TaskToolsCapability struct + Call any + type TenantResolver func(ctx context.Context) (*ItemFilter, error) + type TextContent struct + Text string + func (c TextContent) MarshalJSON() ([]byte, error) + type Tool struct + Annotations *ToolAnnotations + Description string + Handler ToolHandler + InputSchema any + Name string + Roles []string + Simulator SimulatorFunc + SkipValidation bool + func NewTool(name string, handler ToolHandler, opts ...ToolOption) (*Tool, error) + func NewTypedTool[In any, Out any](name string, handler TypedHandler[In, Out], opts ...ToolOption) (*Tool, error) + type ToolAnnotations struct + DestructiveHint *bool + IdempotentHint *bool + OpenWorldHint *bool + ReadOnlyHint *bool + Title string + type ToolCapability struct + ListChanged bool + type ToolHandler func(ctx context.Context, input []byte) ([]byte, error) + func FanOutFanIn(merge MergeFunc, handlers ...NamedHandler) ToolHandler + func Parallel(handlers ...NamedHandler) ToolHandler + func Pipeline(first, second ToolHandler, rest ...ToolHandler) ToolHandler + type ToolInfo struct + Annotations *ToolAnnotations + Description string + InputSchema any + Name string + type ToolOption func(*Tool) + func WithAnnotations(a ToolAnnotations) ToolOption + func WithDescription(desc string) ToolOption + func WithDestructive() ToolOption + func WithIdempotent() ToolOption + func WithInputSchema(schema any) ToolOption + func WithOpenWorld() ToolOption + func WithReadOnly() ToolOption + func WithRoles(roles ...string) ToolOption + func WithSimulator(fn SimulatorFunc) ToolOption + func WithTitle(title string) ToolOption + func WithValidation(enabled bool) ToolOption + type ToolStream struct + func StreamFromCtx(ctx context.Context) *ToolStream + func (s *ToolStream) Send(c Content) error + func (s *ToolStream) SendText(text string) error + func (s *ToolStream) Sequence() int64 + type TypedHandler func(ctx context.Context, input In) (Out, error) v0.1.0-beta.1 May 20, 2026 v0.1.0-beta May 18, 2026