Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func GenerateSchema(handler interface{}) (map[string]interface{}, error)
- type BaseJSONRPCMessage
- type Client
- type CloseHandler
- type Content
- type ErrorHandler
- type InitializeResponse
- type ListPromptsResponse
- type ListResourcesResponse
- type LoggingCapability
- type MCPServer
- func (s *MCPServer) Close() error
- func (s *MCPServer) DeregisterPrompt(name string) error
- func (s *MCPServer) DeregisterResource(uri string) error
- func (s *MCPServer) DeregisterTool(name string) error
- func (s *MCPServer) HasPrompt(name string) bool
- func (s *MCPServer) HasResource(uri string) bool
- func (s *MCPServer) HasTool(name string) bool
- func (s *MCPServer) RegisterPrompt(name, description string, handler interface{}) error
- func (s *MCPServer) RegisterResource(uri, name, description, mimeType string, handler interface{}) error
- func (s *MCPServer) RegisterTool(name, description string, handler interface{}) error
- func (s *MCPServer) Serve() error
- type MessageHandler
- type MessageRole
- type Prompt
- type PromptArgument
- type PromptMessage
- type PromptResponse
- type PromptsCapability
- type RPCError
- type Resource
- type ResourceContent
- type ResourceResponse
- type ResourcesCapability
- type Server
- type ServerCapabilities
- type ServerInfo
- type ServerOption
- type Tool
- type ToolResponse
- type ToolsCapability
- type ToolsResponse
- type Transport
Constants ΒΆ
const ( RoleUser = types.RoleUser RoleAssistant = types.RoleAssistant )
Re-export constants
Variables ΒΆ
var ( NewTextContent = types.NewTextContent NewToolResponse = types.NewToolResponse NewPromptMessage = types.NewPromptMessage NewPromptResponse = types.NewPromptResponse NewTextResource = types.NewTextResource NewResourceResponse = types.NewResourceResponse )
Re-export helper functions
Functions ΒΆ
func GenerateSchema ΒΆ
GenerateSchema generates a JSON schema from a function signature
Types ΒΆ
type BaseJSONRPCMessage ΒΆ
type BaseJSONRPCMessage = types.BaseJSONRPCMessage
Re-export message types
type Client ΒΆ
type Client interface {
// Initialize connects to the server and retrieves its capabilities
Initialize(ctx context.Context) (*InitializeResponse, error)
// ListTools retrieves the list of available tools from the server
ListTools(ctx context.Context, cursor *string) (*ToolsResponse, error)
// CallTool calls a specific tool on the server with the provided arguments
CallTool(ctx context.Context, name string, args interface{}) (*ToolResponse, error)
// ListPrompts retrieves the list of available prompts from the server
ListPrompts(ctx context.Context, cursor *string) (*ListPromptsResponse, error)
// GetPrompt retrieves a specific prompt from the server
GetPrompt(ctx context.Context, name string, args interface{}) (*PromptResponse, error)
// ListResources retrieves the list of available resources from the server
ListResources(ctx context.Context, cursor *string) (*ListResourcesResponse, error)
// ReadResource reads a specific resource from the server
ReadResource(ctx context.Context, uri string) (*ResourceResponse, error)
// Ping sends a ping request to check server connectivity
Ping(ctx context.Context) error
// GetCapabilities returns the server capabilities obtained during initialization
GetCapabilities() *ServerCapabilities
// Close closes the client connection
Close() error
}
Client represents an MCP client that can connect to and interact with MCP servers
type CloseHandler ΒΆ
type CloseHandler = transport.CloseHandler
type ErrorHandler ΒΆ
type ErrorHandler = transport.ErrorHandler
type ListPromptsResponse ΒΆ
type ListPromptsResponse = types.ListPromptsResponse
type ListResourcesResponse ΒΆ
type ListResourcesResponse = types.ListResourcesResponse
type LoggingCapability ΒΆ
type LoggingCapability = types.LoggingCapability
type MCPServer ΒΆ
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer implements the Server interface with automatic tool management
func (*MCPServer) DeregisterPrompt ΒΆ added in v0.0.2
DeregisterPrompt removes a prompt from the server
func (*MCPServer) DeregisterResource ΒΆ added in v0.0.2
DeregisterResource removes a resource from the server
func (*MCPServer) DeregisterTool ΒΆ added in v0.0.2
DeregisterTool removes a tool from the server
func (*MCPServer) HasResource ΒΆ added in v0.0.2
HasResource checks if a resource is registered
func (*MCPServer) RegisterPrompt ΒΆ
RegisterPrompt registers a prompt with automatic argument extraction
func (*MCPServer) RegisterResource ΒΆ
func (s *MCPServer) RegisterResource(uri, name, description, mimeType string, handler interface{}) error
RegisterResource registers a resource
func (*MCPServer) RegisterTool ΒΆ
RegisterTool registers a tool with automatic schema generation
type MessageHandler ΒΆ
type MessageHandler = transport.MessageHandler
type MessageRole ΒΆ
type MessageRole = types.MessageRole
type PromptArgument ΒΆ
type PromptArgument = types.PromptArgument
type PromptMessage ΒΆ
type PromptMessage = types.PromptMessage
type PromptResponse ΒΆ
type PromptResponse = types.PromptResponse
type PromptsCapability ΒΆ
type PromptsCapability = types.PromptsCapability
type ResourceContent ΒΆ
type ResourceContent = types.ResourceContent
type ResourceResponse ΒΆ
type ResourceResponse = types.ResourceResponse
type ResourcesCapability ΒΆ
type ResourcesCapability = types.ResourcesCapability
type Server ΒΆ
type Server interface {
// RegisterTool registers a new tool with the server
// The handler should be a function with signature:
// func(ctx context.Context, args YourArgsStruct) (*ToolResponse, error)
// or
// func(args YourArgsStruct) (*ToolResponse, error)
RegisterTool(name, description string, handler interface{}) error
// RegisterPrompt registers a new prompt with the server
RegisterPrompt(name, description string, handler interface{}) error
// RegisterResource registers a new resource with the server
RegisterResource(uri, name, description, mimeType string, handler interface{}) error
// DeregisterTool removes a tool from the server
DeregisterTool(name string) error
// DeregisterPrompt removes a prompt from the server
DeregisterPrompt(name string) error
// DeregisterResource removes a resource from the server
DeregisterResource(uri string) error
// HasTool checks if a tool is registered
HasTool(name string) bool
// HasPrompt checks if a prompt is registered
HasPrompt(name string) bool
// HasResource checks if a resource is registered
HasResource(uri string) bool
// Serve starts the server and begins handling requests
Serve() error
// Close shuts down the server gracefully
Close() error
}
Server represents an MCP server that can register and serve tools, prompts, and resources
func NewServer ΒΆ
func NewServer(transport Transport, opts ...ServerOption) Server
NewServer creates a new MCP server
type ServerCapabilities ΒΆ
type ServerCapabilities = types.ServerCapabilities
type ServerInfo ΒΆ
type ServerInfo = types.ServerInfo
type ServerOption ΒΆ
type ServerOption func(*MCPServer)
ServerOption configures the server
func WithPaginationLimit ΒΆ added in v0.0.2
func WithPaginationLimit(limit int) ServerOption
WithPaginationLimit sets the pagination limit for list responses
func WithVersion ΒΆ
func WithVersion(version string) ServerOption
WithVersion sets the server version
type ToolResponse ΒΆ
type ToolResponse = types.ToolResponse
type ToolsCapability ΒΆ
type ToolsCapability = types.ToolsCapability
type ToolsResponse ΒΆ
type ToolsResponse = types.ToolsResponse
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
grpc/clients/go
command
|
|
|
grpc/server
command
|
|
|
middleware/client
command
|
|
|
middleware/server
command
|
|
|
sse/clients/go
command
|
|
|
sse/server
command
|
|
|
stdio/clients/go
command
|
|
|
stdio/server
command
|
|
|
streamable_http/clients/go
command
|
|
|
streamable_http/server
command
|
|