expose

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultPort = 5000

Variables

This section is empty.

Functions

func NewHTTPServer

func NewHTTPServer(ctx context.Context, exec Executor, cfg *ServerConfig) (*http.Server, error)

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

func (h *ToolHandler) Implements(method string) bool

func (*ToolHandler) Initialize

func (*ToolHandler) OnNotification

func (h *ToolHandler) OnNotification(_ context.Context, _ *jsonrpc.Notification)

Jump to

Keyboard shortcuts

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