abstract

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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

func NewMLService(ctx context.Context, logger zerolog.Logger, cfg *config.MoLingConfig) MLService

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

func (mls *MLService) Config() string

Config returns the configuration of the service as a string.

func (*MLService) Ctx

func (mls *MLService) Ctx() context.Context

Ctx returns the context of the MLService.

func (*MLService) InitResources

func (mls *MLService) InitResources() error

InitResources initializes the MLService with empty maps and a mutex.

func (*MLService) LoadConfig

func (mls *MLService) LoadConfig(jsonData map[string]any) error

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

func (mls *MLService) Name() string

Name returns the name of the 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.

type ServiceFactory

type ServiceFactory func(ctx context.Context) (Service, error)

Jump to

Keyboard shortcuts

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