mcp

package
v0.0.202 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package mcp implements comanda's Model Context Protocol (MCP) server mode, exposing workflows as MCP tools and skills as MCP prompts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultWorkflowDirs

func DefaultWorkflowDirs() []string

DefaultWorkflowDirs returns the default workflow directories that exist: ~/.comanda/workflows/ (user level) and .comanda/workflows/ (project level).

func NewServer

func NewServer(opts Options) (*mcpsdk.Server, error)

NewServer builds an MCP server exposing each workflow as a tool and each skill as a prompt.

func ServeHTTP

func ServeHTTP(ctx context.Context, s *mcpsdk.Server, addr string) error

ServeHTTP serves the MCP server over the streamable HTTP transport. It is intended for localhost use only; no authentication is applied.

func ServeStdio

func ServeStdio(ctx context.Context, s *mcpsdk.Server) error

ServeStdio serves the MCP server over stdin/stdout until the client disconnects or ctx is canceled. Nothing except MCP protocol frames may be written to stdout while this runs; cmd sets log output to stderr.

Types

type Options

type Options struct {
	Name      string // Server name reported to MCP clients
	Version   string // Server version reported to MCP clients
	Verbose   bool   // Enable debug logging (to stderr)
	EnvConfig *config.EnvConfig
	Workflows []WorkflowDef   // Workflows to expose as tools
	Skills    []*skills.Skill // Skills to expose as prompts (nil/empty disables)
}

Options configures the MCP server.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes workflows on behalf of MCP tool calls.

func NewRunner

func NewRunner(envConfig *config.EnvConfig, verbose bool) *Runner

NewRunner creates a Runner that executes workflows with the given environment configuration.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, def WorkflowDef, args map[string]string) (string, error)

Run executes the workflow defined by def with the given tool arguments and returns the workflow's final output. All arguments except the reserved "input" argument are passed as CLI variables ({{ var }} substitution); "input" is fed to the workflow as STDIN-style input via SetLastOutput.

type WorkflowDef

type WorkflowDef struct {
	Name        string   // MCP tool name (sanitized workflow file base)
	Path        string   // Path to the workflow YAML file
	Description string   // Tool description (first comment line or fallback)
	Vars        []string // {{ var }} placeholders discovered in the file
}

WorkflowDef describes a discovered workflow file exposed as an MCP tool.

func DiscoverWorkflows

func DiscoverWorkflows(dirs, files []string) ([]WorkflowDef, error)

DiscoverWorkflows scans dirs for *.yaml/*.yml workflow files and combines them with the explicit files, building one WorkflowDef per file. It returns an error if two files map to the same tool name, if a file cannot be read, or if a file base cannot be sanitized into a valid tool name.

Jump to

Keyboard shortcuts

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