prompt

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package prompt provides prompt management functionality.

Package prompt is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrPromptNotFound = errors.New("prompt not found")

ErrPromptNotFound is returned when a requested prompt is not found.

Functions

This section is empty.

Types

type MCPServerProvider

type MCPServerProvider interface {
	// Server returns the underlying MCP server instance.
	Server() *mcp.Server
}

MCPServerProvider defines an interface for components that can provide an instance of an *mcp.Server. This is used to decouple the Manager from the concrete server implementation.

func NewMCPServerProvider

func NewMCPServerProvider(server *mcp.Server) MCPServerProvider

NewMCPServerProvider creates a new MCPServerProvider.

type Manager

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

Manager is a thread-safe manager for registering and retrieving prompts.

func NewManager

func NewManager() *Manager

NewManager creates and returns a new, empty Manager.

func (*Manager) AddPrompt

func (pm *Manager) AddPrompt(prompt Prompt)

AddPrompt registers a new prompt with the manager. If a prompt with the same name already exists, it will be overwritten, and a warning will be logged.

func (*Manager) ClearPromptsForService

func (pm *Manager) ClearPromptsForService(serviceID string)

ClearPromptsForService removes all prompts associated with a given service.

func (*Manager) GetPrompt

func (pm *Manager) GetPrompt(name string) (Prompt, bool)

GetPrompt retrieves a prompt from the manager by its name.

func (*Manager) ListPrompts

func (pm *Manager) ListPrompts() []Prompt

ListPrompts returns a slice containing all the prompts currently registered.

func (*Manager) SetMCPServer

func (pm *Manager) SetMCPServer(mcpServer MCPServerProvider)

SetMCPServer provides the Manager with a reference to the MCP server.

func (*Manager) UpdatePrompt

func (pm *Manager) UpdatePrompt(prompt Prompt)

UpdatePrompt updates an existing prompt in the manager. If the prompt does not exist, it will be added.

type ManagerInterface

type ManagerInterface interface {
	// AddPrompt registers a new prompt.
	AddPrompt(prompt Prompt)
	// UpdatePrompt updates an existing prompt.
	UpdatePrompt(prompt Prompt)
	// GetPrompt retrieves a prompt by name.
	GetPrompt(name string) (Prompt, bool)
	// ListPrompts returns all registered prompts.
	ListPrompts() []Prompt
	// ClearPromptsForService removes all prompts associated with a service.
	ClearPromptsForService(serviceID string)
	// SetMCPServer sets the MCP server provider.
	SetMCPServer(mcpServer MCPServerProvider)
}

ManagerInterface defines the interface for a prompt manager.

type MockManagerInterface

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

MockManagerInterface is a mock of ManagerInterface interface.

func NewMockManagerInterface

func NewMockManagerInterface(ctrl *gomock.Controller) *MockManagerInterface

NewMockManagerInterface creates a new mock instance.

func (*MockManagerInterface) AddPrompt

func (m *MockManagerInterface) AddPrompt(prompt Prompt)

AddPrompt mocks base method.

func (*MockManagerInterface) Clear

func (m *MockManagerInterface) Clear()

Clear mocks base method.

func (*MockManagerInterface) ClearPromptsForService

func (m *MockManagerInterface) ClearPromptsForService(serviceID string)

ClearPromptsForService mocks base method.

func (*MockManagerInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManagerInterface) GetPrompt

func (m *MockManagerInterface) GetPrompt(name string) (Prompt, bool)

GetPrompt mocks base method.

func (*MockManagerInterface) ListPrompts

func (m *MockManagerInterface) ListPrompts() []Prompt

ListPrompts mocks base method.

func (*MockManagerInterface) SetMCPServer

func (m *MockManagerInterface) SetMCPServer(mcpServer MCPServerProvider)

SetMCPServer mocks base method.

func (*MockManagerInterface) UpdatePrompt

func (m *MockManagerInterface) UpdatePrompt(prompt Prompt)

UpdatePrompt mocks base method.

type MockManagerInterfaceMockRecorder

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

