Context-Clean
Context-Clean is a local MCP stdio server for context monitoring, configuration, worker orchestration, and handoff management across Antigravity, Claude Code, Codex, and OpenCode.
Read current session context usage and compare it against role-based limits for orchestrator/solo vs worker agents.
Get or update global/project configuration, including context thresholds, worker/orchestrator models, worker kind, model flag, and handoff directory.
Spawn Herdr workers in split panes with configured models and
CONTEXT_CLEAN_ROLE=worker, and optionally wait or send prompts.List live Herdr panes/agents/tracked workers, stop workers by name or pane ID, and clean up orphaned/dead/completed panes with dry-run support.
Create structured Markdown handoffs with summaries, decisions, files touched, active workers, context usage, and next steps, plus maintain/read
LATEST.mdor specific handoff files.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Context-Clean check context usage and create a handoff if I'm near the limit"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Clean-Context
Sistema unificado multi-agente de control de contexto, herencia (handoff), modo Solo / Orquestador y gestión de workers con herdr para Antigravity (agy), Claude Code y Codex, construido sobre un único Servidor MCP Local (Stdio) en Node.js + TypeScript.
Arquitectura
Antigravity (Plugin) ──┐
Claude Code ──┤
Codex (config.toml) ──┼──▶ MCP Stdio Local (dist/index.js)
OpenCode ──┘ ├── Telemetría: ~/.clean-context/telemetry/*.json
├── OpenCode: API local en vivo (~/.local/state/opencode/service.json)
├── Codex: SQLite (~/.codex/state_5.sqlite)
├── Config: ~/.clean-context/config.json (+ .agents/clean-context.json)
├── Workers: herdr CLI + ~/.clean-context/workers.json
└── Handoff: .agents/handoff/handoff-*.md + LATEST.mdHerramientas MCP expuestas
Herramienta | Propósito |
| Lee el |
| Lee o actualiza umbrales ( |
| Divide un pane en |
| Lista panes, agentes vivos en |
| Cierra limpiamente un worker por nombre o |
| Detecta y cierra terminales huérfanas, colgadas o terminadas ( |
| Genera y lee los |
Related MCP server: herdr-mcp-server
Configuración por defecto (config.default.json)
{
"orchestrator": {
"maxContextPercent": 50,
"model": "claude-opus-4-5"
},
"worker": {
"maxContextPercent": 25,
"kind": "opencode",
"model": "opencode-go/deepseek-v4.1-flash#max",
"modelFlag": "-m"
},
"handoffDir": ".agents/handoff/",
"telemetryDir": "~/.clean-context/telemetry/"
}Modo Solo: aplica
orchestrator.maxContextPercent(50%), higiene de terminales ycreate_handoffal llegar al umbral sin forzar workers.Modo Orquestador: delega subtareas exclusivamente con
herdr_spawnusandoworker.modely vigila que ni el orquestador (50%) ni los workers (25%) superen su límite.
Instalación rápida
Requiere pnpm 10+ (corepack enable pnpm si no lo tienes).
pnpm install
pnpm run build
pnpm run install-globalpnpm run install-global (scripts/install.mjs) realiza backups con timestamp antes de modificar archivos y configura automáticamente:
Antigravity: instala el plugin en
~/.gemini/config/plugins/clean-context/(plugin.json,mcp_config.json,rules/AGENTS.md) y conecta~/.gemini/antigravity-cli/statusline.js.Claude Code: registra
clean-contexten~/.claude.json, añade las reglas en~/.claude/CLAUDE.mdy conecta~/.claude/statusline.js.Codex: registra
[mcp_servers.clean-context]en~/.codex/config.tomly añade las reglas en~/.codex/AGENTS.md.
También puedes usar el plugin o .mcp.json directamente por proyecto copiando plugins/clean-context/, AGENTS.md, CLAUDE.md y .mcp.json.
OpenCode (bridge en vivo)
install-global no configura OpenCode, porque su MCP vive en ~/.config/opencode/opencode.jsonc y no hay statusline. Dos pasos manuales:
// ~/.config/opencode/opencode.jsonc
"mcp": {
"servers": {
"clean-context": {
"type": "local",
"command": ["node", "<repo>/dist/index.js"],
"protocol": "legacy"
}
}
}Y la telemetría: OpenCode no escribe un archivo de statusline, pero src/opencode.ts lee su API local en vivo. get_context_status descubre el servicio en ~/.local/state/opencode/service.json (url + password), resuelve la sesión por cwd y calcula el mismo número que muestra la TUI:
contexto usado = tokens.input + tokens.cache.read (último mensaje assistant cerrado)
% = usado / model.limit.context * 100Verificado contra la barra de OpenCode: 182.7K (18%) → 182.7K / 1,000,000. Si OpenCode no está corriendo o no hay sesión para ese cwd, cae a las fuentes por archivo (Antigravity, Codex) como siempre.
Pruebas
pnpm testEjecuta la suite end-to-end (tests/run-tests.mjs):
Generación de telemetría desde
statusline.jsConexión MCP stdio real (
@modelcontextprotocol/sdk)Validación de umbrales
orchestratorvsworkerCreación y lectura de handoff en
.agents/handoff/Consultas y ciclo real
split+herdr_stopcontra el servidorherdractivo
Available Tools
9 toolscreate_handoffB
Generates a structured Markdown handoff file in handoffDir (plus LATEST.md) capturing summary, decisions, files touched, active workers, and the exact next step.
Inputs: summary (required), nextStep (required), cwd, role, +5 more.
get_configB
Returns the active Context-Clean configuration (merged global + optional project override) and config file paths.
Inputs: cwd.
get_context_statusB
Reads the current agent/session statusline telemetry and compares used context % against the configured limit for the agent's role (orchestrator/solo vs worker).
Inputs: cwd, role, client, sessionId.
herdr_cleanupC
Detects and closes orphaned, dead, or completed worker panes in Herdr, and prunes stale worker records.
Inputs: force, dryRun, includeIdle.
herdr_spawnC
Spawns a worker in a split Herdr pane using the configured worker.model and worker.kind, injecting CONTEXT_CLEAN_ROLE=worker.
Inputs: name (required), cwd, kind, wait, +5 more.
herdr_statusC
Lists live Herdr panes, agents, and tracked Context-Clean workers.
Inputs: name, workspaceId.
herdr_stopC
Cleanly stops a worker by closing its Herdr pane and removing it from tracked workers.
Inputs: name, paneId.
read_handoffC
Reads the latest handoff Markdown file (or a specific handoff file) from handoffDir.
Inputs: cwd, fileName.
update_configC
Updates Context-Clean configuration (maxContextPercent, models, handoffDir) globally or for the current project.
Inputs: cwd, scope, handoffDir, workerKind, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool maps to a recognizable action within one of three clear sub-domains (config, Herdr workers, handoffs/status). The only mild overlap is between herdr_status (pane/worker inventory) and get_context_status (statusline telemetry vs. context limit), but the descriptions make the distinction reasonably clear.
Most tools follow a predictable verb_noun pattern (get_config, update_config, create_handoff, read_handoff, get_context_status). The Herdr group uses a namespace prefix plus verb (herdr_spawn, herdr_stop, herdr_status, herdr_cleanup), which is a minor but coherent deviation that actually aids grouping.
Nine tools is well within the ideal 3-15 range and each one covers a distinct operation: two config, four worker lifecycle, one status check, two handoff operations. No tool feels redundant or superfluous for the stated purpose.
Worker lifecycle (spawn/status/stop/cleanup) and handoff persistence (create/read) are well covered, and config has read/update. Minor gaps exist: no list_handoffs or handoff pruning, and no config reset/delete, but read_handoff accepts a specific file so agents can work around the listing gap.
Maintenance
Related MCP Connectors
Task coordination for AI agents. Exclusive locks, shared files, handoffs, per-agent spending limits.
Design, build and run teams of AI agents with checked handoffs between them.
Task and sprint coordination for humans and AI agents, with scoped API keys and full audit trail.
Shared task layer for AI agents: tasks, handoffs and decisions that persist across tools.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceCoordinates up to 64 parallel expert agents for complex multi-agent orchestration and intelligent task routing within Claude Code. It enables users to analyze requests, manage hierarchical execution plans, and monitor active orchestration sessions.MIT

herdr-mcp-serverofficial
AlicenseNot gradedqualityCmaintenanceEnables a chat or voice assistant to drive coding agents running in herdr: it can start an agent on a task, list and watch sessions started anywhere, send follow-ups, answer an agent's questions and approve or refuse its permission prompts. Long-running work is reported back through webhook callbacks so the conversation can continue without blocking.MIT- AlicenseBqualityCmaintenanceEnables AI agents to start, monitor, follow up on, stop, and collect results from headless Claude Code CLI sessions, with queuing, budgets, locks, and wake-up notifications.9MIT
- AlicenseNot gradedqualityCmaintenanceEnables coordinating local coding agents across Antigravity, DeepSeek Harness, Claude Code, and OpenCode with persistent tasks, live public events, file-change artifacts, session follow-ups, process-tree cancellation, and configurable execution permissions.MIT