Documentation
¶
Index ¶
- Constants
- func NewHTTPServer(ctx context.Context, exec Executor, cfg *ServerConfig) (*http.Server, error)
- func WithMCPManager(mgr promptdef.MCPManager) func(*ToolHandler)
- func WithProfileRepo(repo ProfileRepo) func(*ToolHandler)
- type ContextLLMCore
- type Executor
- type LLMCore
- type ProfileRepo
- type ResourceProvider
- type ServerConfig
- type ToolHandler
- func (h *ToolHandler) CallTool(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.CallToolRequest]) (*mcpschema.CallToolResult, *jsonrpc.Error)
- func (h *ToolHandler) Complete(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.CompleteRequest]) (*mcpschema.CompleteResult, *jsonrpc.Error)
- func (h *ToolHandler) GetPrompt(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.GetPromptRequest]) (*mcpschema.GetPromptResult, *jsonrpc.Error)
- func (h *ToolHandler) Implements(method string) bool
- func (h *ToolHandler) Initialize(_ context.Context, params *mcpschema.InitializeRequestParams, ...)
- func (h *ToolHandler) ListPrompts(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListPromptsRequest]) (*mcpschema.ListPromptsResult, *jsonrpc.Error)
- func (h *ToolHandler) ListResourceTemplates(_ context.Context, ...) (*mcpschema.ListResourceTemplatesResult, *jsonrpc.Error)
- func (h *ToolHandler) ListResources(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListResourcesRequest]) (*mcpschema.ListResourcesResult, *jsonrpc.Error)
- func (h *ToolHandler) ListTools(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListToolsRequest]) (*mcpschema.ListToolsResult, *jsonrpc.Error)
- func (h *ToolHandler) OnNotification(_ context.Context, _ *jsonrpc.Notification)
- func (h *ToolHandler) ReadResource(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.ReadResourceRequest]) (*mcpschema.ReadResourceResult, *jsonrpc.Error)
- func (h *ToolHandler) Subscribe(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.SubscribeRequest]) (*mcpschema.SubscribeResult, *jsonrpc.Error)
- func (h *ToolHandler) Unsubscribe(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.UnsubscribeRequest]) (*mcpschema.UnsubscribeResult, *jsonrpc.Error)
Constants ¶
const DefaultPort = 5000
Variables ¶
This section is empty.
Functions ¶
func NewHTTPServer ¶
NewHTTPServer constructs an MCP HTTP server exposing selected executor tools. It does not start listening; callers should run ListenAndServe and handle shutdown.
func WithMCPManager ¶ added in v0.1.7
func WithMCPManager(mgr promptdef.MCPManager) func(*ToolHandler)
WithMCPManager injects an MCP manager so MCP-sourced profiles can be rendered.
func WithProfileRepo ¶ added in v0.1.7
func WithProfileRepo(repo ProfileRepo) func(*ToolHandler)
WithProfileRepo injects a profile repository into a ToolHandler so that prompts/list and prompts/get return agently-core profiles to MCP clients.
Types ¶
type ContextLLMCore ¶ added in v0.1.15
type ContextLLMCore interface {
ToolDefinitionsWithContext(ctx context.Context) []llm.ToolDefinition
}
ContextLLMCore is an optional extension for cores that can list tool definitions using request-scoped context.
type Executor ¶
type Executor interface {
LLMCore() LLMCore
ExecuteTool(ctx context.Context, name string, args map[string]interface{}, timeoutSec int) (interface{}, error)
}
Executor is the minimal runtime contract needed by MCP expose handlers.
type LLMCore ¶
type LLMCore interface {
ToolDefinitions() []llm.ToolDefinition
}
LLMCore exposes tool definitions required by MCP tool listing.
type ProfileRepo ¶ added in v0.1.7
type ProfileRepo interface {
LoadAll(ctx context.Context) ([]*promptdef.Profile, error)
Load(ctx context.Context, id string) (*promptdef.Profile, error)
}
ProfileRepo is the subset of *promptrepo.Repository used by the MCP prompt handlers. *promptrepo.Repository satisfies this interface without any changes.
type ResourceProvider ¶ added in v0.1.9
type ResourceProvider interface {
ListResources(ctx context.Context) ([]mcpschema.Resource, error)
ReadResource(ctx context.Context, uri string) (*mcpschema.ReadResourceResult, error)
}
ResourceProvider is an optional executor-side extension for exposing MCP resources in addition to tools.
type ServerConfig ¶
type ServerConfig struct {
Addr string `yaml:"addr"`
Port int `yaml:"port"`
ToolItems []string `yaml:"toolItems"`
}
ServerConfig defines MCP server exposure options.
func (*ServerConfig) EffectivePort ¶ added in v0.1.14
func (c *ServerConfig) EffectivePort() int
EffectivePort returns the configured MCP port or the default port when the config is enabled but no explicit port was supplied.
func (*ServerConfig) Enabled ¶ added in v0.1.14
func (c *ServerConfig) Enabled() bool
Enabled reports whether MCP exposure is configured on this server config. When tool items are present and no explicit port or addr is supplied, the server falls back to the default loopback port.
func (*ServerConfig) ListenAddr ¶ added in v0.1.14
func (c *ServerConfig) ListenAddr() string
ListenAddr returns the effective bind address for the MCP server. If addr is explicitly configured it is used as-is; otherwise the server binds to the loopback interface on the effective port.
func (*ServerConfig) ToolPatterns ¶
func (c *ServerConfig) ToolPatterns() []string
type ToolHandler ¶
type ToolHandler struct {
// contains filtered or unexported fields
}
ToolHandler exposes executor tool registry via MCP tools/list and tools/call.
func NewToolHandler ¶
func NewToolHandler(exec Executor, patterns []string, opts ...func(*ToolHandler)) *ToolHandler
func NewToolHandlerWithProfiles ¶ added in v0.1.7
func NewToolHandlerWithProfiles(exec Executor, patterns []string, repo *promptrepo.Repository) *ToolHandler
NewToolHandlerWithProfiles constructs a ToolHandler with an optional profile repository so callers can pass both in a single call.
func (*ToolHandler) CallTool ¶
func (h *ToolHandler) CallTool(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.CallToolRequest]) (*mcpschema.CallToolResult, *jsonrpc.Error)
func (*ToolHandler) Complete ¶
func (h *ToolHandler) Complete(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.CompleteRequest]) (*mcpschema.CompleteResult, *jsonrpc.Error)
func (*ToolHandler) GetPrompt ¶
func (h *ToolHandler) GetPrompt(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.GetPromptRequest]) (*mcpschema.GetPromptResult, *jsonrpc.Error)
func (*ToolHandler) Implements ¶
func (h *ToolHandler) Implements(method string) bool
func (*ToolHandler) Initialize ¶
func (h *ToolHandler) Initialize(_ context.Context, params *mcpschema.InitializeRequestParams, _ *mcpschema.InitializeResult)
func (*ToolHandler) ListPrompts ¶
func (h *ToolHandler) ListPrompts(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListPromptsRequest]) (*mcpschema.ListPromptsResult, *jsonrpc.Error)
func (*ToolHandler) ListResourceTemplates ¶
func (h *ToolHandler) ListResourceTemplates(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListResourceTemplatesRequest]) (*mcpschema.ListResourceTemplatesResult, *jsonrpc.Error)
func (*ToolHandler) ListResources ¶
func (h *ToolHandler) ListResources(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListResourcesRequest]) (*mcpschema.ListResourcesResult, *jsonrpc.Error)
func (*ToolHandler) ListTools ¶
func (h *ToolHandler) ListTools(ctx context.Context, _ *jsonrpc.TypedRequest[*mcpschema.ListToolsRequest]) (*mcpschema.ListToolsResult, *jsonrpc.Error)
func (*ToolHandler) OnNotification ¶
func (h *ToolHandler) OnNotification(_ context.Context, _ *jsonrpc.Notification)
func (*ToolHandler) ReadResource ¶
func (h *ToolHandler) ReadResource(ctx context.Context, req *jsonrpc.TypedRequest[*mcpschema.ReadResourceRequest]) (*mcpschema.ReadResourceResult, *jsonrpc.Error)
func (*ToolHandler) Subscribe ¶
func (h *ToolHandler) Subscribe(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.SubscribeRequest]) (*mcpschema.SubscribeResult, *jsonrpc.Error)
func (*ToolHandler) Unsubscribe ¶
func (h *ToolHandler) Unsubscribe(_ context.Context, _ *jsonrpc.TypedRequest[*mcpschema.UnsubscribeRequest]) (*mcpschema.UnsubscribeResult, *jsonrpc.Error)