mcp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 7 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 PaneHandle

type PaneHandle interface {
	Name() string
	PeekContent(lines int) string
	SendText(text string, enter bool)
}

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)
}

PaneHost provides pane lookup for the MCP tool handlers.

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 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) Shutdown

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

Shutdown gracefully stops the server.

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.

Jump to

Keyboard shortcuts

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