Documentation
¶
Overview ¶
Package usecases implements the application business logic for the MCP server.
Index ¶
- type ServerConfig
- type ServerService
- func (s *ServerService) AddPrompt(ctx context.Context, prompt *domain.Prompt) error
- func (s *ServerService) AddResource(ctx context.Context, resource *domain.Resource) error
- func (s *ServerService) AddTool(ctx context.Context, tool *domain.Tool) error
- func (s *ServerService) BroadcastNotification(ctx context.Context, notification *domain.Notification) error
- func (s *ServerService) DeletePrompt(ctx context.Context, name string) error
- func (s *ServerService) DeleteResource(ctx context.Context, uri string) error
- func (s *ServerService) DeleteTool(ctx context.Context, name string) error
- func (s *ServerService) GetAllToolHandlerNames() []string
- func (s *ServerService) GetPrompt(ctx context.Context, name string) (*domain.Prompt, error)
- func (s *ServerService) GetResource(ctx context.Context, uri string) (*domain.Resource, error)
- func (s *ServerService) GetTool(ctx context.Context, name string) (*domain.Tool, error)
- func (s *ServerService) GetToolHandler(name string) ToolHandlerFunc
- func (s *ServerService) ListPrompts(ctx context.Context) ([]*domain.Prompt, error)
- func (s *ServerService) ListResources(ctx context.Context) ([]*domain.Resource, error)
- func (s *ServerService) ListTools(ctx context.Context) ([]*domain.Tool, error)
- func (s *ServerService) RegisterSession(ctx context.Context, session *domain.ClientSession) error
- func (s *ServerService) RegisterToolHandler(name string, handler ToolHandlerFunc)
- func (s *ServerService) SendNotification(ctx context.Context, sessionID string, notification *domain.Notification) error
- func (s *ServerService) ServerInfo() (string, string, string)
- func (s *ServerService) UnregisterSession(ctx context.Context, id string) error
- type ToolHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServerConfig ¶
type ServerConfig struct { Name string Version string Instructions string ResourceRepo domain.ResourceRepository ToolRepo domain.ToolRepository PromptRepo domain.PromptRepository SessionRepo domain.SessionRepository NotificationSender domain.NotificationSender }
ServerConfig contains configuration for the ServerService.
type ServerService ¶
type ServerService struct {
// contains filtered or unexported fields
}
ServerService handles business logic for the MCP server.
func NewServerService ¶
func NewServerService(config ServerConfig) *ServerService
NewServerService creates a new ServerService with the given repositories and configuration.
func (*ServerService) AddResource ¶
AddResource adds a new resource.
func (*ServerService) BroadcastNotification ¶
func (s *ServerService) BroadcastNotification(ctx context.Context, notification *domain.Notification) error
BroadcastNotification sends a notification to all connected clients.
func (*ServerService) DeletePrompt ¶
func (s *ServerService) DeletePrompt(ctx context.Context, name string) error
DeletePrompt removes a prompt.
func (*ServerService) DeleteResource ¶
func (s *ServerService) DeleteResource(ctx context.Context, uri string) error
DeleteResource removes a resource.
func (*ServerService) DeleteTool ¶
func (s *ServerService) DeleteTool(ctx context.Context, name string) error
DeleteTool removes a tool.
func (*ServerService) GetAllToolHandlerNames ¶
func (s *ServerService) GetAllToolHandlerNames() []string
GetAllToolHandlerNames returns a slice of all registered tool handler names
func (*ServerService) GetResource ¶
GetResource returns a resource by its URI.
func (*ServerService) GetToolHandler ¶
func (s *ServerService) GetToolHandler(name string) ToolHandlerFunc
GetToolHandler retrieves a handler for a specific tool
func (*ServerService) ListPrompts ¶
ListPrompts returns all available prompts.
func (*ServerService) ListResources ¶
ListResources returns all available resources.
func (*ServerService) RegisterSession ¶
func (s *ServerService) RegisterSession(ctx context.Context, session *domain.ClientSession) error
RegisterSession adds a new client session.
func (*ServerService) RegisterToolHandler ¶
func (s *ServerService) RegisterToolHandler(name string, handler ToolHandlerFunc)
RegisterToolHandler registers a handler for a specific tool
func (*ServerService) SendNotification ¶
func (s *ServerService) SendNotification(ctx context.Context, sessionID string, notification *domain.Notification) error
SendNotification sends a notification to a specific client.
func (*ServerService) ServerInfo ¶
func (s *ServerService) ServerInfo() (string, string, string)
ServerInfo returns information about the server.
func (*ServerService) UnregisterSession ¶
func (s *ServerService) UnregisterSession(ctx context.Context, id string) error
UnregisterSession removes a client session.
type ToolHandlerFunc ¶
type ToolHandlerFunc func(ctx context.Context, params map[string]interface{}, session *domain.ClientSession) (interface{}, error)
ToolHandlerFunc defines a function type for handling tool calls