Documentation
¶
Overview ¶
Package mcp provides a Model Context Protocol (MCP) server that exposes workflow engine functionality to AI assistants. The server dynamically reflects available module types, step types, trigger types, plugin information, and configuration validation so that AI tools can author and validate workflow YAML files with accurate, up-to-date knowledge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is the MCP server version, set at build time.
Functions ¶
This section is empty.
Types ¶
type EngineProvider ¶ added in v0.3.0
type EngineProvider interface {
// BuildFromConfig builds the engine from a parsed workflow config.
BuildFromConfig(cfg *config.WorkflowConfig) error
// Start starts the engine and all registered triggers.
Start(ctx context.Context) error
// Stop gracefully shuts down the engine.
Stop(ctx context.Context) error
// TriggerWorkflow dispatches a workflow execution.
TriggerWorkflow(ctx context.Context, workflowType string, action string, data map[string]any) error
}
EngineProvider is the interface that the MCP server requires from the workflow engine. It is kept intentionally narrow so that the mcp package does not import the root workflow package directly.
type InProcessOption ¶ added in v0.10.1
type InProcessOption func(*inProcessConfig)
InProcessOption configures the in-process server.
func WithInProcessAuditLog ¶ added in v0.10.1
func WithInProcessAuditLog(logger *slog.Logger) InProcessOption
WithInProcessAuditLog enables audit logging for in-process tool calls.
func WithInProcessDocFile ¶ added in v0.10.1
func WithInProcessDocFile(path string) InProcessOption
WithInProcessDocFile sets an explicit path to DOCUMENTATION.md.
func WithInProcessEngine ¶ added in v0.10.1
func WithInProcessEngine(eng EngineProvider) InProcessOption
WithInProcessEngine attaches a workflow engine for run_workflow support.
func WithInProcessPluginDir ¶ added in v0.10.1
func WithInProcessPluginDir(dir string) InProcessOption
WithInProcessPluginDir sets the plugin directory for type discovery.
func WithInProcessRegistryDir ¶ added in v0.10.1
func WithInProcessRegistryDir(dir string) InProcessOption
WithInProcessRegistryDir sets the registry directory for plugin search.
type InProcessServer ¶ added in v0.10.1
type InProcessServer struct {
// contains filtered or unexported fields
}
InProcessServer wraps the MCP Server for direct in-process invocation without HTTP or subprocess overhead.
func NewInProcessServer ¶ added in v0.10.1
func NewInProcessServer(opts ...InProcessOption) *InProcessServer
NewInProcessServer creates an InProcessServer with all workflow tools registered. All wfctl tools are available without HTTP or subprocess overhead.
func (*InProcessServer) CallTool ¶ added in v0.10.1
func (p *InProcessServer) CallTool(ctx context.Context, name string, args map[string]any) (any, error)
CallTool invokes the named tool with the given arguments. Returns the tool result, which may be of any type, or an error if the tool is not found or invocation fails.
func (*InProcessServer) GetToolSchema ¶ added in v0.10.2
func (p *InProcessServer) GetToolSchema(name string) (ToolSchema, bool)
GetToolSchema returns the schema for a specific tool, or false if not found.
func (*InProcessServer) ListToolSchemas ¶ added in v0.10.2
func (p *InProcessServer) ListToolSchemas() []ToolSchema
ListToolSchemas returns all registered tools with their parameter schemas.
func (*InProcessServer) ListTools ¶ added in v0.10.1
func (p *InProcessServer) ListTools() []string
ListTools returns the names of all registered tools.
type MCPProvider ¶ added in v0.10.1
type MCPProvider interface {
// ListTools returns the names of all registered tools.
ListTools() []string
// ListToolSchemas returns all tools with their parameter schemas.
ListToolSchemas() []ToolSchema
// CallTool invokes the named tool with the given arguments.
// Returns the tool result, which may be of any type, or an error.
CallTool(ctx context.Context, name string, args map[string]any) (any, error)
}
MCPProvider is the interface for invoking MCP tools in-process without HTTP or subprocess overhead.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps an MCP server instance and provides workflow-engine-specific tools and resources.
func NewServer ¶
func NewServer(pluginDir string, opts ...ServerOption) *Server
NewServer creates a new MCP server with all workflow engine tools and resources registered. pluginDir is the directory where installed plugins reside (e.g., "data/plugins"). If set, the server will read plugin manifests from this directory and include plugin-provided types in all type listings. Optional ServerOption values can be provided to attach an engine, etc.
func (*Server) MCPServer ¶
MCPServer returns the underlying mcp-go server instance (useful for testing).
func (*Server) ServeStdio ¶
ServeStdio starts the MCP server over standard input/output.
type ServerOption ¶ added in v0.3.0
type ServerOption func(*Server)
ServerOption configures optional Server behaviour.
func WithDocumentationFile ¶ added in v0.3.33
func WithDocumentationFile(path string) ServerOption
WithDocumentationFile sets an explicit path to DOCUMENTATION.md so that the workflow://docs/full-reference MCP resource serves the actual repo documentation. When not set the server attempts to locate the file automatically (see handleDocsFullReference). If the file cannot be found the resource returns a brief message directing users to the public documentation URL.
func WithEngine ¶ added in v0.3.0
func WithEngine(engine EngineProvider) ServerOption
WithEngine attaches a pre-built workflow engine to the MCP server, enabling the run_workflow tool for AI-driven workflow execution.
func WithRegistryDir ¶ added in v0.3.26
func WithRegistryDir(dir string) ServerOption
WithRegistryDir sets the path to a cloned workflow-registry for plugin search.
type ToolHandlerFunc ¶ added in v0.10.1
type ToolHandlerFunc = server.ToolHandlerFunc
ToolHandlerFunc is the handler type for MCP tool calls.
type ToolSchema ¶ added in v0.10.2
type ToolSchema struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema,omitempty"`
}
InProcessServer exposes the workflow MCP tools for direct in-process invocation without HTTP or subprocess overhead. ToolSchema describes an MCP tool's name, description, and parameter schema.