Documentation
¶
Index ¶
- func ClearLocalServers()
- func RegisterLocalServer(server *Server)
- func RegisterTypedTool[TInput any, TOutput any](s *Server, name string, description string, ...) error
- type Args
- func (a Args) Bool(key string) bool
- func (a Args) Float(key string) float64
- func (a Args) Int(key string) int
- func (a Args) Map(key string) map[string]any
- func (a Args) String(key string) string
- func (a Args) ValidatedFloat(key string, validator security.ArgValidator) (float64, error)
- func (a Args) ValidatedInt(key string, validator security.ArgValidator) (int, error)
- func (a Args) ValidatedString(key string, validator security.ArgValidator) (string, error)
- type AuthConfig
- type CallToolParams
- type CallToolResult
- type Client
- type Cluster
- func (c *Cluster) DeregisterNode(instanceID string) error
- func (c *Cluster) GetNode() (*ClusterNode, error)
- func (c *Cluster) HealthyNodes() []*ClusterNode
- func (c *Cluster) Nodes() []*ClusterNode
- func (c *Cluster) RegisterNode(instance *ServiceInstance) error
- func (c *Cluster) Send(ctx context.Context, method string, params any) (any, error)
- func (c *Cluster) Start(ctx context.Context) error
- func (c *Cluster) Stop() error
- type ClusterConfig
- type ClusterNode
- type ClusterTransport
- type ConsulDiscovery
- func (d *ConsulDiscovery) Close() error
- func (d *ConsulDiscovery) Deregister(ctx context.Context, instanceID string) error
- func (d *ConsulDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
- func (d *ConsulDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
- func (d *ConsulDiscovery) UpdateService(serviceName string, instances []*ServiceInstance)
- func (d *ConsulDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
- type ConsulDiscoveryConfig
- type Content
- type DNSDiscovery
- func (d *DNSDiscovery) Close() error
- func (d *DNSDiscovery) Deregister(ctx context.Context, instanceID string) error
- func (d *DNSDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
- func (d *DNSDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
- func (d *DNSDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
- type DNSDiscoveryConfig
- type GRPCServer
- func (s *GRPCServer) Address() string
- func (s *GRPCServer) CallTool(ctx context.Context, req *pb.CallToolRequest) (*pb.CallToolResponse, error)
- func (s *GRPCServer) ForceStop()
- func (s *GRPCServer) Initialize(ctx context.Context, req *pb.InitializeRequest) (*pb.InitializeResponse, error)
- func (s *GRPCServer) ListTools(ctx context.Context, req *pb.ListToolsRequest) (*pb.ListToolsResponse, error)
- func (s *GRPCServer) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error)
- func (s *GRPCServer) Serve(address string) error
- func (s *GRPCServer) Stop()
- func (s *GRPCServer) StreamCallTool(req *pb.CallToolRequest, ...) error
- type GRPCTransport
- func (t *GRPCTransport) Close() error
- func (t *GRPCTransport) Connect(ctx context.Context) error
- func (t *GRPCTransport) IsConnected() bool
- func (t *GRPCTransport) Receive() ([]byte, error)
- func (t *GRPCTransport) Send(ctx context.Context, method string, params any) (any, error)
- func (t *GRPCTransport) StreamCallTool(ctx context.Context, name string, args map[string]any) (<-chan *CallToolResult, <-chan error)
- type GRPCTransportConfig
- type KubernetesDiscovery
- func (d *KubernetesDiscovery) Close() error
- func (d *KubernetesDiscovery) Deregister(ctx context.Context, instanceID string) error
- func (d *KubernetesDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
- func (d *KubernetesDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
- func (d *KubernetesDiscovery) UpdateEndpoints(serviceName string, instances []*ServiceInstance)
- func (d *KubernetesDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
- type KubernetesDiscoveryConfig
- type LoadBalancerStrategy
- type LocalTransport
- type NodeState
- type Schema
- type SchemaField
- type Server
- func (s *Server) CallTool(ctx context.Context, params CallToolParams) (*CallToolResult, error)
- func (s *Server) Close() error
- func (s *Server) GetAuthExtractor() security.AuthExtractor
- func (s *Server) GetSecurityConfig() *security.SecurityConfig
- func (s *Server) ListTools() []Tool
- func (s *Server) Name() string
- func (s *Server) RegisterTool(tool Tool) error
- func (s *Server) RegisterTypedTool(tool interface{ ... }) error
- func (s *Server) Serve(transport Transport) error
- type ServerConfig
- type ServerOption
- func WithAuditLogger(logger security.AuditLogger) ServerOption
- func WithAuthenticator(auth security.Authenticator) ServerOption
- func WithAuthorizer(authz security.Authorizer) ServerOption
- func WithDebugMode(debug bool) ServerOption
- func WithIntegratedAuditLogger(logger *security.IntegratedAuditLogger) ServerOption
- func WithRateLimit(requestsPerSecond float64, burst int) ServerOption
- func WithSecurityConfig(config *security.SecurityConfig) ServerOption
- type ServiceDiscovery
- type ServiceInstance
- type Session
- type StaticDiscovery
- func (d *StaticDiscovery) Close() error
- func (d *StaticDiscovery) Deregister(ctx context.Context, instanceID string) error
- func (d *StaticDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
- func (d *StaticDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
- func (d *StaticDiscovery) SetHealthy(instanceID string, healthy bool)
- func (d *StaticDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
- type TLSConfig
- type Tool
- type ToolHandler
- type ToolRegistry
- func (r *ToolRegistry) GetServer(toolName string) string
- func (r *ToolRegistry) GetTool(name string) (Tool, error)
- func (r *ToolRegistry) HasTool(name string) bool
- func (r *ToolRegistry) ListTools() []Tool
- func (r *ToolRegistry) Register(serverName string, tools []Tool) error
- func (r *ToolRegistry) RegisterWithOverride(serverName string, tools []Tool)
- type Transport
- type TypedTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearLocalServers ¶
func ClearLocalServers()
ClearLocalServers clears all registered local servers (for testing)
func RegisterLocalServer ¶
func RegisterLocalServer(server *Server)
RegisterLocalServer registers a server for local transport
Types ¶
type Args ¶
Args provides type-safe access to tool arguments
func (Args) ValidatedFloat ¶
ValidatedFloat returns a validated float argument
func (Args) ValidatedInt ¶
ValidatedInt returns a validated integer argument
func (Args) ValidatedString ¶
ValidatedString returns a validated string argument
type AuthConfig ¶
AuthConfig represents authentication configuration
type CallToolParams ¶
type CallToolParams struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
}
CallToolParams represents parameters for calling a tool
type CallToolResult ¶
type CallToolResult struct {
Content []Content `json:"content"`
IsError bool `json:"isError,omitempty"`
}
CallToolResult represents the result of a tool call
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an MCP client that connects to servers
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster coordinates multiple service nodes with load balancing and failover
func NewCluster ¶
func NewCluster(config ClusterConfig) (*Cluster, error)
NewCluster creates a new cluster coordinator
func (*Cluster) DeregisterNode ¶
DeregisterNode removes a node from the cluster
func (*Cluster) GetNode ¶
func (c *Cluster) GetNode() (*ClusterNode, error)
GetNode returns a node using the configured load balancing strategy
func (*Cluster) HealthyNodes ¶
func (c *Cluster) HealthyNodes() []*ClusterNode
HealthyNodes returns only healthy nodes
func (*Cluster) RegisterNode ¶
func (c *Cluster) RegisterNode(instance *ServiceInstance) error
RegisterNode manually registers a node
type ClusterConfig ¶
type ClusterConfig struct {
ServiceName string
Discovery ServiceDiscovery
Strategy LoadBalancerStrategy
HealthCheckInterval time.Duration
HealthCheckTimeout time.Duration
MaxFailures int
RetryAttempts int
RetryDelay time.Duration
TLS *TLSConfig
}
ClusterConfig configures the cluster coordinator
type ClusterNode ¶
type ClusterNode struct {
Instance *ServiceInstance
State NodeState
LastHealthCheck time.Time
FailureCount int
Connections int64
Transport *GRPCTransport
// contains filtered or unexported fields
}
ClusterNode represents a node in the cluster
func (*ClusterNode) DecrementConnections ¶
func (n *ClusterNode) DecrementConnections()
DecrementConnections atomically decrements the connection count
func (*ClusterNode) GetConnections ¶
func (n *ClusterNode) GetConnections() int64
GetConnections atomically returns the connection count
func (*ClusterNode) IncrementConnections ¶
func (n *ClusterNode) IncrementConnections()
IncrementConnections atomically increments the connection count
type ClusterTransport ¶
type ClusterTransport struct {
// contains filtered or unexported fields
}
ClusterTransport wraps a Cluster to implement the Transport interface
func NewClusterTransport ¶
func NewClusterTransport(cluster *Cluster) *ClusterTransport
NewClusterTransport creates a Transport backed by cluster coordination
type ConsulDiscovery ¶
type ConsulDiscovery struct {
// contains filtered or unexported fields
}
ConsulDiscovery implements ServiceDiscovery using Consul
func NewConsulDiscovery ¶
func NewConsulDiscovery(config ConsulDiscoveryConfig) *ConsulDiscovery
NewConsulDiscovery creates a new Consul-based service discovery
func (*ConsulDiscovery) Deregister ¶
func (d *ConsulDiscovery) Deregister(ctx context.Context, instanceID string) error
Deregister removes a service from Consul
func (*ConsulDiscovery) Discover ¶
func (d *ConsulDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
Discover queries Consul for healthy service instances Note: In production, this would use the Consul API client
func (*ConsulDiscovery) Register ¶
func (d *ConsulDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
Register registers a service with Consul
func (*ConsulDiscovery) UpdateService ¶
func (d *ConsulDiscovery) UpdateService(serviceName string, instances []*ServiceInstance)
UpdateService updates service instances (simulates Consul watch)
func (*ConsulDiscovery) Watch ¶
func (d *ConsulDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
Watch watches for service changes in Consul
type ConsulDiscoveryConfig ¶
ConsulDiscoveryConfig configures Consul-based discovery
type Content ¶
type Content struct {
Type string `json:"type"` // "text", "image", "resource"
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
}
Content represents tool result content
type DNSDiscovery ¶
type DNSDiscovery struct {
// contains filtered or unexported fields
}
DNSDiscovery implements ServiceDiscovery using DNS SRV records
func NewDNSDiscovery ¶
func NewDNSDiscovery(config DNSDiscoveryConfig) *DNSDiscovery
NewDNSDiscovery creates a new DNS-based service discovery
func (*DNSDiscovery) Deregister ¶
func (d *DNSDiscovery) Deregister(ctx context.Context, instanceID string) error
Deregister is not supported for DNS discovery
func (*DNSDiscovery) Discover ¶
func (d *DNSDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
Discover looks up SRV records for the service
func (*DNSDiscovery) Register ¶
func (d *DNSDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
Register is not supported for DNS discovery
func (*DNSDiscovery) Watch ¶
func (d *DNSDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
Watch polls DNS at intervals for changes
type DNSDiscoveryConfig ¶
DNSDiscoveryConfig configures DNS-based discovery
type GRPCServer ¶
type GRPCServer struct {
pb.UnimplementedMCPServiceServer
// contains filtered or unexported fields
}
GRPCServer wraps an MCP server for gRPC serving
func NewGRPCServer ¶
func NewGRPCServer(mcpServer *Server, tlsConfig *TLSConfig) (*GRPCServer, error)
NewGRPCServer creates a new gRPC server wrapper
func (*GRPCServer) Address ¶
func (s *GRPCServer) Address() string
Address returns the server's listening address
func (*GRPCServer) CallTool ¶
func (s *GRPCServer) CallTool(ctx context.Context, req *pb.CallToolRequest) (*pb.CallToolResponse, error)
CallTool implements the CallTool RPC
func (*GRPCServer) ForceStop ¶
func (s *GRPCServer) ForceStop()
ForceStop immediately stops the gRPC server
func (*GRPCServer) Initialize ¶
func (s *GRPCServer) Initialize(ctx context.Context, req *pb.InitializeRequest) (*pb.InitializeResponse, error)
Initialize implements the Initialize RPC
func (*GRPCServer) ListTools ¶
func (s *GRPCServer) ListTools(ctx context.Context, req *pb.ListToolsRequest) (*pb.ListToolsResponse, error)
ListTools implements the ListTools RPC
func (*GRPCServer) Ping ¶
func (s *GRPCServer) Ping(ctx context.Context, req *pb.PingRequest) (*pb.PingResponse, error)
Ping implements the Ping RPC
func (*GRPCServer) Serve ¶
func (s *GRPCServer) Serve(address string) error
Serve starts the gRPC server on the given address
func (*GRPCServer) StreamCallTool ¶
func (s *GRPCServer) StreamCallTool(req *pb.CallToolRequest, stream grpc.ServerStreamingServer[pb.CallToolResponse]) error
StreamCallTool implements the StreamCallTool RPC
type GRPCTransport ¶
type GRPCTransport struct {
// contains filtered or unexported fields
}
GRPCTransport implements Transport for gRPC communication
func NewGRPCTransportWithConfig ¶
func NewGRPCTransportWithConfig(config GRPCTransportConfig) (*GRPCTransport, error)
NewGRPCTransportWithConfig creates a new gRPC transport with detailed config
func (*GRPCTransport) Close ¶
func (t *GRPCTransport) Close() error
Close closes the gRPC connection
func (*GRPCTransport) Connect ¶
func (t *GRPCTransport) Connect(ctx context.Context) error
Connect establishes the gRPC connection
func (*GRPCTransport) IsConnected ¶
func (t *GRPCTransport) IsConnected() bool
IsConnected returns whether the transport is connected
func (*GRPCTransport) Receive ¶
func (t *GRPCTransport) Receive() ([]byte, error)
Receive reads a message from the transport
func (*GRPCTransport) StreamCallTool ¶
func (t *GRPCTransport) StreamCallTool(ctx context.Context, name string, args map[string]any) (<-chan *CallToolResult, <-chan error)
StreamCallTool executes a tool with streaming response
type GRPCTransportConfig ¶
GRPCTransportConfig holds gRPC transport configuration
type KubernetesDiscovery ¶
type KubernetesDiscovery struct {
// contains filtered or unexported fields
}
KubernetesDiscovery implements ServiceDiscovery using Kubernetes endpoints API
func NewKubernetesDiscovery ¶
func NewKubernetesDiscovery(config KubernetesDiscoveryConfig) *KubernetesDiscovery
NewKubernetesDiscovery creates a new Kubernetes-based service discovery
func (*KubernetesDiscovery) Close ¶
func (d *KubernetesDiscovery) Close() error
Close cleans up resources
func (*KubernetesDiscovery) Deregister ¶
func (d *KubernetesDiscovery) Deregister(ctx context.Context, instanceID string) error
Deregister removes an endpoint
func (*KubernetesDiscovery) Discover ¶
func (d *KubernetesDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
Discover returns instances from Kubernetes endpoints Note: In production, this would use the Kubernetes client-go library
func (*KubernetesDiscovery) Register ¶
func (d *KubernetesDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
Register adds an endpoint to the service
func (*KubernetesDiscovery) UpdateEndpoints ¶
func (d *KubernetesDiscovery) UpdateEndpoints(serviceName string, instances []*ServiceInstance)
UpdateEndpoints updates the endpoints for a service (simulates k8s watch)
func (*KubernetesDiscovery) Watch ¶
func (d *KubernetesDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
Watch returns a channel for endpoint updates
type KubernetesDiscoveryConfig ¶
KubernetesDiscoveryConfig configures Kubernetes-based discovery
type LoadBalancerStrategy ¶
type LoadBalancerStrategy string
LoadBalancerStrategy defines the load balancing algorithm
const ( RoundRobin LoadBalancerStrategy = "round-robin" LeastConnections LoadBalancerStrategy = "least-connections" Random LoadBalancerStrategy = "random" WeightedRandom LoadBalancerStrategy = "weighted-random" )
type LocalTransport ¶
type LocalTransport struct {
// contains filtered or unexported fields
}
LocalTransport implements in-process MCP communication
func NewLocalTransport ¶
func NewLocalTransport(serverName string) (*LocalTransport, error)
NewLocalTransport creates a new local transport
type Schema ¶
type Schema map[string]SchemaField
Schema represents a JSON Schema for tool input validation
func (Schema) ValidateArgs ¶
ValidateSchema validates arguments against the tool's schema
type SchemaField ¶
type SchemaField struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Default any `json:"default,omitempty"`
Pattern string `json:"pattern,omitempty"` // Regex pattern for strings
MaxLength int `json:"maxLength,omitempty"` // Max length for strings
MinLength int `json:"minLength,omitempty"` // Min length for strings
Enum []any `json:"enum,omitempty"` // Allowed values
Minimum *float64 `json:"minimum,omitempty"` // Minimum for numbers
Maximum *float64 `json:"maximum,omitempty"` // Maximum for numbers
}
SchemaField represents a single field in the schema
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an MCP server that hosts tools
func NewServer ¶
func NewServer(name string, opts ...ServerOption) *Server
NewServer creates a new MCP server with options
func (*Server) CallTool ¶
func (s *Server) CallTool(ctx context.Context, params CallToolParams) (*CallToolResult, error)
CallTool executes a tool by name with full security checks
func (*Server) GetAuthExtractor ¶
func (s *Server) GetAuthExtractor() security.AuthExtractor
GetAuthExtractor returns the configured auth extractor This is useful for HTTP middleware that needs to extract auth from requests
func (*Server) GetSecurityConfig ¶
func (s *Server) GetSecurityConfig() *security.SecurityConfig
GetSecurityConfig returns the security configuration
func (*Server) RegisterTool ¶
RegisterTool registers a tool with the server
func (*Server) RegisterTypedTool ¶
RegisterTypedTool registers a TypedTool with the server
type ServerConfig ¶
type ServerConfig struct {
Name string
Transport string // "local" or "grpc"
Address string
TLS bool
Auth *AuthConfig
}
ServerConfig represents MCP server configuration
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is a functional option for configuring the server
func WithAuditLogger ¶
func WithAuditLogger(logger security.AuditLogger) ServerOption
WithAuditLogger sets the audit logger
func WithAuthenticator ¶
func WithAuthenticator(auth security.Authenticator) ServerOption
WithAuthenticator sets the authenticator
func WithAuthorizer ¶
func WithAuthorizer(authz security.Authorizer) ServerOption
WithAuthorizer sets the authorizer
func WithDebugMode ¶
func WithDebugMode(debug bool) ServerOption
WithDebugMode enables debug mode (exposes internal errors)
func WithIntegratedAuditLogger ¶
func WithIntegratedAuditLogger(logger *security.IntegratedAuditLogger) ServerOption
WithIntegratedAuditLogger sets the integrated audit logger with middleware support
func WithRateLimit ¶
func WithRateLimit(requestsPerSecond float64, burst int) ServerOption
WithRateLimit sets rate limiting
func WithSecurityConfig ¶
func WithSecurityConfig(config *security.SecurityConfig) ServerOption
WithSecurityConfig sets the security configuration
type ServiceDiscovery ¶
type ServiceDiscovery interface {
// Discover returns available service instances
Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
// Register registers a service instance (for dynamic discovery)
Register(ctx context.Context, instance *ServiceInstance) error
// Deregister removes a service instance
Deregister(ctx context.Context, instanceID string) error
// Watch returns a channel that emits updates when services change
Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
// Close cleans up resources
Close() error
}
ServiceDiscovery defines the interface for service discovery implementations
type ServiceInstance ¶
type ServiceInstance struct {
ID string `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Port int `json:"port"`
Metadata map[string]string `json:"metadata,omitempty"`
Healthy bool `json:"healthy"`
Weight int `json:"weight,omitempty"`
}
ServiceInstance represents a discovered service instance
func (*ServiceInstance) Endpoint ¶
func (s *ServiceInstance) Endpoint() string
Endpoint returns the full address:port string
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a connection to an MCP server
func (*Session) CallTool ¶
func (s *Session) CallTool(ctx context.Context, params CallToolParams) (*CallToolResult, error)
CallTool executes a tool on the server
type StaticDiscovery ¶
type StaticDiscovery struct {
// contains filtered or unexported fields
}
StaticDiscovery implements ServiceDiscovery with a static list of addresses
func NewStaticDiscovery ¶
func NewStaticDiscovery(services map[string][]string) *StaticDiscovery
NewStaticDiscovery creates a new static discovery with the given addresses
func (*StaticDiscovery) Deregister ¶
func (d *StaticDiscovery) Deregister(ctx context.Context, instanceID string) error
Deregister removes a service instance
func (*StaticDiscovery) Discover ¶
func (d *StaticDiscovery) Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
Discover returns all configured instances for a service
func (*StaticDiscovery) Register ¶
func (d *StaticDiscovery) Register(ctx context.Context, instance *ServiceInstance) error
Register adds a service instance (static discovery supports dynamic registration)
func (*StaticDiscovery) SetHealthy ¶
func (d *StaticDiscovery) SetHealthy(instanceID string, healthy bool)
SetHealthy updates the health status of an instance
func (*StaticDiscovery) Watch ¶
func (d *StaticDiscovery) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
Watch returns a channel for service updates (static discovery returns closed channel)
type TLSConfig ¶
type TLSConfig struct {
Enabled bool
CertFile string
KeyFile string
CAFile string
InsecureSkipVerify bool
ServerName string
ClientAuth tls.ClientAuthType
}
TLSConfig holds TLS configuration for gRPC
func CreateInsecureTLSConfig ¶
CreateInsecureTLSConfig creates a TLS config for development (skip verification).
SECURITY WARNING: This function creates a TLS configuration that disables certificate verification. This makes the connection vulnerable to man-in-the-middle attacks. NEVER use this in production environments. This is intended ONLY for local development and testing purposes.
This function will return an error if called in a production environment.
func CreateSecureTLSConfig ¶
CreateSecureTLSConfig creates a secure TLS configuration with best practices
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Handler ToolHandler `json:"-"`
Schema Schema `json:"input_schema"`
RequiredPermission security.Permission `json:"-"` // Required permission to execute this tool
AllowedRoles []string `json:"-"` // Allowed roles to execute this tool
}
Tool represents an MCP tool definition
type ToolHandler ¶
ToolHandler is the function signature for tool handlers
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry manages tools across multiple MCP servers
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates a new tool registry
func (*ToolRegistry) GetServer ¶
func (r *ToolRegistry) GetServer(toolName string) string
GetServer returns the server name that hosts a tool
func (*ToolRegistry) GetTool ¶
func (r *ToolRegistry) GetTool(name string) (Tool, error)
GetTool retrieves a tool by name
func (*ToolRegistry) HasTool ¶
func (r *ToolRegistry) HasTool(name string) bool
HasTool checks if a tool is registered
func (*ToolRegistry) ListTools ¶
func (r *ToolRegistry) ListTools() []Tool
ListTools returns all registered tools
func (*ToolRegistry) Register ¶
func (r *ToolRegistry) Register(serverName string, tools []Tool) error
Register registers tools from a server with collision detection
func (*ToolRegistry) RegisterWithOverride ¶
func (r *ToolRegistry) RegisterWithOverride(serverName string, tools []Tool)
RegisterWithOverride registers tools from a server, overriding existing tools (use with caution)
type Transport ¶
type Transport interface {
Send(ctx context.Context, method string, params any) (any, error)
Close() error
}
Transport defines the interface for MCP communication
func NewGRPCTransport ¶
func NewGRPCTransport(config ServerConfig) (Transport, error)
NewGRPCTransport creates a new gRPC client transport
type TypedTool ¶
type TypedTool[I, O any] struct { // contains filtered or unexported fields }
TypedTool provides compile-time type safety for MCP tools
func NewTypedTool ¶
func NewTypedTool[I, O any]( name string, description string, handler func(context.Context, I) (O, error), ) *TypedTool[I, O]
NewTypedTool creates a new type-safe tool with auto-generated schema
func (*TypedTool[I, O]) Description ¶
Description returns the tool description