Add v2 Development section covering multi-node fleet design (master, agent self-registration, tier-based placement, edge routing). Update project structure to reflect new agent subsystems (edge_rpc, dns, proxy, certs). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.7 KiB
3.7 KiB
CLAUDE.md
Project Overview
MCP (Metacircular Control Plane) is the orchestrator for the Metacircular platform. It manages container lifecycle, tracks what services run where, and transfers files between the operator's workstation and managed nodes.
Architecture
MCP has two components:
- CLI (
mcp) — thin client on the operator's workstation. Reads local service definition files, pushes intent to agents, queries status. No database. - Agent (
mcp-agent) — smart per-node daemon. Manages containers via podman, stores the registry (SQLite), monitors for drift, alerts the operator.
Services have one or more components (containers). Container naming: <service>-<component>.
v2 Development (Multi-Node)
MCP v2 extends the single-node agent model to a multi-node fleet with a central master process. See the root repo's docs/phase-e-plan.md and docs/architecture-v2.md for the full design.
Current state:
- svc is operational as an edge node (manages mc-proxy routing only, no containers)
- rift runs the agent with full container management
- orion is provisioned but offline for maintenance
Key v2 concepts (in development):
- mcp-master — central orchestrator on rift. Accepts CLI commands, dispatches to agents, maintains node registry, coordinates edge routing.
- Agent self-registration — agents register with the master on startup (name, role, address, arch). No static node config required after bootstrap.
- Tier-based placement —
tier = "core"runs on the master node,tier = "worker"(default) is auto-placed on a worker with capacity,node = "<name>"overrides for pinned services. - Edge routing —
public = trueon routes declares intent; the master assigns the route to an edge node (currently svc).
Build Commands
make all # vet → lint → test → build both binaries
make build # go build ./...
make test # go test ./...
make vet # go vet ./...
make lint # golangci-lint run ./...
make proto # regenerate gRPC code from .proto files
make proto-lint # buf lint + buf breaking
make mcp # build CLI binary
make mcp-agent # build agent binary
make clean # remove binaries
Run a single test: go test ./internal/registry/ -run TestComponentCRUD
Project Structure
cmd/mcp/— CLI entry pointcmd/mcp-agent/— Agent entry pointinternal/agent/— Agent core (deploy, lifecycle, sync, adopt, status, files, edge_rpc, dns, proxy, certs)internal/runtime/— Container runtime abstraction (podman)internal/registry/— SQLite registry (services, components, events)internal/monitor/— Monitoring subsystem (watch loop, alerting)internal/servicedef/— Service definition file parsing (TOML)internal/auth/— MCIAS integration (token validation, interceptor)internal/config/— Configuration loading (CLI + agent)proto/mcp/v1/— Proto definitionsgen/mcp/v1/— Generated Go gRPC code
Critical Rules
- Agent is gRPC-only (no REST). This is a deliberate exception to the platform's REST+gRPC parity rule.
- Container naming convention:
<service>-<component>(e.g.,metacrypt-api,metacrypt-web). - File operations are scoped to
/srv/<service>/. Path traversal is rejected. - Alert commands use exec-style invocation (argv array, no shell). Never use
sh -c. - The agent binds to the overlay interface only, not all interfaces. It does NOT sit behind MC-Proxy.
- Every RPC is audit-logged at info level (method, caller, timestamp).
active: true/falsein service definitions controls desired state.mcp stop/startupdate the file.
Module Path
git.wntrmute.dev/mc/mcp