envmcp

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package envmcp implements the `codex-app-gateway env-mcp` subcommand: a stateless MCP server that codex spawns as a child process. It exposes a fixed tool set (list_environments, shell, exec_command, write_stdin, read_output, terminate, read_file, apply_patch) to codex; tool calls are multiplexed across the workspace's connected executors via a per-exe BridgeClient pool keyed by environment name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, args RunArgs, stdin io.Reader, stdout, stderr io.Writer, logger *slog.Logger) error

Run constructs the bridge.Pool, builds the tool registry, and serves the MCP loop on stdin/stdout until EOF or context cancellation.

stdout is the MCP JSON-RPC stream; do not write to it from outside MCPServer.Serve. Diagnostic output flows through logger (gateway supervisor pipes our stderr into the pod's stderr with a `[codex-subproc]` prefix). The `stderr` parameter is reserved for future direct writes (e.g., panic dumps) and currently unused.

Types

type MCPServer

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

MCPServer is a minimal newline-delimited JSON-RPC stdio MCP server that exposes a fixed set of tools through a registry. Concurrency: requests are handled sequentially in the order they arrive; this matches the MCP stdio model and keeps the server free of intra-process synchronization other than the write-mutex.

func NewMCPServer

func NewMCPServer(name string, ts []tools.Tool, logger *slog.Logger) *MCPServer

NewMCPServer constructs a server bound to a registry. Tool order is preserved as supplied (LLM clients sometimes rely on consistent ordering for caching).

func (*MCPServer) Serve

func (s *MCPServer) Serve(ctx context.Context, in io.Reader, out io.Writer) error

Serve reads requests from in until EOF and writes responses to out. Returns nil on clean EOF, error on unrecoverable read/write failure.

type RunArgs

type RunArgs struct {
	WorkspaceID        string // --workspace-id
	ExecGatewayURL     string // --exec-gateway-url; pool appends /<exe_id>
	AppGatewayInternal string // --app-gateway-internal; list_environments calls /internal/connected here
	WorkspaceTokenEnv  string // --workspace-token-env (workspace-scoped cap token)
	LoopbackTokenEnv   string // --loopback-token-env (for /internal/connected)
	// ExecGatewayInternalURL is the http(s):// base for codex-exec-gateway's
	// internal API (NOT the ws /bridge URL). copy_path's HTTP relay path
	// POSTs to <base>/api/exec-gateway/relay/create here. Empty disables
	// the HTTP relay path; copy_path falls back to the ws cat-pump.
	ExecGatewayInternalURL    string // --exec-gateway-internal-url
	ExecGatewayInternalSecret string // --exec-gateway-internal-secret-env (env var name; value injected by gateway)
}

RunArgs is the parsed CLI input for `codex-app-gateway env-mcp`. Per the 2026-05-16 fixed-tools redesign, env-mcp is workspace-scoped rather than per-executor; one child binary handles every executor in the workspace via environment_id routing.

Jump to

Keyboard shortcuts

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