mcp

package
v1.17.13 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mcp provides an MCP (Model Context Protocol) server for initech, exposing agent primitives over streamable HTTP. External LLM clients connect to observe and control agents via standard MCP tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddInput added in v1.2.0

type AddInput struct {
	Role string `json:"role" jsonschema:"role name for the new agent (e.g. eng3)"`
}

AddInput is the input schema for the initech_add tool.

type AddOutput added in v1.2.0

type AddOutput struct {
	Status string `json:"status"`
	Agent  string `json:"agent"`
}

AddOutput is the output schema for the initech_add tool.

type AgentInput added in v1.2.0

type AgentInput struct {
	Agent string `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
}

AgentInput is the input schema for tools that take only an agent name.

type AgentOutput added in v1.2.0

type AgentOutput struct {
	Status string `json:"status"`
}

AgentOutput is the output schema for lifecycle tools.

type AssignInput added in v1.15.0

type AssignInput struct {
	Agent   string   `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
	BeadID  string   `json:"bead_id,omitempty" jsonschema:"single bead ID (backwards compat)"`
	BeadIDs []string `json:"bead_ids,omitempty" jsonschema:"one or more bead IDs to assign"`
	Message string   `json:"message,omitempty" jsonschema:"custom instructions appended to the dispatch message"`
}

AssignInput is the input schema for the initech_assign tool.

type AssignOutput added in v1.15.0

type AssignOutput struct {
	Status string `json:"status"`
}

AssignOutput is the output schema for the initech_assign tool.

type AtInput added in v1.2.0

type AtInput struct {
	Agent   string `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
	Message string `json:"message" jsonschema:"text to send to the agent terminal"`
	Delay   string `json:"delay" jsonschema:"delay before sending, as a Go duration (e.g. 5m, 30s, 1h)"`
}

AtInput is the input schema for the initech_at tool.

type AtOutput added in v1.2.0

type AtOutput struct {
	Status  string `json:"status"`
	TimerID string `json:"timer_id"`
}

AtOutput is the output schema for the initech_at tool.

type DeliverInput added in v1.15.0

type DeliverInput struct {
	BeadID  string `json:"bead_id" jsonschema:"bead ID to deliver (e.g. ini-abc)"`
	Pass    *bool  `json:"pass,omitempty" jsonschema:"mark ready_for_qa (default true)"`
	Reason  string `json:"reason,omitempty" jsonschema:"failure reason (used when pass=false)"`
	To      string `json:"to,omitempty" jsonschema:"agent to report to (default super)"`
	Message string `json:"message,omitempty" jsonschema:"custom note appended to the report"`
}

DeliverInput is the input schema for the initech_deliver tool.

type DeliverOutput added in v1.15.0

type DeliverOutput struct {
	Status string `json:"status"`
}

DeliverOutput is the output schema for the initech_deliver tool.

type InterruptInput added in v1.15.0

type InterruptInput struct {
	Agent string `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
	Hard  bool   `json:"hard,omitempty" jsonschema:"send Ctrl+C instead of Escape (default false)"`
}

InterruptInput is the input schema for the initech_interrupt tool.

type InterruptOutput added in v1.15.0

type InterruptOutput struct {
	Status string `json:"status"`
}

InterruptOutput is the output schema for the initech_interrupt tool.

type NotifyInput added in v1.10.0

type NotifyInput struct {
	Message string `json:"message" jsonschema:"notification message text"`
	Kind    string `json:"kind,omitempty" jsonschema:"event kind (default custom). Dot-notation encouraged: deploy, release, milestone"`
	Agent   string `json:"agent,omitempty" jsonschema:"agent name to attribute the notification to"`
}

NotifyInput is the input schema for the initech_notify tool.

type NotifyOutput added in v1.10.0

type NotifyOutput struct {
	Status string `json:"status"`
}

NotifyOutput is the output schema for the initech_notify tool.

type PaneHandle

type PaneHandle interface {
	Name() string
	PeekContent(lines int) string
	SendText(text string, enter bool)
	Activity() string
	IsAlive() bool
	IsVisible() bool
	BeadID() string
	MemoryRSSKB() int64
}

PaneHandle is a minimal interface for interacting with a single pane. The MCP package uses this to avoid importing internal/tui directly.

type PaneHost

