mcpserver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mcpserver exposes a Runefile's non-private tasks to AI agents and IDEs as Model Context Protocol tools. Tools are run through the SAME engine the CLI uses (FR-026); secrets never appear in any tool name, description, schema, or result (FR-029, Principle VII). It is a public package so it can be embedded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Tasks returns the exposable (non-private) tasks with their metadata.
	Tasks() []TaskInfo
	// Call runs a task by display name with string arguments, capturing output.
	Call(ctx context.Context, name string, args map[string]string) (Result, error)
}

Engine is the host the MCP server runs tasks against. The CLI implements it.

type HTTPConfig

type HTTPConfig struct {
	Addr  string // e.g. 127.0.0.1:7777
	Token string // required bearer token
}

HTTPConfig configures the opt-in Streamable HTTP transport.

type Options

type Options struct {
	// AllowDestructive permits calling tasks marked destructive ([confirm]).
	AllowDestructive bool
	// AllowList, when non-empty, narrows callable tasks to these names.
	AllowList []string
	// Version reported to clients.
	Version string
	// Instructions, when non-empty, is delivered to clients as the MCP
	// server instructions in the initialize result. Rune uses it for the
	// [context] hook's project-health text (spec 021 FR-002). It must
	// already be masked; this package never processes it.
	Instructions string
}

Options configures authorization for the server.

type ParamInfo

type ParamInfo struct {
	Name     string
	Required bool
	Variadic bool
}

ParamInfo describes a task parameter for input-schema derivation.

type Result

type Result struct {
	Stdout   string
	Stderr   string
	ExitCode int
	// FixSuggestion is the captured output of the task's || failure hooks
	// (spec 022). Like Options.Instructions, it must already be masked and
	// size-capped by the engine; this package never processes it, only
	// renders it as a delimited section after the exit marker. Empty means
	// no section is rendered.
	FixSuggestion string
}

Result is the outcome of running a task on behalf of an agent.

type Server

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

Server wraps an mcp.Server built from a Runefile's tasks.

func New

func New(engine Engine, opts Options) *Server

New builds an MCP server exposing engine's non-private tasks as tools.

func (*Server) MCP

func (s *Server) MCP() *mcp.Server

MCP returns the underlying mcp.Server (for transports/tests).

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, cfg HTTPConfig) error

ServeHTTP starts the Streamable HTTP transport. It binds the configured address (localhost by default), requires a bearer token before any list/call (SC-010), and refuses a non-localhost bind unless the address is explicit.

func (*Server) ServeStdio

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

ServeStdio runs the MCP server over stdio (always available, auth inherited from the local process/session).

func (*Server) StartHTTP

func (s *Server) StartHTTP(cfg HTTPConfig) (addr string, stop func(), err error)

StartHTTP binds and serves the HTTP transport in a background goroutine, returning the bound address and a stop function. Used by the (agent) executor to expose project tasks to the agent it drives.

type TaskInfo

type TaskInfo struct {
	Name        string // display name (namespaced mod::task becomes mod__task as a tool)
	Doc         string
	Params      []ParamInfo
	Destructive bool // has [confirm]/destructive => DestructiveHint
	Network     bool // has [network] => OpenWorldHint
}

TaskInfo is the agent-facing view of a task. Private tasks are never included.

Jump to

Keyboard shortcuts

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