Documentation
¶
Overview ¶
Package compositetools provides a MultiSession decorator that adds composite tool (workflow) capabilities to a session.
Index ¶
- func ConvertWorkflowDefsToTools(defs map[string]*composer.WorkflowDefinition) []vmcp.Tool
- func FilterWorkflowDefsForSession(defs map[string]*composer.WorkflowDefinition, rt *vmcp.RoutingTable) map[string]*composer.WorkflowDefinition
- func NewDecorator(sess sessiontypes.MultiSession, compositeTools []vmcp.Tool, ...) sessiontypes.MultiSession
- func ValidateNoToolConflicts(backendTools, compositeTools []vmcp.Tool) error
- type WorkflowExecutor
- type WorkflowResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertWorkflowDefsToTools ¶
func ConvertWorkflowDefsToTools(defs map[string]*composer.WorkflowDefinition) []vmcp.Tool
ConvertWorkflowDefsToTools converts workflow definitions to vmcp.Tool format.
This creates the tool metadata (name, description, schema) that gets exposed via the MCP tools/list endpoint. The actual workflow execution logic is handled by the workflow executor adapters created separately.
Each workflow definition becomes a tool with:
- Name: workflow.Name
- Description: workflow.Description
- InputSchema: workflow.Parameters (JSON Schema format)
- OutputSchema: workflow.Output (JSON Schema format, if defined)
Returns a slice of vmcp.Tool ready for aggregation and exposure to clients.
func FilterWorkflowDefsForSession ¶
func FilterWorkflowDefsForSession( defs map[string]*composer.WorkflowDefinition, rt *vmcp.RoutingTable, ) map[string]*composer.WorkflowDefinition
FilterWorkflowDefsForSession returns only the workflow definitions whose every tool step references a backend tool that is present in the session routing table.
If a session does not have access to a backend tool (e.g. due to identity-based filtering), any composite tool that depends on that backend tool is also excluded. This prevents a session from invoking a composite tool that would fail at runtime because one or more of its underlying tools are not routable for that session.
func NewDecorator ¶
func NewDecorator( sess sessiontypes.MultiSession, compositeTools []vmcp.Tool, executors map[string]WorkflowExecutor, ) sessiontypes.MultiSession
NewDecorator wraps sess with composite tool support. compositeTools is the metadata list appended to session.Tools(). executors maps each composite tool name to its workflow executor. Both may be nil/empty.
func ValidateNoToolConflicts ¶
ValidateNoToolConflicts validates that composite tool names don't conflict with backend tool names.
Tool name conflicts would cause ambiguity in routing/execution:
- Which tool should be invoked when a client calls the name?
- Should it route to the backend or execute the workflow?
This validation ensures clear separation and prevents runtime confusion. Returns an error listing all conflicting tool names if any conflicts are found.
Types ¶
type WorkflowExecutor ¶
type WorkflowExecutor interface {
ExecuteWorkflow(ctx context.Context, params map[string]any) (*WorkflowResult, error)
}
WorkflowExecutor executes a named composite tool workflow.
type WorkflowResult ¶
WorkflowResult holds the output of a workflow execution.