MockManagerInterfaceMockRecorder is the mock recorder for MockManagerInterface.

func (*MockManagerInterfaceMockRecorder) AddPrompt

func (mr *MockManagerInterfaceMockRecorder) AddPrompt(prompt any) *gomock.Call

AddPrompt indicates an expected call of AddPrompt.

func (*MockManagerInterfaceMockRecorder) Clear

Clear indicates an expected call of Clear.

func (*MockManagerInterfaceMockRecorder) ClearPromptsForService

func (mr *MockManagerInterfaceMockRecorder) ClearPromptsForService(serviceID any) *gomock.Call

ClearPromptsForService indicates an expected call of ClearPromptsForService.

func (*MockManagerInterfaceMockRecorder) GetPrompt

func (mr *MockManagerInterfaceMockRecorder) GetPrompt(name any) *gomock.Call

GetPrompt indicates an expected call of GetPrompt.

func (*MockManagerInterfaceMockRecorder) ListPrompts

func (mr *MockManagerInterfaceMockRecorder) ListPrompts() *gomock.Call

ListPrompts indicates an expected call of ListPrompts.

func (*MockManagerInterfaceMockRecorder) SetMCPServer

func (mr *MockManagerInterfaceMockRecorder) SetMCPServer(mcpServer any) *gomock.Call

SetMCPServer indicates an expected call of SetMCPServer.

func (*MockManagerInterfaceMockRecorder) UpdatePrompt

func (mr *MockManagerInterfaceMockRecorder) UpdatePrompt(prompt any) *gomock.Call

UpdatePrompt indicates an expected call of UpdatePrompt.

type Prompt

type Prompt interface {
	// Prompt returns the MCP prompt definition.
	Prompt() *mcp.Prompt
	// Service returns the ID of the service that provides this prompt.
	Service() string
	// Get executes the prompt with the provided arguments.
	Get(ctx context.Context, args json.RawMessage) (*mcp.GetPromptResult, error)
}

Prompt is the fundamental interface for any executable prompt in the system.

func NewPromptFromConfig

func NewPromptFromConfig(definition *configv1.PromptDefinition, serviceID string) (Prompt, error)

NewPromptFromConfig creates a new Prompt from a configuration definition.

type Service

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

Service handles the business logic for the prompts feature. It provides methods for listing available prompts and retrieving a specific prompt by name.

func NewService

func NewService(promptManager ManagerInterface) *Service

NewService creates and returns a new Service instance.

func (*Service) GetPrompt

func (s *Service) GetPrompt(
	ctx context.Context,
	req *mcp.GetPromptRequest,
) (*mcp.GetPromptResult, error)

GetPrompt handles the "prompts/get" MCP request. It retrieves a specific prompt by name from the Manager and executes it with the provided arguments, returning the result. If the prompt is not found, it returns a ErrPromptNotFound error.

func (*Service) ListPrompts

func (s *Service) ListPrompts(
	_ context.Context,
	_ *mcp.ListPromptsRequest,
) (*mcp.ListPromptsResult, error)

ListPrompts handles the "prompts/list" MCP request. It retrieves the list of available prompts from the Manager, converts them to the MCP format, and returns them to the client.

func (*Service) SetMCPServer

func (s *Service) SetMCPServer(mcpServer *mcp.Server)

SetMCPServer sets the MCP server instance for the service.

type TemplatedPrompt

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

TemplatedPrompt implements the Prompt interface for a prompt that is defined by a template.

func NewTemplatedPrompt

func NewTemplatedPrompt(definition *configv1.PromptDefinition, serviceID string) *TemplatedPrompt

NewTemplatedPrompt creates a new TemplatedPrompt.

func (*TemplatedPrompt) Get

Get executes the prompt with the provided arguments.

func (*TemplatedPrompt) Prompt

func (p *TemplatedPrompt) Prompt() *mcp.Prompt

Prompt returns the MCP prompt definition.

func (*TemplatedPrompt) Service

func (p *TemplatedPrompt) Service() string

Service returns the ID of the service that provides this prompt.

Jump to

Keyboard shortcuts

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