Documentation
¶
Overview ¶
Package mcpserver implements the MCP server functionality.
Index ¶
- Variables
- func RegisterSkillResources(rm resource.ManagerInterface, sm *skill.Manager) error
- type LazyLogResult
- type LazyRedact
- type MCPSession
- type MethodHandler
- type NoOpPromptManager
- func (m *NoOpPromptManager) AddPrompt(_ prompt.Prompt)
- func (m *NoOpPromptManager) ClearPromptsForService(_ string)
- func (m *NoOpPromptManager) GetPrompt(_ string) (prompt.Prompt, bool)
- func (m *NoOpPromptManager) ListPrompts() []prompt.Prompt
- func (m *NoOpPromptManager) SetMCPServer(_ prompt.MCPServerProvider)
- func (m *NoOpPromptManager) UpdatePrompt(_ prompt.Prompt)
- type NoOpResourceManager
- func (m *NoOpResourceManager) AddResource(_ resource.Resource)
- func (m *NoOpResourceManager) ClearResourcesForService(_ string)
- func (m *NoOpResourceManager) GetResource(_ string) (resource.Resource, bool)
- func (m *NoOpResourceManager) ListResources() []resource.Resource
- func (m *NoOpResourceManager) OnListChanged(_ func())
- func (m *NoOpResourceManager) RemoveResource(_ string)
- type NoOpToolManager
- func (m *NoOpToolManager) AddMiddleware(_ tool.ExecutionMiddleware)
- func (m *NoOpToolManager) AddServiceInfo(_ string, _ *tool.ServiceInfo)
- func (m *NoOpToolManager) AddTool(_ tool.Tool) error
- func (m *NoOpToolManager) ClearToolsForService(_ string)
- func (m *NoOpToolManager) ExecuteTool(_ context.Context, _ *tool.ExecutionRequest) (any, error)
- func (m *NoOpToolManager) GetAllowedServiceIDs(_ string) (map[string]bool, bool)
- func (m *NoOpToolManager) GetServiceInfo(_ string) (*tool.ServiceInfo, bool)
- func (m *NoOpToolManager) GetTool(_ string) (tool.Tool, bool)
- func (m *NoOpToolManager) GetToolCountForService(_ string) int
- func (m *NoOpToolManager) IsServiceAllowed(_, _ string) bool
- func (m *NoOpToolManager) ListMCPTools() []*mcp.Tool
- func (m *NoOpToolManager) ListServices() []*tool.ServiceInfo
- func (m *NoOpToolManager) ListTools() []tool.Tool
- func (m *NoOpToolManager) SetMCPServer(_ tool.MCPServerProvider)
- func (m *NoOpToolManager) SetProfiles(_ []string, _ []*configv1.ProfileDefinition)
- func (m *NoOpToolManager) ToolMatchesProfile(_ tool.Tool, _ string) bool
- type RegistrationServer
- func (s *RegistrationServer) GetService(ctx context.Context, req *v1.GetServiceRequest) (*v1.GetServiceResponse, error)
- func (s *RegistrationServer) GetServiceStatus(_ context.Context, _ *v1.GetServiceStatusRequest) (*v1.GetServiceStatusResponse, error)
- func (s *RegistrationServer) InitiateOAuth2Flow(ctx context.Context, req *v1.InitiateOAuth2FlowRequest) (*v1.InitiateOAuth2FlowResponse, error)
- func (s *RegistrationServer) ListServices(ctx context.Context, _ *v1.ListServicesRequest) (*v1.ListServicesResponse, error)
- func (s *RegistrationServer) RegisterService(ctx context.Context, req *v1.RegisterServiceRequest) (*v1.RegisterServiceResponse, error)
- func (s *RegistrationServer) RegisterTools(_ context.Context, _ *v1.RegisterToolsRequest) (*v1.RegisterToolsResponse, error)
- func (s *RegistrationServer) UnregisterService(_ context.Context, _ *v1.UnregisterServiceRequest) (*v1.UnregisterServiceResponse, error)
- func (s *RegistrationServer) ValidateService(ctx context.Context, req *v1.ValidateServiceRequest) (*v1.ValidateServiceResponse, error)
- type RootsTool
- func (t *RootsTool) Execute(ctx context.Context, _ *tool.ExecutionRequest) (any, error)
- func (t *RootsTool) GetCacheConfig() *configv1.CacheConfig
- func (t *RootsTool) IsStreaming() bool
- func (t *RootsTool) MCPTool() *mcp.Tool
- func (t *RootsTool) StreamExecute(ctx context.Context, req *tool.ExecutionRequest) (<-chan any, error)
- func (t *RootsTool) Tool() *v1.Tool
- type Router
- type Server
- func (s *Server) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
- func (s *Server) AddTool(t tool.Tool) error
- func (s *Server) AuthManager() *auth.Manager
- func (s *Server) CallTool(ctx context.Context, req *tool.ExecutionRequest) (any, error)
- func (s *Server) ClearToolsForService(serviceKey string)
- func (s *Server) CreateMessage(ctx context.Context, params *mcp.CreateMessageParams) (*mcp.CreateMessageResult, error)
- func (s *Server) GetPrompt(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
- func (s *Server) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
- func (s *Server) GetTool(toolName string) (tool.Tool, bool)
- func (s *Server) ListPrompts(_ context.Context, _ *mcp.ListPromptsRequest) (*mcp.ListPromptsResult, error)
- func (s *Server) ListResources(_ context.Context, _ *mcp.ListResourcesRequest) (*mcp.ListResourcesResult, error)
- func (s *Server) ListTools() []tool.Tool
- func (s *Server) PromptManager() prompt.ManagerInterface
- func (s *Server) ReadResource(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
- func (s *Server) Reload(ctx context.Context) error
- func (s *Server) ResourceManager() resource.ManagerInterface
- func (s *Server) Server() *mcp.Server
- func (s *Server) ServiceRegistry() *serviceregistry.ServiceRegistry
- func (s *Server) SetMCPServer(mcpServer tool.MCPServerProvider)
- func (s *Server) SetReloadFunc(f func(context.Context) error)
- func (s *Server) ToolManager() tool.ManagerInterface
- type SkillResource
- func (r *SkillResource) Name() string
- func (r *SkillResource) Read(_ context.Context) (*mcp.ReadResourceResult, error)
- func (r *SkillResource) Resource() *mcp.Resource
- func (r *SkillResource) Service() string
- func (r *SkillResource) Subscribe(_ context.Context) error
- func (r *SkillResource) URI() string
- type TemporaryToolManager
- func (m *TemporaryToolManager) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
- func (m *TemporaryToolManager) AddTool(t tool.Tool) error
- func (m *TemporaryToolManager) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
- func (m *TemporaryToolManager) GetTool(toolName string) (tool.Tool, bool)
- func (m *TemporaryToolManager) GetToolCountForService(serviceID string) int
- func (m *TemporaryToolManager) ListTools() []tool.Tool
Constants ¶
This section is empty.
Variables ¶
var AddReceivingMiddlewareHook func(name string)
AddReceivingMiddlewareHook is a testing hook that allows inspection of the middleware chain.
It is invoked when the Server method is called, allowing tests to verify which middlewares are present.
Side Effects:
- When set, this function is called synchronously during Server() access.
Summary: Represents a AddReceivingMiddlewareHook.
var NewRegistrationServerHook func(bus interface{}, authManager interface{}) (*RegistrationServer, error)
NewRegistrationServerHook is a test hook for overriding the creation of a RegistrationServer.
Summary: Test hook to override RegistrationServer creation.
Side Effects:
- If set, this hook is called instead of the standard constructor logic.
Functions ¶
func RegisterSkillResources ¶
func RegisterSkillResources(rm resource.ManagerInterface, sm *skill.Manager) error
RegisterSkillResources registers all skills from the manager into the resource manager.
It iterates through all available skills and registers their documentation (SKILL.md) and associated assets as resources in the provided Resource Manager.
Parameters:
- rm (resource.ManagerInterface): The resource manager to register resources with.
- sm (*skill.Manager): The skill manager to retrieve skills from.
Returns:
- error: An error if listing skills fails.
Side Effects:
- Registers resources with the manager.
Summary: Executes RegisterSkillResources operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
Types ¶
type LazyLogResult ¶
type LazyLogResult struct {
Value any
JSONBytes []byte
IsStructured bool
FinalResult *mcp.CallToolResult
}
LazyLogResult wraps a tool execution result for efficient logging.
It avoids expensive serialization of large payloads (e.g. images, huge text) and lazily computes the string representation only when logging is enabled.
Summary: Represents a LazyLogResult.
func (LazyLogResult) LogValue ¶
func (r LazyLogResult) LogValue() slog.Value
LogValue implements slog.LogValuer.
It returns a summarized or redacted log value.
Returns:
- slog.Value: The log value.
Side Effects:
- May serialize or redact the result value.
Summary: Executes LogValue operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type LazyRedact ¶
type LazyRedact []byte
LazyRedact is a byte slice that implements slog.LogValuer to lazily redact its JSON content only when logged.
Summary: Represents a LazyRedact.
func (LazyRedact) LogValue ¶
func (l LazyRedact) LogValue() slog.Value
LogValue implements slog.LogValuer.
It returns a redacted log value.
Returns:
- slog.Value: The redacted value.
Side Effects:
- Performs JSON redaction on the byte slice.
Summary: Executes LogValue operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type MCPSession ¶
type MCPSession struct {
// contains filtered or unexported fields
}
MCPSession wraps an MCP session to provide client interaction capabilities like sampling and roots.
Summary: Provides a wrapper around the MCP server session to facilitate client interactions.
func NewMCPSampler ¶
func NewMCPSampler(session *mcp.ServerSession) *MCPSession
NewMCPSampler is a deprecated alias for NewMCPSession.
Summary: Creates a new MCPSession (deprecated alias).
Parameters:
- session: *mcp.ServerSession. The underlying MCP server session.
Returns:
- *MCPSession: A new instance of MCPSession.
Side Effects:
- This function is deprecated and should be replaced by NewMCPSession.
func NewMCPSession ¶
func NewMCPSession(session *mcp.ServerSession) *MCPSession
NewMCPSession creates a new MCPSession.
Summary: Initializes a new MCPSession instance.
Parameters:
- session: *mcp.ServerSession. The underlying MCP server session.
Returns:
- *MCPSession: A new instance of MCPSession.
func (*MCPSession) CreateMessage ¶
func (s *MCPSession) CreateMessage(ctx context.Context, params *mcp.CreateMessageParams) (*mcp.CreateMessageResult, error)
CreateMessage requests a message creation from the client (sampling).
Summary: Requests the client to create a message, effectively sampling the LLM.
Parameters:
- ctx: context.Context. The context for the request.
- params: *mcp.CreateMessageParams. The parameters for the message creation request.
Returns:
- *mcp.CreateMessageResult: The result of the message creation from the client.
- error: An error if no active session is available or if the request fails.
Throws/Errors:
- Returns an error if the session is nil.
func (*MCPSession) ListRoots ¶
func (s *MCPSession) ListRoots(ctx context.Context) (*mcp.ListRootsResult, error)
ListRoots requests the list of roots from the client.
Summary: Requests the list of root directories from the client.
Parameters:
- ctx: context.Context. The context for the request.
Returns:
- *mcp.ListRootsResult: The list of roots returned by the client.
- error: An error if no active session is available or if the request fails.
Throws/Errors:
- Returns an error if the session is nil.
type MethodHandler ¶
MethodHandler defines the signature for a function that handles an MCP method call.
Summary: Handler function signature for MCP methods.
Parameters:
- ctx (context.Context): The context for the request.
- req (mcp.Request): The request object.
Returns:
- mcp.Result: The result of the operation.
- error: An error if the operation fails.
type NoOpPromptManager ¶
type NoOpPromptManager struct{}
NoOpPromptManager is a no-op implementation of prompt.ManagerInterface.
Summary: A prompt manager that does nothing.
func (*NoOpPromptManager) AddPrompt ¶
func (m *NoOpPromptManager) AddPrompt(_ prompt.Prompt)
AddPrompt implements prompt.ManagerInterface.
Summary: No-op AddPrompt.
Parameters:
- _ (prompt.Prompt): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpPromptManager) ClearPromptsForService ¶
func (m *NoOpPromptManager) ClearPromptsForService(_ string)
ClearPromptsForService implements prompt.ManagerInterface.
Summary: No-op ClearPromptsForService.
Parameters:
- _ (string): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpPromptManager) GetPrompt ¶
func (m *NoOpPromptManager) GetPrompt(_ string) (prompt.Prompt, bool)
GetPrompt implements prompt.ManagerInterface.
Summary: No-op GetPrompt.
Parameters:
- _ (string): Unused.
Returns:
- prompt.Prompt: Always nil.
- bool: Always false.
func (*NoOpPromptManager) ListPrompts ¶
func (m *NoOpPromptManager) ListPrompts() []prompt.Prompt
ListPrompts implements prompt.ManagerInterface.
Summary: Returns an empty list of prompts.
Parameters:
- None.
Returns:
- []prompt.Prompt: Always nil.
Side Effects:
- None.
func (*NoOpPromptManager) SetMCPServer ¶
func (m *NoOpPromptManager) SetMCPServer(_ prompt.MCPServerProvider)
SetMCPServer implements prompt.ManagerInterface.
Summary: No-op SetMCPServer.
Parameters:
- _ (prompt.MCPServerProvider): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpPromptManager) UpdatePrompt ¶
func (m *NoOpPromptManager) UpdatePrompt(_ prompt.Prompt)
UpdatePrompt implements prompt.ManagerInterface.
Summary: No-op UpdatePrompt.
Parameters:
- _ (prompt.Prompt): Unused.
Returns:
- None.
Side Effects:
- None.
type NoOpResourceManager ¶
type NoOpResourceManager struct{}
NoOpResourceManager is a no-op implementation of resource.ManagerInterface.
Summary: A resource manager that does nothing.
func (*NoOpResourceManager) AddResource ¶
func (m *NoOpResourceManager) AddResource(_ resource.Resource)
AddResource implements resource.ManagerInterface.
Summary: No-op AddResource.
Parameters:
- _ (resource.Resource): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpResourceManager) ClearResourcesForService ¶
func (m *NoOpResourceManager) ClearResourcesForService(_ string)
ClearResourcesForService implements resource.ManagerInterface.
Summary: No-op ClearResourcesForService.
Parameters:
- _ (string): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpResourceManager) GetResource ¶
func (m *NoOpResourceManager) GetResource(_ string) (resource.Resource, bool)
GetResource implements resource.ManagerInterface.
Summary: No-op GetResource.
Parameters:
- _ (string): Unused.
Returns:
- resource.Resource: Always nil.
- bool: Always false.
func (*NoOpResourceManager) ListResources ¶
func (m *NoOpResourceManager) ListResources() []resource.Resource
ListResources implements resource.ManagerInterface.
Summary: Returns an empty list of resources.
Parameters:
- None.
Returns:
- []resource.Resource: Always nil.
Side Effects:
- None.
func (*NoOpResourceManager) OnListChanged ¶
func (m *NoOpResourceManager) OnListChanged(_ func())
OnListChanged implements resource.ManagerInterface.
Summary: No-op OnListChanged.
Parameters:
- _ (func()): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpResourceManager) RemoveResource ¶
func (m *NoOpResourceManager) RemoveResource(_ string)
RemoveResource implements resource.ManagerInterface.
Summary: No-op RemoveResource.
Parameters:
- _ (string): Unused.
Returns:
- None.
Side Effects:
- None.
type NoOpToolManager ¶
type NoOpToolManager struct{}
NoOpToolManager is a no-op implementation of tool.ManagerInterface.
Summary: A tool manager that does nothing.
func (*NoOpToolManager) AddMiddleware ¶
func (m *NoOpToolManager) AddMiddleware(_ tool.ExecutionMiddleware)
AddMiddleware implements tool.ManagerInterface.
Summary: No-op AddMiddleware.
Parameters:
- _ (tool.ExecutionMiddleware): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpToolManager) AddServiceInfo ¶
func (m *NoOpToolManager) AddServiceInfo(_ string, _ *tool.ServiceInfo)
AddServiceInfo implements tool.ManagerInterface.
Summary: No-op AddServiceInfo.
Parameters:
- _ (string): Unused.
- _ (*tool.ServiceInfo): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpToolManager) AddTool ¶
func (m *NoOpToolManager) AddTool(_ tool.Tool) error
AddTool implements tool.ManagerInterface.
Summary: No-op AddTool.
Parameters:
- _ (tool.Tool): Unused.
Returns:
- error: Always returns nil.
func (*NoOpToolManager) ClearToolsForService ¶
func (m *NoOpToolManager) ClearToolsForService(_ string)
ClearToolsForService implements tool.ManagerInterface.
Summary: No-op ClearToolsForService.
Parameters:
- _ (string): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpToolManager) ExecuteTool ¶
func (m *NoOpToolManager) ExecuteTool(_ context.Context, _ *tool.ExecutionRequest) (any, error)
ExecuteTool implements tool.ManagerInterface.
Summary: No-op ExecuteTool.
Parameters:
- _ (context.Context): Unused.
- _ (*tool.ExecutionRequest): Unused.
Returns:
- any: Always nil.
- error: Always nil.
func (*NoOpToolManager) GetAllowedServiceIDs ¶
func (m *NoOpToolManager) GetAllowedServiceIDs(_ string) (map[string]bool, bool)
GetAllowedServiceIDs implements tool.ManagerInterface.
Summary: No-op GetAllowedServiceIDs.
Parameters:
- _ (string): Unused.
Returns:
- map[string]bool: Always nil.
- bool: Always false.
func (*NoOpToolManager) GetServiceInfo ¶
func (m *NoOpToolManager) GetServiceInfo(_ string) (*tool.ServiceInfo, bool)
GetServiceInfo implements tool.ManagerInterface.
Summary: No-op GetServiceInfo.
Parameters:
- _ (string): Unused.
Returns:
- *tool.ServiceInfo: Always nil.
- bool: Always false.
func (*NoOpToolManager) GetTool ¶
func (m *NoOpToolManager) GetTool(_ string) (tool.Tool, bool)
GetTool implements tool.ManagerInterface.
Summary: No-op GetTool.
Parameters:
- _ (string): Unused.
Returns:
- tool.Tool: Always nil.
- bool: Always false.
func (*NoOpToolManager) GetToolCountForService ¶
func (m *NoOpToolManager) GetToolCountForService(_ string) int
GetToolCountForService implements tool.ManagerInterface.
Summary: No-op GetToolCountForService.
Parameters:
- _ (string): Unused.
Returns:
- int: Always 0.
func (*NoOpToolManager) IsServiceAllowed ¶
func (m *NoOpToolManager) IsServiceAllowed(_, _ string) bool
IsServiceAllowed implements tool.ManagerInterface.
Summary: No-op IsServiceAllowed.
Parameters:
- _, _ (string): Unused.
Returns:
- bool: Always true (allow all).
func (*NoOpToolManager) ListMCPTools ¶
func (m *NoOpToolManager) ListMCPTools() []*mcp.Tool
ListMCPTools implements tool.ManagerInterface.
Summary: Returns an empty list of MCP tools.
Parameters:
- None.
Returns:
- []*mcp.Tool: Always nil.
Side Effects:
- None.
func (*NoOpToolManager) ListServices ¶
func (m *NoOpToolManager) ListServices() []*tool.ServiceInfo
ListServices implements tool.ManagerInterface.
Summary: Returns an empty list of services.
Parameters:
- None.
Returns:
- []*tool.ServiceInfo: Always nil.
Side Effects:
- None.
func (*NoOpToolManager) ListTools ¶
func (m *NoOpToolManager) ListTools() []tool.Tool
ListTools implements tool.ManagerInterface.
Summary: Returns an empty list of tools.
Parameters:
- None.
Returns:
- []tool.Tool: Always nil.
Side Effects:
- None.
func (*NoOpToolManager) SetMCPServer ¶
func (m *NoOpToolManager) SetMCPServer(_ tool.MCPServerProvider)
SetMCPServer implements tool.ManagerInterface.
Summary: No-op SetMCPServer.
Parameters:
- _ (tool.MCPServerProvider): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpToolManager) SetProfiles ¶
func (m *NoOpToolManager) SetProfiles(_ []string, _ []*configv1.ProfileDefinition)
SetProfiles implements tool.ManagerInterface.
Summary: No-op SetProfiles.
Parameters:
- _ ([]string): Unused.
- _ ([]*configv1.ProfileDefinition): Unused.
Returns:
- None.
Side Effects:
- None.
func (*NoOpToolManager) ToolMatchesProfile ¶
func (m *NoOpToolManager) ToolMatchesProfile(_ tool.Tool, _ string) bool
ToolMatchesProfile implements tool.ManagerInterface.
Summary: No-op ToolMatchesProfile.
Parameters:
- _ (tool.Tool): Unused.
- _ (string): Unused.
Returns:
- bool: Always true.
type RegistrationServer ¶
type RegistrationServer struct {
v1.UnimplementedRegistrationServiceServer
// contains filtered or unexported fields
}
RegistrationServer implements the gRPC server for service registration.
Summary: Handles gRPC requests for registering and managing upstream services.
Side Effects:
- Publishes messages to the event bus.
- Interacts with the authentication manager.
func NewRegistrationServer ¶
func NewRegistrationServer(bus *bus.Provider, authManager *auth.Manager) (*RegistrationServer, error)
NewRegistrationServer creates a new RegistrationServer initialized with the event bus and auth manager.
Summary: Initializes a new RegistrationServer instance.
Parameters:
- bus: *bus.Provider. The event bus used for communication with workers.
- authManager: *auth.Manager. Manager for handling authentication and OAuth flows.
Returns:
- *RegistrationServer: A new instance of the RegistrationServer.
- error: An error if the bus is nil.
Throws/Errors:
- Returns an error if the bus is nil.
func (*RegistrationServer) GetService ¶
func (s *RegistrationServer) GetService(ctx context.Context, req *v1.GetServiceRequest) (*v1.GetServiceResponse, error)
GetService retrieves a service by its name.
Summary: Retrieves the configuration of a registered service.
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.GetServiceRequest. The request containing the service name.
Returns:
- *v1.GetServiceResponse: The response containing the service configuration.
- error: An error if the service is not found or other error.
Throws/Errors:
- codes.InvalidArgument: If the service name is missing.
- codes.NotFound: If the service is not found.
- codes.DeadlineExceeded: If the request times out.
func (*RegistrationServer) GetServiceStatus ¶
func (s *RegistrationServer) GetServiceStatus(_ context.Context, _ *v1.GetServiceStatusRequest) (*v1.GetServiceStatusResponse, error)
GetServiceStatus is not yet implemented.
Summary: Retrieves the status of a service (Not Implemented).
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.GetServiceStatusRequest. The request containing the service name or ID.
Returns:
- *v1.GetServiceStatusResponse: The response with the service status.
- error: Always returns an Unimplemented error.
func (*RegistrationServer) InitiateOAuth2Flow ¶
func (s *RegistrationServer) InitiateOAuth2Flow(ctx context.Context, req *v1.InitiateOAuth2FlowRequest) (*v1.InitiateOAuth2FlowResponse, error)
InitiateOAuth2Flow initiates an OAuth2 flow for a service or credential.
Summary: Initiates the OAuth2 flow by generating an authorization URL.
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.InitiateOAuth2FlowRequest. The request containing OAuth2 flow details.
Returns:
- *v1.InitiateOAuth2FlowResponse: The response containing the authorization URL and state.
- error: An error if validation fails or flow initiation errors.
Throws/Errors:
- codes.InvalidArgument: If required parameters are missing.
- codes.Unauthenticated: If the user is not authenticated.
- codes.Internal: If an internal error occurs.
func (*RegistrationServer) ListServices ¶
func (s *RegistrationServer) ListServices(ctx context.Context, _ *v1.ListServicesRequest) (*v1.ListServicesResponse, error)
ListServices lists all registered services by querying the service registry via the event bus.
Summary: Lists all currently registered services.
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.ListServicesRequest. The request object (empty for now).
Returns:
- *v1.ListServicesResponse: The response containing a list of registered services.
- error: An error if the operation fails or times out.
Throws/Errors:
- codes.DeadlineExceeded: If the request times out.
- codes.Internal: If an internal error occurs.
func (*RegistrationServer) RegisterService ¶
func (s *RegistrationServer) RegisterService(ctx context.Context, req *v1.RegisterServiceRequest) (*v1.RegisterServiceResponse, error)
RegisterService handles a gRPC request to register a new upstream service.
Summary: Asynchronously registers a new upstream service via the event bus.
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.RegisterServiceRequest. The request containing the configuration of the service to be registered.
Returns:
- *v1.RegisterServiceResponse: The response containing the registration status, service key, and discovered tools.
- error: An error if the registration fails, times out, or arguments are invalid.
Side Effects:
- Publishes a registration request to the event bus.
- Waits for a response on a dedicated result channel.
func (*RegistrationServer) RegisterTools ¶
func (s *RegistrationServer) RegisterTools(_ context.Context, _ *v1.RegisterToolsRequest) (*v1.RegisterToolsResponse, error)
RegisterTools is not yet implemented.
Summary: Registers tools for a service (Not Implemented).
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.RegisterToolsRequest. The request containing the tools to register.
Returns:
- *v1.RegisterToolsResponse: A response indicating success or failure.
- error: Always returns an Unimplemented error.
func (*RegistrationServer) UnregisterService ¶
func (s *RegistrationServer) UnregisterService(_ context.Context, _ *v1.UnregisterServiceRequest) (*v1.UnregisterServiceResponse, error)
UnregisterService is not yet implemented.
Summary: Handles the unregistration of a service (Not Implemented).
Parameters:
- ctx: context.Context. The context for the gRPC call.
- req: *v1.UnregisterServiceRequest. The request containing the service ID to unregister.
Returns:
- *v1.UnregisterServiceResponse: The response indicating success or failure.
- error: Always returns an Unimplemented error.
func (*RegistrationServer) ValidateService ¶
func (s *RegistrationServer) ValidateService(ctx context.Context, req *v1.ValidateServiceRequest) (*v1.ValidateServiceResponse, error)
ValidateService validates a service configuration by attempting to connect and discover tools.
Summary: Validates the provided service configuration by connecting to the upstream service.
Parameters:
- ctx: context.Context. The context for the request.
- req: *v1.ValidateServiceRequest. The validation request containing the service configuration.
Returns:
- *v1.ValidateServiceResponse: The response containing validation results, discovered tools, and resources.
- error: An error if the validation request itself is invalid (e.g. missing config).
Side Effects:
- Temporarily creates an upstream connection and then closes it.
type RootsTool ¶
type RootsTool struct {
// contains filtered or unexported fields
}
RootsTool implements the Tool interface for listing roots.
It provides a built-in tool ("mcp:list_roots") that allows the server to query the client for available filesystem roots.
Summary: Represents a RootsTool.
func NewRootsTool ¶
func NewRootsTool() *RootsTool
NewRootsTool creates a new instance of the RootsTool.
Returns:
- *RootsTool: A new instance of RootsTool.
Side Effects:
- None.
Summary: Initializes NewRootsTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*RootsTool) Execute ¶
Execute executes the tool.
Summary: Executes the "mcp:list_roots" tool.
Parameters:
- ctx (context.Context): The context for execution, containing an active MCP session.
- _ (*tool.ExecutionRequest): The execution request parameters (unused).
Returns:
- any: The result of listing roots.
- error: An error if the session is missing or the list operation fails.
Errors:
- Returns error if the active session is missing.
- Returns error if listing roots fails.
Side Effects:
- Sends a "roots/list" request to the client.
func (*RootsTool) GetCacheConfig ¶
func (t *RootsTool) GetCacheConfig() *configv1.CacheConfig
GetCacheConfig returns the caching configuration for this tool.
Returns:
- *configv1.CacheConfig: Always nil (caching disabled).
Side Effects:
- None.
Summary: Retrieves GetCacheConfig operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*RootsTool) IsStreaming ¶
IsStreaming indicates whether this tool supports streaming execution.
Summary: Checks if the RootsTool supports streaming.
Parameters:
- None.
Returns:
- bool: Always false for this tool.
Errors:
- None.
Side Effects:
- None.
func (*RootsTool) MCPTool ¶
MCPTool returns the MCP-compliant tool definition.
Returns:
- *mcp.Tool: The MCP tool definition.
Side Effects:
- None.
Summary: Executes MCPTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*RootsTool) StreamExecute ¶
func (t *RootsTool) StreamExecute(ctx context.Context, req *tool.ExecutionRequest) (<-chan any, error)
StreamExecute executes the tool in a streaming context.
Summary: Executes the tool in a streaming context.
Parameters:
- ctx (context.Context): The context for execution.
- req (*tool.ExecutionRequest): The execution request parameters.
Returns:
- <-chan any: Always nil for this tool.
- error: Always nil for this tool.
Errors:
- None.
Side Effects:
- None.
func (*RootsTool) Tool ¶
Tool returns the protobuf definition of the tool.
Returns:
- *v1.Tool: The protobuf tool definition.
Side Effects:
- None.
Summary: Executes Tool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is responsible for mapping MCP method names to their corresponding handler functions.
Summary: Routes MCP requests to registered handlers.
Side Effects:
- Stores handlers in an internal map.
func NewRouter ¶
func NewRouter() *Router
NewRouter creates and returns a new, empty Router.
Summary: Creates a new Router instance.
Parameters:
- None.
Returns:
- *Router: A new, initialized Router.
Side Effects:
- Allocates memory for the Router and its handler map.
func (*Router) GetHandler ¶
func (r *Router) GetHandler(method string) (MethodHandler, bool)
GetHandler retrieves the handler function for a given MCP method name.
Summary: Retrieves a handler for an MCP method.
Parameters:
- method (string): The name of the MCP method.
Returns:
- MethodHandler: The handler function if found.
- bool: A boolean indicating whether a handler was found (true) or not (false).
Side Effects:
- None.
func (*Router) Register ¶
func (r *Router) Register(method string, handler MethodHandler)
Register associates a handler function with a specific MCP method name.
Summary: Registers a handler for an MCP method.
Parameters:
- method (string): The method name.
- handler (MethodHandler): The handler function.
Returns:
- None.
Side Effects:
- Updates the internal handler map.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the core of the MCP Any application.
It orchestrates the handling of MCP (Model Context Protocol) requests by managing various components such as tools, prompts, resources, and services. It uses an internal router to delegate requests to the appropriate handlers and communicates with backend workers via an event bus.
Summary: Represents a Server.
func NewServer ¶
func NewServer( _ context.Context, toolManager tool.ManagerInterface, promptManager prompt.ManagerInterface, resourceManager resource.ManagerInterface, authManager *auth.Manager, serviceRegistry *serviceregistry.ServiceRegistry, catalogManager *catalog.Manager, bus *bus.Provider, debug bool, ) (*Server, error)
NewServer creates and initializes a new MCP Any Server.
It sets up the necessary managers for tools, prompts, and resources, configures the router with handlers for standard MCP methods, and establishes middleware for request processing, such as routing and tool list filtering.
Parameters:
- ctx (context.Context): The application's root context.
- toolManager (tool.ManagerInterface): Manages the lifecycle and access to tools.
- promptManager (prompt.ManagerInterface): Manages the lifecycle and access to prompts.
- resourceManager (resource.ManagerInterface): Manages the lifecycle and access to resources.
- authManager (*auth.Manager): Handles authentication for incoming requests.
- serviceRegistry (*serviceregistry.ServiceRegistry): Keeps track of all registered upstream services.
- catalogManager (*catalog.Manager): Manages the dynamic service catalog.
- bus (*bus.Provider): The event bus used for asynchronous communication between components.
- debug (bool): Whether to enable debug mode.
Returns:
- *Server: A new instance of the Server.
- error: An error if initialization fails.
Side Effects:
- Registers HTTP handlers.
- Registers built-in tools.
- Registers middleware.
Summary: Initializes NewServer operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) AddServiceInfo ¶
func (s *Server) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
AddServiceInfo adds information about a service to the tool manager.
Parameters:
- serviceID (string): The unique identifier of the service.
- info (*tool.ServiceInfo): The service information to add.
Side Effects:
- Updates the tool manager with service information.
Summary: Executes AddServiceInfo operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) AddTool ¶
AddTool registers a new tool with the tool manager.
Parameters:
- t (tool.Tool): The tool instance to register.
Returns:
- error: An error if the tool cannot be added (e.g., if it already exists).
Side Effects:
- Adds the tool to the tool manager.
Summary: Executes AddTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) AuthManager ¶
AuthManager returns the server's authentication manager.
It provides access to the authentication manager, which is responsible for handling authentication for incoming requests.
Returns:
- *auth.Manager: The authentication manager instance.
Side Effects:
- None.
Summary: Executes AuthManager operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) CallTool ¶
CallTool executes a tool with the provided request.
It handles the execution of the tool, including logging, metrics collection, and profile-based access control.
Parameters:
- ctx (context.Context): The context for the execution.
- req (*tool.ExecutionRequest): The execution request containing tool name and arguments.
Returns:
- any: The result of the tool execution.
- error: An error if the tool execution fails or access is denied.
Side Effects:
- Executes the tool (which may have side effects).
- Logs execution details.
- Updates metrics.
Summary: Executes CallTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ClearToolsForService ¶
ClearToolsForService removes all tools associated with a specific service.
Parameters:
- serviceKey (string): The identifier of the service whose tools should be cleared.
Side Effects:
- Removes tools associated with the service from the tool manager.
Summary: Executes ClearToolsForService operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) CreateMessage ¶
func (s *Server) CreateMessage(ctx context.Context, params *mcp.CreateMessageParams) (*mcp.CreateMessageResult, error)
CreateMessage requests a message creation from the client (sampling).
This method exposes sampling to the Server instance if a session is available.
Parameters:
- ctx (context.Context): The context for the request.
- params (*mcp.CreateMessageParams): The parameters for the message creation.
Returns:
- *mcp.CreateMessageResult: The result of the message creation.
- error: An error if no active session is found in context or if the operation fails.
Side Effects:
- Sends a message creation request to the client.
Summary: Initializes CreateMessage operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) GetPrompt ¶
func (s *Server) GetPrompt( ctx context.Context, req *mcp.GetPromptRequest, ) (*mcp.GetPromptResult, error)
GetPrompt handles the "prompts/get" MCP request.
It retrieves a specific prompt by name from the PromptManager and executes it with the provided arguments, returning the result.
Parameters:
- ctx (context.Context): The context for the request.
- req (*mcp.GetPromptRequest): The "prompts/get" request from the client, containing the prompt name and arguments.
Returns:
- *mcp.GetPromptResult: The result of the prompt execution.
- error: An error if the prompt is not found or execution fails.
Errors:
- prompt.ErrPromptNotFound: If the requested prompt does not exist.
Side Effects:
- None.
Summary: Retrieves GetPrompt operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) GetServiceInfo ¶
func (s *Server) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
GetServiceInfo retrieves information about a service by its ID.
Parameters:
- serviceID (string): The unique identifier of the service.
Returns:
- *tool.ServiceInfo: A pointer to the ServiceInfo if found.
- bool: A boolean indicating whether the service was found.
Side Effects:
- None.
Summary: Retrieves GetServiceInfo operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) GetTool ¶
GetTool retrieves a tool by its name.
Parameters:
- toolName (string): The name of the tool to retrieve.
Returns:
- tool.Tool: The tool instance if found.
- bool: A boolean indicating whether the tool was found.
Side Effects:
- None.
Summary: Retrieves GetTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ListPrompts ¶
func (s *Server) ListPrompts( _ context.Context, _ *mcp.ListPromptsRequest, ) (*mcp.ListPromptsResult, error)
ListPrompts handles the "prompts/list" MCP request.
It retrieves the list of available prompts from the PromptManager, converts them to the MCP format, and returns them to the client.
Parameters:
- ctx (context.Context): The context for the request.
- req (*mcp.ListPromptsRequest): The "prompts/list" request from the client.
Returns:
- *mcp.ListPromptsResult: A list of available prompts.
- error: An error if the retrieval fails.
Side Effects:
- None.
Summary: Executes ListPrompts operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ListResources ¶
func (s *Server) ListResources( _ context.Context, _ *mcp.ListResourcesRequest, ) (*mcp.ListResourcesResult, error)
ListResources handles the "resources/list" MCP request.
It fetches the list of available resources from the ResourceManager, converts them to the MCP format, and returns them to the client.
Parameters:
- ctx (context.Context): The context for the request.
- req (*mcp.ListResourcesRequest): The "resources/list" request from the client.
Returns:
- *mcp.ListResourcesResult: A list of available resources.
- error: An error if the retrieval fails.
Side Effects:
- None.
Summary: Executes ListResources operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ListTools ¶
ListTools returns a list of all available tools.
Returns:
- []tool.Tool: A slice of all available tools.
Side Effects:
- Logs the listing action.
- Increments metrics counter.
Summary: Executes ListTools operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) PromptManager ¶
func (s *Server) PromptManager() prompt.ManagerInterface
PromptManager returns the server's prompt manager.
It provides access to the prompt manager, which is responsible for managing the lifecycle and access to prompts.
Returns:
- prompt.ManagerInterface: The prompt manager interface.
Side Effects:
- None.
Summary: Executes PromptManager operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ReadResource ¶
func (s *Server) ReadResource( ctx context.Context, req *mcp.ReadResourceRequest, ) (*mcp.ReadResourceResult, error)
ReadResource handles the "resources/read" MCP request.
It retrieves a specific resource by its URI from the ResourceManager and returns its content.
Parameters:
- ctx (context.Context): The context for the request.
- req (*mcp.ReadResourceRequest): The "resources/read" request from the client, containing the URI of the resource.
Returns:
- *mcp.ReadResourceResult: The content of the resource.
- error: An error if the resource is not found or reading fails.
Errors:
- resource.ErrResourceNotFound: If the requested resource does not exist.
Side Effects:
- Reads the resource content (may involve I/O).
Summary: Retrieves ReadResource operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) Reload ¶
Reload reloads the server's configuration and updates its state.
Parameters:
- ctx (context.Context): The context for the reload operation.
Returns:
- error: An error if the reload function fails.
Side Effects:
- Executes the reload callback if set.
Summary: Executes Reload operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ResourceManager ¶
func (s *Server) ResourceManager() resource.ManagerInterface
ResourceManager returns the server's resource manager.
It provides access to the resource manager, which is responsible for managing the lifecycle and access to resources.
Returns:
- resource.ManagerInterface: The resource manager interface.
Side Effects:
- None.
Summary: Executes ResourceManager operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) Server ¶
Server returns the underlying *mcp.Server instance.
It provides access to the core MCP server functionality, which can be used for advanced configurations or direct interaction with the MCP server.
Returns:
- *mcp.Server: The underlying server instance.
Side Effects:
- Executes the middleware hook if configured.
Summary: Executes Server operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ServiceRegistry ¶
func (s *Server) ServiceRegistry() *serviceregistry.ServiceRegistry
ServiceRegistry returns the server's service registry.
It provides access to the service registry, which keeps track of all registered upstream services.
Returns:
- *serviceregistry.ServiceRegistry: The service registry instance.
Side Effects:
- None.
Summary: Executes ServiceRegistry operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) SetMCPServer ¶
func (s *Server) SetMCPServer(mcpServer tool.MCPServerProvider)
SetMCPServer sets the MCP server provider for the tool manager.
Parameters:
- mcpServer (tool.MCPServerProvider): The MCP server provider to set.
Side Effects:
- Sets the MCP server provider in the tool manager.
Summary: Updates SetMCPServer operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) SetReloadFunc ¶
SetReloadFunc sets the function to be called when a configuration reload is triggered.
Parameters:
- f (func(context.Context) error): The function to execute on reload.
Side Effects:
- Stores the reload callback.
Summary: Updates SetReloadFunc operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*Server) ToolManager ¶
func (s *Server) ToolManager() tool.ManagerInterface
ToolManager returns the server's tool manager.
It provides access to the tool manager, which is responsible for managing the lifecycle and access to tools.
Returns:
- tool.ManagerInterface: The tool manager interface.
Side Effects:
- None.
Summary: Executes ToolManager operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type SkillResource ¶
type SkillResource struct {
// contains filtered or unexported fields
}
SkillResource adapts a Skill (or its asset) to the Resource interface.
It provides a way to expose skill documentation and associated assets (like images or text files) as MCP resources, making them accessible to clients.
Summary: Represents a SkillResource.
func NewSkillAssetResource ¶
func NewSkillAssetResource(s *skill.Skill, assetPath string) *SkillResource
NewSkillAssetResource creates a new resource for a skill asset.
It wraps a specific asset associated with a skill into a Resource.
Parameters:
- s (*skill.Skill): The skill definition the asset belongs to.
- assetPath (string): The relative path to the asset file within the skill's directory.
Returns:
- *SkillResource: A new instance of SkillResource pointing to the specified asset.
Side Effects:
- None.
Summary: Initializes NewSkillAssetResource operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func NewSkillResource ¶
func NewSkillResource(s *skill.Skill) *SkillResource
NewSkillResource creates a new resource for the main SKILL.md.
It wraps the provided Skill definition into a Resource that serves the skill's documentation file (SKILL.md).
Parameters:
- s (*skill.Skill): The skill definition to expose as a resource.
Returns:
- *SkillResource: A new instance of SkillResource pointing to the skill's documentation.
Side Effects:
- None.
Summary: Initializes NewSkillResource operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) Name ¶
func (r *SkillResource) Name() string
Name returns the human-readable name of the resource.
Returns:
- string: The resource name.
Side Effects:
- None.
Summary: Executes Name operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) Read ¶
func (r *SkillResource) Read(_ context.Context) (*mcp.ReadResourceResult, error)
Read returns the contents of the resource.
It reads the file content from disk, verifying that the path is secure and within the allowed skill directory to prevent path traversal attacks.
Parameters:
- _ (context.Context): Unused in this implementation.
Returns:
- *mcp.ReadResourceResult: The result containing the resource content (text or blob).
- error: An error if the file cannot be read or if the path is invalid.
Side Effects:
- Reads file content from disk.
- Updates internal cache.
Summary: Retrieves Read operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) Resource ¶
func (r *SkillResource) Resource() *mcp.Resource
Resource returns the underlying MCP resource definition.
Returns:
- *mcp.Resource: The MCP resource definition.
Side Effects:
- None.
Summary: Executes Resource operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) Service ¶
func (r *SkillResource) Service() string
Service returns the service identifier associated with the resource.
Returns:
- string: The service identifier ("skills").
Side Effects:
- None.
Summary: Executes Service operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) Subscribe ¶
func (r *SkillResource) Subscribe(_ context.Context) error
Subscribe subscribes to changes on the resource.
Currently, this implementation is a no-op as dynamic updates to skill resources are not yet supported.
Parameters:
- _ (context.Context): Unused.
Returns:
- error: Always returns nil.
Side Effects:
- None.
Summary: Executes Subscribe operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*SkillResource) URI ¶
func (r *SkillResource) URI() string
URI returns the URI of the resource.
Returns:
- string: The resource URI.
Side Effects:
- None.
Summary: Executes URI operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type TemporaryToolManager ¶
type TemporaryToolManager struct {
NoOpToolManager
// contains filtered or unexported fields
}
TemporaryToolManager is a tool manager that stores service info and tools temporarily.
It is intended for use in ValidateService where we need to store service info and discovered tools for the duration of the validation request but discard them afterwards.
Summary: Represents a TemporaryToolManager.
func NewTemporaryToolManager ¶
func NewTemporaryToolManager() *TemporaryToolManager
NewTemporaryToolManager creates a new TemporaryToolManager.
Returns:
- *TemporaryToolManager: A new instance of TemporaryToolManager.
Side Effects:
- None.
Summary: Initializes NewTemporaryToolManager operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) AddServiceInfo ¶
func (m *TemporaryToolManager) AddServiceInfo(serviceID string, info *tool.ServiceInfo)
AddServiceInfo implements tool.ManagerInterface.
Parameters:
- serviceID (string): The ID of the service.
- info (*tool.ServiceInfo): The service information.
Side Effects:
- Updates the internal service info map.
Summary: Executes AddServiceInfo operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) AddTool ¶
func (m *TemporaryToolManager) AddTool(t tool.Tool) error
AddTool implements tool.ManagerInterface.
Parameters:
- t (tool.Tool): The tool to add.
Returns:
- error: An error if the tool service ID is empty or name sanitization fails.
Side Effects:
- Updates the internal tool map.
Summary: Executes AddTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) GetServiceInfo ¶
func (m *TemporaryToolManager) GetServiceInfo(serviceID string) (*tool.ServiceInfo, bool)
GetServiceInfo implements tool.ManagerInterface.
Parameters:
- serviceID (string): The ID of the service.
Returns:
- *tool.ServiceInfo: The service information if found.
- bool: True if the service information exists.
Side Effects:
- None.
Summary: Retrieves GetServiceInfo operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) GetTool ¶
func (m *TemporaryToolManager) GetTool(toolName string) (tool.Tool, bool)
GetTool implements tool.ManagerInterface.
Parameters:
- toolName (string): The name of the tool.
Returns:
- tool.Tool: The tool if found.
- bool: True if the tool exists.
Side Effects:
- None.
Summary: Retrieves GetTool operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) GetToolCountForService ¶
func (m *TemporaryToolManager) GetToolCountForService(serviceID string) int
GetToolCountForService implements tool.ManagerInterface.
Parameters:
- serviceID (string): The ID of the service.
Returns:
- int: The number of tools for the service.
Side Effects:
- None.
Summary: Retrieves GetToolCountForService operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*TemporaryToolManager) ListTools ¶
func (m *TemporaryToolManager) ListTools() []tool.Tool
ListTools implements tool.ManagerInterface.
Returns:
- []tool.Tool: A list of all tools.
Side Effects:
- None.
Summary: Executes ListTools operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.