Documentation
¶
Index ¶
- func IsMCPToolName(name string) bool
- func RemapLegacyAdvisorToolName(toolName string) string
- func ScenarioFromContext(ctx context.Context) (typ.RuleScenario, bool)
- type AdvisorHook
- type DefaultExecutor
- type Executor
- type Hook
- type HookDeps
- type Pipeline
- type Provider
- type RuntimeCaller
- type ToolCall
- type ToolProvider
- type VirtualToolRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMCPToolName ¶
IsMCPToolName reports whether name looks like a normalized MCP tool name (i.e. it parses successfully via ParseNormalizedToolName).
func RemapLegacyAdvisorToolName ¶
RemapLegacyAdvisorToolName normalises the legacy "advisor" source ID to "builtin". All other tool names pass through unchanged.
func ScenarioFromContext ¶
func ScenarioFromContext(ctx context.Context) (typ.RuleScenario, bool)
ScenarioFromContext reads the scenario stored under client.ScenarioContextKey (set by the protocol server's routing middleware).
Types ¶
type AdvisorHook ¶
type AdvisorHook struct{}
AdvisorHook injects AdvisorContext before an advisor tool call. Exported for test compatibility in packages that alias this type.
func (AdvisorHook) Match ¶
func (h AdvisorHook) Match(toolName string) bool
func (AdvisorHook) PrepareContext ¶
type DefaultExecutor ¶
type DefaultExecutor struct {
// contains filtered or unexported fields
}
DefaultExecutor is the standard implementation of Executor.
func NewDefaultExecutor ¶
func NewDefaultExecutor(rt RuntimeCaller, deps HookDeps) *DefaultExecutor
NewDefaultExecutor creates a DefaultExecutor with no hooks. Use Pipeline.NewExecutor to get an executor with registered tool hooks.
type Executor ¶
type Executor interface {
Execute(ctx context.Context, call ToolCall) (context.Context, coretool.ToolResult, error)
}
Executor executes a single MCP tool call through the full pipeline: name validation, legacy remapping, callable guard, hooks, and dispatch.
type Hook ¶
type Hook interface {
Match(toolName string) bool
PrepareContext(deps HookDeps, ctx context.Context, messages []map[string]any) context.Context
}
Hook prepares runtime context for a specific MCP servertool call. Hooks run after the worker response arrives and before local tool execution.
type HookDeps ¶
type HookDeps interface {
// GetAdvisorMaxUses returns the configured maximum advisor calls per request.
GetAdvisorMaxUses() int
}
HookDeps provides the server-level dependencies that hooks may need.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline owns all registered ToolProviders and builds executors with the correct hook set. Construct once at server startup; call Register for each tool, then RegisterInto to populate the VirtualToolRegistry.
func (*Pipeline) NewExecutor ¶
func (p *Pipeline) NewExecutor(rt RuntimeCaller, deps HookDeps) *DefaultExecutor
NewExecutor returns a DefaultExecutor wired with the current hook list.
func (*Pipeline) Register ¶
func (p *Pipeline) Register(provider ToolProvider)
Register adds a ToolProvider to the pipeline. If provider.Hook() is non-nil it is appended to the hook list.
func (*Pipeline) RegisterInto ¶
func (p *Pipeline) RegisterInto(registry VirtualToolRegistry)
RegisterInto writes all provider descriptors into registry. Call once after all providers have been registered.
type Provider ¶ added in v0.260924.1
type Provider struct {
// contains filtered or unexported fields
}
Provider implements ToolProvider for the built-in advisor virtual tool.
func NewProvider ¶ added in v0.260924.1
func NewProvider(cfg typ.AdvisorConfig, cp *client.ClientPool, store *mcpruntime.SessionStore) Provider
NewProvider constructs an advisor servertool provider. cp and store may be nil in tests.
func (Provider) Descriptor ¶ added in v0.260924.1
func (p Provider) Descriptor() coretool.VirtualTool
Descriptor returns the VirtualTool definition for the advisor.
type RuntimeCaller ¶
type RuntimeCaller interface {
CallTool(ctx context.Context, normalizedName, arguments string) (coretool.ToolResult, error)
ListCallableServerToolNames(ctx context.Context) map[string]struct{}
GetAdvisorMaxUses() int
}
RuntimeCaller is the subset of the tool runtime used by DefaultExecutor.
type ToolProvider ¶
type ToolProvider interface {
// Descriptor returns the VirtualTool to register in the runtime registry.
Descriptor() coretool.VirtualTool
// Hook returns a pre-call context hook, or nil if not needed.
Hook() Hook
}
ToolProvider is implemented by each virtual server tool. Register once; Pipeline derives hooks and registry entries from it.
type VirtualToolRegistry ¶
type VirtualToolRegistry interface {
Register(coretool.VirtualTool)
}