usecases

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package usecases implements the application business logic for the MCP server.

Index

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) AddPrompt

func (s *ServerService) AddPrompt(ctx context.Context, prompt *domain.Prompt) error

AddPrompt adds a new prompt.

func (*ServerService) AddResource

func (s *ServerService) AddResource(ctx context.Context, resource *domain.Resource) error

AddResource adds a new resource.

func (*ServerService) AddTool

func (s *ServerService) AddTool(ctx context.Context, tool *domain.Tool) error

AddTool adds a new tool.

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) GetPrompt

func (s *ServerService) GetPrompt(ctx context.Context, name string) (*domain.Prompt, error)

GetPrompt returns a prompt by its name.

func (*ServerService) GetResource

func (s *ServerService) GetResource(ctx context.Context, uri string) (*domain.Resource, error)

GetResource returns a resource by its URI.

func (*ServerService) GetTool

func (s *ServerService) GetTool(ctx context.Context, name string) (*domain.Tool, error)

GetTool returns a tool by its name.

func (*ServerService) GetToolHandler

func (s *ServerService) GetToolHandler(name string) ToolHandlerFunc

GetToolHandler retrieves a handler for a specific tool

func (*ServerService) ListPrompts

func (s *ServerService) ListPrompts(ctx context.Context) ([]*domain.Prompt, error)

ListPrompts returns all available prompts.

func (*ServerService) ListResources

func (s *ServerService) ListResources(ctx context.Context) ([]*domain.Resource, error)

ListResources returns all available resources.

func (*ServerService) ListTools

func (s *ServerService) ListTools(ctx context.Context) ([]*domain.Tool, error)

ListTools returns all available tools.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL