Documentation
¶
Index ¶
- Constants
- func ChainMiddlewareHandlers(h http.Handler, mws ...Middleware) http.Handler
- type Adapter
- func (a *Adapter) CallTool(ctx context.Context, params *schema.CallToolRequestParams) (*schema.CallToolResult, error)
- func (a *Adapter) Complete(ctx context.Context, params *schema.CompleteRequestParams) (*schema.CompleteResult, error)
- func (a *Adapter) CreateMessage(ctx context.Context, params *schema.CreateMessageRequestParams) (*schema.CreateMessageResult, error)
- func (a *Adapter) CreateUserInteraction(ctx context.Context, params *schema.CreateUserInteractionRequestParams) (*schema.CreateUserInteractionResult, error)
- func (a *Adapter) Elicit(ctx context.Context, params *schema.ElicitRequestParams) (*schema.ElicitResult, error)
- func (a *Adapter) GetPrompt(ctx context.Context, params *schema.GetPromptRequestParams) (*schema.GetPromptResult, error)
- func (a *Adapter) Initialize(ctx context.Context) (*schema.InitializeResult, error)
- func (a *Adapter) ListPrompts(ctx context.Context, cursor *string) (*schema.ListPromptsResult, error)
- func (a *Adapter) ListResourceTemplates(ctx context.Context, cursor *string) (*schema.ListResourceTemplatesResult, error)
- func (a *Adapter) ListResources(ctx context.Context, cursor *string) (*schema.ListResourcesResult, error)
- func (a *Adapter) ListRoots(ctx context.Context, params *schema.ListRootsRequestParams) (*schema.ListRootsResult, error)
- func (a *Adapter) ListTools(ctx context.Context, cursor *string) (*schema.ListToolsResult, error)
- func (a *Adapter) Ping(ctx context.Context, params *schema.PingRequestParams) (*schema.PingResult, error)
- func (a *Adapter) ReadResource(ctx context.Context, params *schema.ReadResourceRequestParams) (*schema.ReadResourceResult, error)
- func (a *Adapter) SetLevel(ctx context.Context, params *schema.SetLevelRequestParams) (*schema.SetLevelResult, error)
- func (a *Adapter) Subscribe(ctx context.Context, params *schema.SubscribeRequestParams) (*schema.SubscribeResult, error)
- func (a *Adapter) Unsubscribe(ctx context.Context, params *schema.UnsubscribeRequestParams) (*schema.UnsubscribeResult, error)
- type Client
- func (c *Client) CreateMessage(ctx context.Context, params *schema.CreateMessageRequestParams) (*schema.CreateMessageResult, *jsonrpc.Error)
- func (c *Client) CreateUserInteraction(ctx context.Context, params *schema.CreateUserInteractionRequestParams) (*schema.CreateUserInteractionResult, *jsonrpc.Error)
- func (c *Client) Elicit(ctx context.Context, params *schema.ElicitRequestParams) (*schema.ElicitResult, *jsonrpc.Error)
- func (c *Client) Implements(method string) bool
- func (c *Client) Init(ctx context.Context, capabilities *schema.ClientCapabilities)
- func (c *Client) ListRoots(ctx context.Context, params *schema.ListRootsRequestParams) (*schema.ListRootsResult, *jsonrpc.Error)
- type Cors
- type Handler
- func (h *Handler) CallTool(ctx context.Context, request *jsonrpc.Request) (*schema.CallToolResult, *jsonrpc.Error)
- func (h *Handler) Cancel(ctx context.Context, notification *jsonrpc.Notification) *jsonrpc.Error
- func (h *Handler) Complete(ctx context.Context, request *jsonrpc.Request) (*schema.CompleteResult, *jsonrpc.Error)
- func (h *Handler) GetPrompt(ctx context.Context, request *jsonrpc.Request) (*schema.GetPromptResult, *jsonrpc.Error)
- func (h *Handler) Initialize(ctx context.Context, request *jsonrpc.Request) (*schema.InitializeResult, *jsonrpc.Error)
- func (h *Handler) ListPrompts(ctx context.Context, request *jsonrpc.Request) (*schema.ListPromptsResult, *jsonrpc.Error)
- func (h *Handler) ListResourceTemplates(ctx context.Context, request *jsonrpc.Request) (*schema.ListResourceTemplatesResult, *jsonrpc.Error)
- func (h *Handler) ListResources(ctx context.Context, request *jsonrpc.Request) (*schema.ListResourcesResult, *jsonrpc.Error)
- func (h *Handler) ListTools(ctx context.Context, request *jsonrpc.Request) (*schema.ListToolsResult, *jsonrpc.Error)
- func (h *Handler) OnNotification(ctx context.Context, notification *jsonrpc.Notification)
- func (h *Handler) Ping(ctx context.Context, request *jsonrpc.Request) (*schema.PingResult, *jsonrpc.Error)
- func (h *Handler) ReadResource(ctx context.Context, request *jsonrpc.Request) (*schema.ReadResourceResult, *jsonrpc.Error)
- func (h *Handler) Serve(parent context.Context, request *jsonrpc.Request, response *jsonrpc.Response)
- func (h *Handler) SetLevel(ctx context.Context, request *jsonrpc.Request) (*schema.SetLevelResult, *jsonrpc.Error)
- func (h *Handler) Subscribe(ctx context.Context, request *jsonrpc.Request) (*schema.SubscribeResult, *jsonrpc.Error)
- func (h *Handler) Unsubscribe(ctx context.Context, request *jsonrpc.Request) (*schema.UnsubscribeResult, *jsonrpc.Error)
- type Logger
- func (l *Logger) Alert(ctx context.Context, data interface{}) error
- func (l *Logger) Critical(ctx context.Context, data interface{}) error
- func (l *Logger) Debug(ctx context.Context, data interface{}) error
- func (l *Logger) Emergency(ctx context.Context, data interface{}) error
- func (l *Logger) Error(ctx context.Context, data interface{}) error
- func (l *Logger) Info(ctx context.Context, data interface{}) error
- func (l *Logger) Logger(name string) logger.Logger
- func (l *Logger) Notice(ctx context.Context, data interface{}) error
- func (l *Logger) Warning(ctx context.Context, data interface{}) error
- type Middleware
- type Option
- func WithAuthorizer(authorizer Middleware) Option
- func WithCORS(cors *Cors) Option
- func WithCustomHandler(path string, handler http.HandlerFunc) Option
- func WithEndpointAddress(addr string) Option
- func WithImplementation(implementation schema.Implementation) Option
- func WithJRPCAuthorizer(authorizer auth.JRPCAuthorizer) Option
- func WithLoggerName(name string) Option
- func WithNewServer(NewServer server.NewServer) Option
- func WithProtectedResourcesHandler(handler http.HandlerFunc) Option
- func WithProtocolVersion(version string) Option
- type Server
- func (s *Server) AsClient(ctx context.Context) client.Interface
- func (s *Server) HTTP(_ context.Context, addr string) *http.Server
- func (s *Server) NewHandler(ctx context.Context, transport transport.Transport) transport.Handler
- func (s *Server) Stdio(ctx context.Context) *stdio.Server
- func (s *Server) UseStreaming(useStreaming bool)
Constants ¶
const ( AllowOriginHeader = "Access-Control-Allow-Origin" AllowHeadersHeader = "Access-Control-Allow-Headers" AllowMethodsHeader = "Access-Control-Allow-Methods" AllControlRequestHeader = "Access-Control-Request-Method" AllowCredentialsHeader = "Access-Control-Allow-Credentials" ExposeHeadersHeader = "Access-Control-Expose-Headers" MaxAgeHeader = "Access-Control-Max-Age" Separator = ", " )
Variables ¶
This section is empty.
Functions ¶
func ChainMiddlewareHandlers ¶ added in v0.2.5
func ChainMiddlewareHandlers(h http.Handler, mws ...Middleware) http.Handler
ChainMiddlewareHandlers chains multiple middleware handlers together
Types ¶
type Adapter ¶ added in v0.2.5
type Adapter struct {
// contains filtered or unexported fields
}
Adapter adapts a server Handler to implement the client.Interface
func NewAdapter ¶ added in v0.2.5
NewAdapter creates a new adapter for the given handler
func (*Adapter) CallTool ¶ added in v0.2.5
func (a *Adapter) CallTool(ctx context.Context, params *schema.CallToolRequestParams) (*schema.CallToolResult, error)
CallTool calls a tool
func (*Adapter) Complete ¶ added in v0.2.5
func (a *Adapter) Complete(ctx context.Context, params *schema.CompleteRequestParams) (*schema.CompleteResult, error)
Complete completes a request
func (*Adapter) CreateMessage ¶ added in v0.2.10
func (a *Adapter) CreateMessage(ctx context.Context, params *schema.CreateMessageRequestParams) (*schema.CreateMessageResult, error)
CreateMessage proxies "sampling/createMessage" to the underlying handler.
func (*Adapter) CreateUserInteraction ¶ added in v0.2.10
func (a *Adapter) CreateUserInteraction(ctx context.Context, params *schema.CreateUserInteractionRequestParams) (*schema.CreateUserInteractionResult, error)
CreateUserInteraction proxies "interaction/create" to the underlying handler.
func (*Adapter) Elicit ¶ added in v0.2.10
func (a *Adapter) Elicit(ctx context.Context, params *schema.ElicitRequestParams) (*schema.ElicitResult, error)
Elicit proxies "elicitation/create" to the underlying handler.
func (*Adapter) GetPrompt ¶ added in v0.2.5
func (a *Adapter) GetPrompt(ctx context.Context, params *schema.GetPromptRequestParams) (*schema.GetPromptResult, error)
GetPrompt gets a prompt
func (*Adapter) Initialize ¶ added in v0.2.5
Initialize initializes the client
func (*Adapter) ListPrompts ¶ added in v0.2.5
func (a *Adapter) ListPrompts(ctx context.Context, cursor *string) (*schema.ListPromptsResult, error)
ListPrompts lists prompts
func (*Adapter) ListResourceTemplates ¶ added in v0.2.5
func (a *Adapter) ListResourceTemplates(ctx context.Context, cursor *string) (*schema.ListResourceTemplatesResult, error)
ListResourceTemplates lists resource templates
func (*Adapter) ListResources ¶ added in v0.2.5
func (a *Adapter) ListResources(ctx context.Context, cursor *string) (*schema.ListResourcesResult, error)
ListResources lists resources
func (*Adapter) ListRoots ¶ added in v0.2.10
func (a *Adapter) ListRoots(ctx context.Context, params *schema.ListRootsRequestParams) (*schema.ListRootsResult, error)
ListRoots proxies "roots/list" to the underlying handler.
func (*Adapter) Ping ¶ added in v0.2.5
func (a *Adapter) Ping(ctx context.Context, params *schema.PingRequestParams) (*schema.PingResult, error)
Ping pings the server
func (*Adapter) ReadResource ¶ added in v0.2.5
func (a *Adapter) ReadResource(ctx context.Context, params *schema.ReadResourceRequestParams) (*schema.ReadResourceResult, error)
ReadResource reads a resource
func (*Adapter) SetLevel ¶ added in v0.2.5
func (a *Adapter) SetLevel(ctx context.Context, params *schema.SetLevelRequestParams) (*schema.SetLevelResult, error)
SetLevel sets the logging level
func (*Adapter) Subscribe ¶ added in v0.2.5
func (a *Adapter) Subscribe(ctx context.Context, params *schema.SubscribeRequestParams) (*schema.SubscribeResult, error)
Subscribe subscribes to a resource
func (*Adapter) Unsubscribe ¶ added in v0.2.5
func (a *Adapter) Unsubscribe(ctx context.Context, params *schema.UnsubscribeRequestParams) (*schema.UnsubscribeResult, error)
Unsubscribe unsubscribes from a resource
type Client ¶
Client implements mcp-protocol/client.Operations for the server side. It allows server implementers to invoke client-side RPC methods over the same transport channel on which the original request arrived.
func (*Client) CreateMessage ¶
func (c *Client) CreateMessage(ctx context.Context, params *schema.CreateMessageRequestParams) (*schema.CreateMessageResult, *jsonrpc.Error)
CreateMessage creates a sampling message on the client side.
func (*Client) CreateUserInteraction ¶ added in v0.2.10
func (c *Client) CreateUserInteraction(ctx context.Context, params *schema.CreateUserInteractionRequestParams) (*schema.CreateUserInteractionResult, *jsonrpc.Error)
CreateUserInteraction requests that the client presents an interaction UI to the user and returns their response.
func (*Client) Elicit ¶ added in v0.2.10
func (c *Client) Elicit(ctx context.Context, params *schema.ElicitRequestParams) (*schema.ElicitResult, *jsonrpc.Error)
Elicit asks the client to elicit additional information from the user.
func (*Client) Implements ¶ added in v0.2.11
type Cors ¶ added in v0.2.5
type Cors struct {
AllowCredentials *bool `yaml:"AllowCredentials,omitempty"`
AllowHeaders []string `yaml:"AllowHeaders,omitempty"`
AllowMethods []string `yaml:"AllowMethods,omitempty"`
AllowOrigins []string `yaml:"AllowOrigins,omitempty"`
ExposeHeaders []string `yaml:"ExposeHeaders,omitempty"`
MaxAge *int64 `yaml:"MaxAge,omitempty"`
}
type Handler ¶
type Handler struct {
transport.Notifier
*Logger
*Server
Initialized bool
// contains filtered or unexported fields
}
Handler represents handler
func (*Handler) CallTool ¶
func (h *Handler) CallTool(ctx context.Context, request *jsonrpc.Request) (*schema.CallToolResult, *jsonrpc.Error)
CallTool handles the tools/call method
func (*Handler) Complete ¶
func (h *Handler) Complete(ctx context.Context, request *jsonrpc.Request) (*schema.CompleteResult, *jsonrpc.Error)
Complete handles the completion/complete method
func (*Handler) GetPrompt ¶
func (h *Handler) GetPrompt(ctx context.Context, request *jsonrpc.Request) (*schema.GetPromptResult, *jsonrpc.Error)
GetPrompt handles the prompts/get method
func (*Handler) Initialize ¶
func (h *Handler) Initialize(ctx context.Context, request *jsonrpc.Request) (*schema.InitializeResult, *jsonrpc.Error)
Initialize handles the initialize method
func (*Handler) ListPrompts ¶
func (h *Handler) ListPrompts(ctx context.Context, request *jsonrpc.Request) (*schema.ListPromptsResult, *jsonrpc.Error)
ListPrompts handles the prompts/list method
func (*Handler) ListResourceTemplates ¶
func (h *Handler) ListResourceTemplates(ctx context.Context, request *jsonrpc.Request) (*schema.ListResourceTemplatesResult, *jsonrpc.Error)
ListResourceTemplates handles the resources/templates/list method
func (*Handler) ListResources ¶
func (h *Handler) ListResources(ctx context.Context, request *jsonrpc.Request) (*schema.ListResourcesResult, *jsonrpc.Error)
ListResources handles the resources/list method
func (*Handler) ListTools ¶
func (h *Handler) ListTools(ctx context.Context, request *jsonrpc.Request) (*schema.ListToolsResult, *jsonrpc.Error)
ListTools handles the tools/list method
func (*Handler) OnNotification ¶
func (h *Handler) OnNotification(ctx context.Context, notification *jsonrpc.Notification)
OnNotification handles incoming JSON-RPC notifications
func (*Handler) Ping ¶
func (h *Handler) Ping(ctx context.Context, request *jsonrpc.Request) (*schema.PingResult, *jsonrpc.Error)
Ping handles the ping method
func (*Handler) ReadResource ¶
func (h *Handler) ReadResource(ctx context.Context, request *jsonrpc.Request) (*schema.ReadResourceResult, *jsonrpc.Error)
ReadResource handles the resources/read method
func (*Handler) Serve ¶
func (h *Handler) Serve(parent context.Context, request *jsonrpc.Request, response *jsonrpc.Response)
Serve handles incoming JSON-RPC requests
func (*Handler) SetLevel ¶
func (h *Handler) SetLevel(ctx context.Context, request *jsonrpc.Request) (*schema.SetLevelResult, *jsonrpc.Error)
SetLevel handles the logging/setLevel method
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
type Middleware ¶ added in v0.2.5
Middleware is a function that takes an http.Handler and returns an http.Handler
type Option ¶
Option is a function that configures the server.
func WithAuthorizer ¶
func WithAuthorizer(authorizer Middleware) Option
WithAuthorizer adds a new authorizer to the server.
func WithCustomHandler ¶ added in v0.2.10
func WithCustomHandler(path string, handler http.HandlerFunc) Option
WithCustomHandler adds a custom handler to the server.
func WithEndpointAddress ¶ added in v0.2.10
WithEndpointAddress sets the protocol version.
func WithImplementation ¶
func WithImplementation(implementation schema.Implementation) Option
WithImplementation sets the server implementation.
func WithJRPCAuthorizer ¶ added in v0.2.5
func WithJRPCAuthorizer(authorizer auth.JRPCAuthorizer) Option
WithJRPCAuthorizer adds a new JRPCAuthorizer to the server.
func WithNewServer ¶ added in v0.2.11
WithNewServer sets the new server.
func WithProtectedResourcesHandler ¶ added in v0.2.5
func WithProtectedResourcesHandler(handler http.HandlerFunc) Option
func WithProtocolVersion ¶ added in v0.2.10
WithProtocolVersion sets the protocol version for the server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents MCP protocol handler
func (*Server) AsClient ¶ added in v0.2.5
AsClient returns a client.Interface implementation that uses this server directly
func (*Server) HTTP ¶
HTTP creates and returns an HTTP server with OAuth2 authorizer and SSE handlers.
func (*Server) NewHandler ¶
NewHandler creates a new handler instance
func (*Server) UseStreaming ¶ added in v0.2.10
UseStreaming sets whether to use streaming or SSE for the HTTP server.