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 ¶
- func New(version string, opts Options) *mcp.Server
- type AddServiceInput
- type AddServiceOutput
- type AddToTargetInput
- type AddToTargetOutput
- type GatewayInfo
- type GatewayStatusInput
- type GatewayStatusOutput
- type ListInput
- type ListOutput
- type LogsInput
- type LogsOutput
- type Options
- type Origin
- type Scoped
- type ServiceDef
- type ServiceInfo
- type StartInput
- type StartOutput
- type StatusInput
- type StatusOutput
- type StopInput
- type StopOutput
- type StopState
- type TargetInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 AddToTargetOutput ¶
type GatewayInfo ¶ added in v0.5.0
type GatewayInfo struct {
Running bool `json:"running"`
Addr string `json:"addr,omitempty" jsonschema:"The address it listens on."`
Posture string `` /* 199-byte string literal not displayed */
Mode string `json:"mode,omitempty" jsonschema:"subdomain or path: which URL shape the index advertises."`
Exposed []string `json:"exposed,omitempty" jsonschema:"Services that may leave this machine. Empty means none may."`
PublicURL string `json:"public_url,omitempty" jsonschema:"The tunnel's public address, when devrun is running one."`
TunnelKind string `json:"tunnel_kind,omitempty" jsonschema:"named or quick. A quick tunnel's URL changes every run."`
}
GatewayInfo is what the gateway is doing, and — the part that matters — whether anything off this machine can reach it.
type GatewayStatusInput ¶ added in v0.5.0
type GatewayStatusInput struct {
Scoped
}
GatewayStatusInput takes a scope and nothing else: this reads, it does not publish. A tool that could publish would need OpenWorldHint and must never be auto-approvable.
type GatewayStatusOutput ¶ added in v0.5.0
type GatewayStatusOutput struct {
Origin
Gateway GatewayInfo `json:"gateway"`
}
GatewayStatusOutput is the gateway, or Running false when there is none.
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"`
Gateway *GatewayInfo `json:"gateway,omitempty" jsonschema:"Absent when the gateway is not running, so no service has a URL."`
}
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 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 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."`
URL string `` /* 196-byte string literal not displayed */
}
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 StatusInput ¶
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 StopOutput ¶
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.