mcp

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp serves orch's state to an agent as MCP tools over stdio.

Why this exists

Until now an agent reported back by shelling out: `scripts/task-finish.sh` runs `orch task-status … done`, and the dispatch prompt says so in as many words. That works, but it is a one-way pipe — the agent can *write* a status and nothing else. It cannot ask what its dependencies decided, what its own spec ref is, how much budget is left, or what the run has been doing. Every one of those answers already exists in the project's database; the scripts just have no way to ask for them.

These tools are that surface. The three the scripts already cover (`orch_set_status`, `orch_block`) keep exactly the shape the scripts have, so G6.6 can offer MCP first and fall back to the scripts without either side learning a new vocabulary:

scripts/task-start.sh  ID                      -> orch_set_status{task_id, status:"in-progress"}
scripts/task-finish.sh ID "summary" "author"   -> orch_set_status{task_id, status:"done", note, author}
scripts/task-block.sh  ID "reason"  "author"   -> orch_block{task_id, reason, author}

The other five (`orch_list_tasks`, `orch_get_task`, `orch_budget`, `orch_events`, `orch_context`) are read-only and have no script equivalent at all. `orch_report_finding` queues a report about orch itself for the operator to review and send (#536), and only when the project opted in.

One backend, no second source of truth

The server shares the project's database with the engine rather than opening its own view of the project. It has to: an agent asking "am I still in-progress?" while the run loop is reaping dispatches must get the run loop's answer. Every write goes through `Backend.Transition`, which is the same single-writer path `orch task-status` uses and the same one that enforces the legal-transition table.

Errors an agent can act on

A refused transition is not a protocol error. It is a tool result with `IsError` set, carrying a structured payload that names the current status and every status it may legally move to — because the caller here is a model that can retry, and "illegal transition in-progress -> backlog" without the list is a dead end. See setStatusOut.

Index

Constants

View Source
const (
	FindingsRepo  = findings.Repo
	FindingsLabel = findings.Label
)

FindingsRepo and FindingsLabel are findings.Repo and findings.Label.

View Source
const ServerName = "orch"

ServerName is the name the server reports in `initialize`. It is what an agent's tool list groups these tools under, so it matches the binary.

Variables

This section is empty.

Functions

func NewServer

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

NewServer builds the MCP server with every tool registered.

func Serve

func Serve(ctx context.Context, opts Options) error

Serve runs the server on stdio until ctx is cancelled or stdin closes.

Types

type BudgetReporter

type BudgetReporter = explain.BudgetReporter

BudgetReporter is the slice of *budget.Gate that `orch_budget` and `orch_context` need. Aliased to explain's so there is one definition of "what this server needs from the guardrail" rather than two that must be kept identical by hand.

An interface rather than the concrete gate so a project with no budgets.yaml can pass nil and the tool can answer "not configured" instead of the package having to build a disabled gate to ask.

type FindingsReporter

type FindingsReporter interface {
	SearchIssues(repo, label, query string, limit int) ([]vcs.Issue, error)
}

FindingsReporter is the slice of *vcs.GitHubProvider the tool needs: a search for reports that already exist. It files nothing (#536).

type Options

type Options struct {
	// Project is the opened project; every read and write goes through it
	// (internal/project, #587), to the database shared with the engine.
	Project *project.Project
	// TasksJSON is the path to tasks.json, read for the DAG's shape.
	TasksJSON string
	// ProjectID and ProjectRoot identify the project in `orch_context`.
	ProjectID   string
	ProjectRoot string
	// StateDir is where `orch run` holds its run lock, which orch_task_stop
	// reads to tell whether a run is there to ask.
	StateDir string
	// SpecRoot prefixes a task's specRef. Empty means prompt.DefaultSpecRoot.
	SpecRoot string
	// Budget answers `orch_budget`. Nil means no budgets.yaml, which the
	// tool reports as disabled.
	Budget BudgetReporter
	// Version is reported in `initialize`, so an agent can tell which orch
	// it is talking to.
	Version string
	// Findings searches for reports that already exist. Nil means
	// `report_findings.enabled` is off: the tool is still listed, and says so.
	Findings FindingsReporter
	// Knowledge is knowledge.enabled: off, orch_learn and orch_knowledge_search
	// are still listed, and say so.
	Knowledge bool
}

Options is everything the tools read.

Project is the only required field. The rest degrade: no TasksJSON means the DAG-shaped fields (title, description, files, spec ref, dependencies) come back empty rather than the server refusing to start, which is the right call for a tool whose whole job is answering questions about a project that may be mid-scaffold.

Jump to

Keyboard shortcuts

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