type PaneHost interface {
	// FindPane returns the pane with the given name, or nil if not found.
	// The bool is false if the host is shutting down.
	FindPane(name string) (PaneHandle, bool)

	// RestartAgent restarts the named agent's process. Returns an error if the
	// agent is not found or the restart fails.
	RestartAgent(name string) error

	// StopAgent stops the named agent's process. Returns an error if the agent
	// is not found. Stopping an already-stopped agent is a no-op.
	StopAgent(name string) error

	// StartAgent starts a previously stopped agent. Returns an error if the
	// agent is not found or the start fails. Starting an already-running agent
	// is a no-op.
	StartAgent(name string) error

	// AddAgent hot-adds a new agent pane with the given role name.
	AddAgent(name string) error

	// RemoveAgent removes the named agent pane. Returns an error if the
	// pane is not found or is the last remaining pane.
	RemoveAgent(name string) error

	// InterruptAgent sends a raw control byte to the named agent's PTY.
	// hard=true sends Ctrl+C (0x03), false sends Escape (0x1B).
	InterruptAgent(name string, hard bool) error

	// ScheduleSend schedules a message to be sent to an agent after a delay.
	// The delay is a Go duration string (e.g. "5m", "30s"). Returns the
	// timer ID on success.
	ScheduleSend(agent, message, delay string) (string, error)

	// AllPanes returns all panes. The bool is false if the host is shutting down.
	AllPanes() ([]PaneHandle, bool)

	// NotifyConfig returns the webhook URL and project name for posting
	// notifications. Returns empty strings if not configured.
	NotifyConfig() (webhookURL, project string)

	// AnnounceConfig returns the Agent Radio announce URL and project name.
	// Returns empty strings if not configured.
	AnnounceConfig() (announceURL, project string)

	// SetBead registers a bead ID on a pane for display in the TUI overlay.
	SetBead(agent, beadID string) error
}

PaneHost provides pane lookup and lifecycle operations for MCP tool handlers.

type PatrolInput added in v1.2.0

type PatrolInput struct {
	Lines int `json:"lines,omitempty" jsonschema:"number of lines per agent (default 20)"`
}

PatrolInput is the input schema for the initech_patrol tool.

type PatrolOutput added in v1.2.0

type PatrolOutput struct {
	Content string `json:"content"`
}

PatrolOutput is the output schema for the initech_patrol tool.

type PeekInput

type PeekInput struct {
	Agent string `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
	Lines int    `json:"lines,omitempty" jsonschema:"number of lines to return (default 50)"`
}

PeekInput is the input schema for the initech_peek tool. Fields without omitempty are required in the JSON Schema.

type PeekOutput

type PeekOutput struct {
	Content string `json:"content"`
}

PeekOutput is the output schema for the initech_peek tool.

type RemoveInput added in v1.2.0

type RemoveInput struct {
	Agent string `json:"agent" jsonschema:"agent name to remove"`
}

RemoveInput is the input schema for the initech_remove tool.

type RemoveOutput added in v1.2.0

type RemoveOutput struct {
	Status string `json:"status"`
}

RemoveOutput is the output schema for the initech_remove tool.

type SendInput

type SendInput struct {
	Agent   string `json:"agent" jsonschema:"target agent name (e.g. eng1)"`
	Message string `json:"message" jsonschema:"text to send to the agent terminal"`
	Enter   *bool  `json:"enter,omitempty" jsonschema:"press Enter after the message (default true)"`
}

SendInput is the input schema for the initech_send tool.

type SendOutput

type SendOutput struct {
	Status string `json:"status"`
}

SendOutput is the output schema for the initech_send tool.

type Server

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

Server is an MCP server that exposes initech agent primitives over streamable HTTP. It wraps the official go-sdk MCP server with bearer token authentication.

func NewServer

func NewServer(port int, bind, token string, host PaneHost, logger *slog.Logger) *Server

NewServer creates an MCP server bound to the given address and port. The token is required for bearer auth on every request. If port is 0, the OS assigns a free port. If bind is empty, defaults to "0.0.0.0". The host provides pane access for tool handlers.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the address the server is bound to. Only meaningful after Start has been called.

func (*Server) MarkPaneDirty added in v1.3.0

func (s *Server) MarkPaneDirty(name string)

MarkPaneDirty signals that a pane's terminal output has changed. The notification is debounced (1 per second per pane) to avoid flooding clients. No-op if no clients are subscribed to the pane's output resource.

func (*Server) NotifyAgentStateChanged added in v1.3.0

func (s *Server) NotifyAgentStateChanged(name string)

NotifyAgentStateChanged signals that an agent's state has changed (activity toggle, bead claimed/cleared, etc.). Fires notifications for both the fleet status resource and the per-agent status resource.

func (*Server) NotifyResourcesChanged added in v1.3.0

func (s *Server) NotifyResourcesChanged()

NotifyResourcesChanged triggers a resources/list_changed notification to all connected MCP clients. Call this when panes are hot-added or removed so clients re-fetch the agent status resource.

func (*Server) Shutdown

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

Shutdown gracefully stops the server and the debounce goroutine.

func (*Server) Start

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

Start begins listening and serving. It blocks until the server is shut down or a fatal listen error occurs. Returns nil on clean shutdown.

type StatusInput added in v1.2.0

type StatusInput struct{}

StatusInput is the input schema for the initech_status tool (no params).

type StatusOutput added in v1.2.0

type StatusOutput struct {
	Content string `json:"content"`
}

StatusOutput is the output schema for the initech_status tool.

Jump to

Keyboard shortcuts

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