mcpserver

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 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 mcpserver exposes devrun to AI agents as a Model Context Protocol server. Claude Code, Codex and other MCP clients launch `devrun mcp` and talk to it over stdio.

Every tool is a bounded request/response: nothing follows, attaches or opens the TUI, so no call can hang the agent. Each resolves its config afresh from an optional project_dir (default: the directory the agent launched the server in) and reports which file it used, so an agent that addressed the wrong scope sees it in the result. The work itself is internal/ops — the same code the CLI runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(version string, opts Options) *mcp.Server

New builds the devrun MCP server.

Types

type AddServiceInput

type AddServiceInput struct {
	Scoped
	Name    string            `json:"name" jsonschema:"Name for the new service: letters, digits, '.', '_' or '-'."`
	Command string            `json:"command" jsonschema:"Shell command that runs the service in the foreground, e.g. 'npm run dev'. It is run with sh -c."`
	CWD     string            `` /* 143-byte string literal not displayed */
	Env     map[string]string `json:"env,omitempty" jsonschema:"Environment variables to set for the service."`
}

type AddServiceOutput

type AddServiceOutput struct {
	Origin
	Service ServiceDef `json:"service"`
}

type AddToTargetInput

type AddToTargetInput struct {
	Scoped
	Target   string   `json:"target" jsonschema:"The target to add to. It is created if it does not exist."`
	Services []string `json:"services" jsonschema:"Services to add. Each must already be defined in the same config."`
}

type AddToTargetOutput

type AddToTargetOutput struct {
	Origin
	Target  string   `json:"target"`
	Members []string `json:"members" jsonschema:"The target's members after the change."`
}

type ListInput

type ListInput struct {
	Scoped
}

type ListOutput

type ListOutput struct {
	Origin
	DaemonRunning bool          `json:"daemon_running" jsonschema:"False when the state shown is the last saved one because the daemon could not be reached."`
	Services      []ServiceInfo `json:"services"`
	Targets       []TargetInfo  `json:"targets"`
}

type LogsInput

type LogsInput struct {
	Scoped
	Name  string `json:"name" jsonschema:"The service name."`
	Lines int    `json:"lines,omitempty" jsonschema:"How many lines to return, from the end of the log. Default 100, at most 1000."`
	Grep  string `json:"grep,omitempty" jsonschema:"Only return lines containing this text, case-insensitively; lines then counts matches."`
}

type LogsOutput

type LogsOutput struct {
	Origin
	Name      string   `json:"name"`
	Lines     []string `json:"lines" jsonschema:"Oldest first, as plain text with terminal control sequences removed."`
	Truncated bool     `` /* 128-byte string literal not displayed */
	LogPath   string   `json:"log_path"`
}

type Options

type Options struct {
	// Dir is the project directory a call uses when it gives no project_dir —
	// normally the server's working directory, which is where the agent was
	// launched.
	Dir string
}

Options configures the server.

type Origin

type Origin struct {
	Source string `json:"source" jsonschema:"The config file that was read or written."`
	Scope  string `json:"scope" jsonschema:"project (a devrun.yaml) or global (the user's registry)."`
}

Origin is the part of every tool's result that says which config was used.

type Scoped

type Scoped struct {
	ProjectDir string `` /* 207-byte string literal not displayed */
	Global     bool   `json:"global,omitempty" jsonschema:"Use the global registry even when project_dir has a devrun.yaml."`
}

Scoped is the part of every tool's input that picks the config.

type ServiceDef

type ServiceDef struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	CWD     string   `json:"cwd"`
	EnvKeys []string `json:"env_keys,omitempty"`
}

type ServiceInfo

type ServiceInfo struct {
	Name     string   `json:"name"`
	State    string   `json:"state" jsonschema:"running, starting, stopping, stopped, crashed or exited."`
	PID      *int     `json:"pid,omitempty"`
	Port     *int     `json:"port,omitempty" jsonschema:"The TCP port it listens on, once detected."`
	UptimeS  int64    `json:"uptime_s,omitempty"`
	CPUPct   float64  `json:"cpu_pct,omitempty"`
	MemBytes int64    `json:"mem_bytes,omitempty"`
	Targets  []string `json:"targets,omitempty" jsonschema:"Targets this service belongs to."`
}

ServiceInfo is one service's live state.

type StartInput

type StartInput struct {
	Scoped
	Service  string `json:"service,omitempty" jsonschema:"The service to start. Give this or target, not both."`
	Target   string `json:"target,omitempty" jsonschema:"The target whose services to start. Give this or service, not both."`
	Wait     *bool  `` /* 145-byte string literal not displayed */
	TimeoutS int    `json:"timeout_s,omitempty" jsonschema:"How long to wait, in seconds. Default 15, at most 120."`
}

type StartOutput

type StartOutput struct {
	Origin
	Outcome  ops.Outcome          `` /* 191-byte string literal not displayed */
	Services []ops.ServiceOutcome `json:"services" jsonschema:"Each service's outcome; one that did not come up carries its exit code and the end of its log."`
	WaitedMS int64                `json:"waited_ms"`
}

type StatusInput

type StatusInput struct {
	Scoped
	Name string `json:"name" jsonschema:"The service name."`
}

type StatusOutput

type StatusOutput struct {
	Origin
	ServiceInfo
	ExitCode *int     `json:"exit_code,omitempty" jsonschema:"Exit code of the last run, when it crashed or exited."`
	Command  string   `json:"command"`
	CWD      string   `json:"cwd"`
	EnvKeys  []string `json:"env_keys,omitempty" jsonschema:"Names of the environment variables it sets. Values are not returned."`
	LogPath  string   `json:"log_path"`
}

type StopInput

type StopInput struct {
	Scoped
	Service string `json:"service,omitempty" jsonschema:"The service to stop. Give this or target, not both."`
	Target  string `json:"target,omitempty" jsonschema:"The target to stop. Members still held by another running target keep running."`
}

type StopOutput

type StopOutput struct {
	Origin
	Services []StopState `json:"services" jsonschema:"State of each affected service after the stop."`
	Note     string      `json:"note,omitempty"`
}

type StopState

type StopState struct {
	Name  string `json:"name"`
	State string `json:"state"`
}

type TargetInfo

type TargetInfo struct {
	Name    string   `json:"name"`
	Members []string `json:"members"`
	Active  bool     `json:"active" jsonschema:"Started as a target and not stopped since."`
}

TargetInfo is one target and whether it is active.

Jump to

Keyboard shortcuts

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