Documentation
¶
Index ¶
- type MLService
- func (mls *MLService) AddNotificationHandler(name string, handler server.NotificationHandlerFunc)
- func (mls *MLService) AddPrompt(pe PromptEntry)
- func (mls *MLService) AddResource(rs mcp.Resource, hr server.ResourceHandlerFunc)
- func (mls *MLService) AddResourceTemplate(rt mcp.ResourceTemplate, hr server.ResourceTemplateHandlerFunc)
- func (mls *MLService) AddTool(tool mcp.Tool, handler server.ToolHandlerFunc)
- func (mls *MLService) Config() string
- func (mls *MLService) Ctx() context.Context
- func (mls *MLService) InitResources() error
- func (mls *MLService) LoadConfig(jsonData map[string]any) error
- func (mls *MLService) MlConfig() *config.MoLingConfig
- func (mls *MLService) Name() string
- func (mls *MLService) NotificationHandlers() map[string]server.NotificationHandlerFunc
- func (mls *MLService) Prompts() []PromptEntry
- func (mls *MLService) ResourceTemplates() map[mcp.ResourceTemplate]server.ResourceTemplateHandlerFunc
- func (mls *MLService) Resources() map[mcp.Resource]server.ResourceHandlerFunc
- func (mls *MLService) Tools() []server.ServerTool
- type PromptEntry
- type Service
- type ServiceFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MLService ¶
type MLService struct {
Context context.Context
Logger zerolog.Logger // The logger for the service
// contains filtered or unexported fields
}
MLService implements the Service interface and provides methods to manage resources, templates, prompts, tools, and notification handlers.
func NewMLService ¶
NewMLService creates a new MLService with the given context and logger.
func (*MLService) AddNotificationHandler ¶
func (mls *MLService) AddNotificationHandler(name string, handler server.NotificationHandlerFunc)
AddNotificationHandler adds a notification handler to the service.
func (*MLService) AddPrompt ¶
func (mls *MLService) AddPrompt(pe PromptEntry)
AddPrompt adds a prompt and its handler function to the service.
func (*MLService) AddResource ¶
func (mls *MLService) AddResource(rs mcp.Resource, hr server.ResourceHandlerFunc)
AddResource adds a resource and its handler function to the service.
func (*MLService) AddResourceTemplate ¶
func (mls *MLService) AddResourceTemplate(rt mcp.ResourceTemplate, hr server.ResourceTemplateHandlerFunc)
AddResourceTemplate adds a resource template and its handler function to the service.
func (*MLService) AddTool ¶
func (mls *MLService) AddTool(tool mcp.Tool, handler server.ToolHandlerFunc)
AddTool adds a tool and its handler function to the service.
func (*MLService) InitResources ¶
InitResources initializes the MLService with empty maps and a mutex.
func (*MLService) LoadConfig ¶
LoadConfig loads the configuration for the service from a map.
func (*MLService) MlConfig ¶
func (mls *MLService) MlConfig() *config.MoLingConfig
MlConfig returns the configuration of the MoLing service.
func (*MLService) NotificationHandlers ¶
func (mls *MLService) NotificationHandlers() map[string]server.NotificationHandlerFunc
NotificationHandlers returns the map of notification handlers.
func (*MLService) Prompts ¶
func (mls *MLService) Prompts() []PromptEntry
Prompts returns the map of prompts and their handler functions.
func (*MLService) ResourceTemplates ¶
func (mls *MLService) ResourceTemplates() map[mcp.ResourceTemplate]server.ResourceTemplateHandlerFunc
ResourceTemplates returns the map of resource templates and their handler functions.
func (*MLService) Resources ¶
func (mls *MLService) Resources() map[mcp.Resource]server.ResourceHandlerFunc
Resources returns the map of resources and their handler functions.
func (*MLService) Tools ¶
func (mls *MLService) Tools() []server.ServerTool
Tools returns the slice of server tools.
type PromptEntry ¶
type PromptEntry struct {
PromptVar mcp.Prompt
HandlerFunc server.PromptHandlerFunc
}
func (*PromptEntry) Handler ¶
func (pe *PromptEntry) Handler() server.PromptHandlerFunc
func (*PromptEntry) Prompt ¶
func (pe *PromptEntry) Prompt() mcp.Prompt
type Service ¶
type Service interface {
Ctx() context.Context
// Resources returns a map of resources and their corresponding handler functions.
Resources() map[mcp.Resource]server.ResourceHandlerFunc
// ResourceTemplates returns a map of resource templates and their corresponding handler functions.
ResourceTemplates() map[mcp.ResourceTemplate]server.ResourceTemplateHandlerFunc
// Prompts returns a map of prompts and their corresponding handler functions.
Prompts() []PromptEntry
// Tools returns a slice of server tools.
Tools() []server.ServerTool
// NotificationHandlers returns a map of notification handlers.
NotificationHandlers() map[string]server.NotificationHandlerFunc
// Config returns the configuration of the service as a string.
Config() string
// LoadConfig loads the configuration for the service from a map.
LoadConfig(jsonData map[string]any) error
// Init initializes the service with the given context and configuration.
Init() error
MlConfig() *config.MoLingConfig
// Name returns the name of the service.
Name() comm.MoLingServerType
// Close closes the service and releases any resources it holds.
Close() error
}
Service defines the interface for a service with various handlers and tools.