services

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package services Description: This file contains the implementation of the CommandServer interface for MacOS and Linux.

Index

Constants

View Source
const (
	// MaxInlineSize Maximum size for inline content (5MB)
	MaxInlineSize = 1024 * 1024 * 5
	// MaxBase64Size Maximum size for base64 encoding (1MB)
	MaxBase64Size = 1024 * 1024 * 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandConfig

type CommandConfig struct {
	// contains filtered or unexported fields
}

CommandConfig represents the configuration for allowed commands.

func NewCommandConfig

func NewCommandConfig(commands []string) *CommandConfig

NewCommandConfig creates a new CommandConfig with the given allowed commands.

func (*CommandConfig) Check

func (cc *CommandConfig) Check() error

Check validates the allowed commands in the CommandConfig.

type CommandServer

type CommandServer struct {
	MLService
	// contains filtered or unexported fields
}

CommandServer implements the Service interface and provides methods to execute named commands.

type Config

type Config interface {
	// Check validates the configuration and returns an error if the configuration is invalid.
	Check() error
}

Config is an interface that defines a method for checking configuration validity.

type FileInfo

type FileInfo struct {
	Size        int64     `json:"size"`
	Created     time.Time `json:"created"`
	Modified    time.Time `json:"modified"`
	Accessed    time.Time `json:"accessed"`
	IsDirectory bool      `json:"isDirectory"`
	IsFile      bool      `json:"isFile"`
	Permissions string    `json:"permissions"`
}

type FileSystemConfig

type FileSystemConfig struct {
	// contains filtered or unexported fields
}

FileSystemConfig represents the configuration for the file system.

func NewFileSystemConfig

func NewFileSystemConfig(path []string) *FileSystemConfig

NewFileSystemConfig creates a new FileSystemConfig with the given allowed directories.

func (*FileSystemConfig) Check

func (fc *FileSystemConfig) Check() error

Check validates the allowed directories in the FileSystemConfig.

type FilesystemServer

type FilesystemServer struct {
	MLService
	// contains filtered or unexported fields
}

type MLService

type MLService struct {
	// contains filtered or unexported fields
}

MLService implements the Service interface and provides methods to manage resources, templates, prompts, tools, and notification handlers.

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

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

Ctx returns the context of the MLService.

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 {
	// contains filtered or unexported fields
}

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
}

Service defines the interface for a service with various handlers and tools.

func NewCommandServer

func NewCommandServer(ctx context.Context, cfg Config) (Service, error)

NewCommandServer creates a new CommandServer with the given allowed commands.

func NewFilesystemServer

func NewFilesystemServer(ctx context.Context, cfg Config) (Service, error)

Jump to

Keyboard shortcuts

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