agent-mux

agent-mux

MCP server that manages interactive CLI agent pools using tmux, enabling creation, control, and communication with agents like Claude and Codex.

Category
Visit Server

README

I have a new version which name is Hydra,more powerful,see detail in https://github.com/JinchengGao-Infty/Hydra?tab=readme-ov-file

Agent Mux

Agent Mux is a tmux-backed agent pool plus a small MCP (Model Context Protocol) server. It manages “projects” as tmux sessions, and spawns each interactive agent as a tmux window so you can:

  • Create/list/switch/close projects (tmux sessions)
  • Spawn/list/attach/interrupt/kill agents (tmux windows)
  • Send text to an agent (type + Enter)
  • Read output from an agent (via tmux capture-pane)

This repo keeps the agent-mux implementation under lib/agent-mux/, and exposes it as MCP tools via servers/agent-mux-server.mjs.

Why tmux?

tmux provides durable sessions you can inspect manually, and a simple way to capture rendered terminal output—making it a practical substrate for orchestrating interactive CLI agents.

Features

  • Dedicated tmux socket: uses tmux -L ccx ... so it won’t interfere with your default tmux
  • One project = one session, one agent = one window (single pane)
  • Persistent registry under .ccx/projects/<project>/agents.json
  • Per-agent log file via pipe-pane to .ccx/projects/<project>/logs/<agent>.log
  • Conservative name validation for projects and agents

Requirements

  • Node.js 18+ (ESM)
  • tmux in PATH
  • Optional agent CLIs (only needed if you use default commands):
    • claude (default args: --dangerously-skip-permissions)
    • codex (default args: --yolo)
    • gemini (default args: --yolo)

Installation

From the repo root:

npm install

Quick start (manual tmux)

After you create a project and spawn agents, you can inspect the tmux session:

tmux -L ccx attach -t <project>
# Detach without closing: Ctrl-b d
# Switch windows: Ctrl-b 0/1/2/...

Quick start (MCP server)

Run the MCP server (stdio):

node servers/agent-mux-server.mjs

Then register it in your MCP client as a stdio server. Example (client formats vary):

{
  "mcpServers": {
    "agent-mux": {
      "command": "node",
      "args": ["servers/agent-mux-server.mjs"]
    }
  }
}

Usage examples

Via MCP tools

Typical flow:

  1. Create/select a project
  • create_project({ "name": "my-project", "cwd": "/path/to/workdir" })
  • switch_project({ "name": "my-project" })
  1. Spawn an agent
  • spawn_agent({ "type": "codex", "name": "codex-1" })
  1. Talk to it
  • send_to_agent({ "name": "codex-1", "text": "hello" })
  1. Read output
  • read_agent_output({ "name": "codex-1", "lines": 50 })

As a library (Node.js)

import { AgentMux } from "./lib/agent-mux/index.mjs";

const mux = new AgentMux({ projectRoot: process.cwd(), tmuxSocketName: "ccx" });

mux.create_project("my-project", process.cwd());
mux.spawn_agent("codex", "codex-1");
mux.send_to_agent("codex-1", "hello");

const { output } = mux.read_agent_output("codex-1", 50);
console.log(output);

MCP tools

The MCP server exposes these tools (names match the AgentMux methods):

Project management

  • create_project({ name, cwd? })
  • list_projects({})
  • switch_project({ name })
  • close_project({ name })

Agent management

  • spawn_agent({ type, name, options? })
  • list_agents({ project? })
  • attach_agent({ name })
  • interrupt_agent({ name })
  • kill_agent({ name })

Agent I/O

  • send_to_agent({ name, text })
  • read_agent_output({ name, lines? })
  • send_to_window({ window, text })

API (library)

Naming rules

Project names and agent names must match:

  • ^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$

new AgentMux(options?)

  • options.projectRoot (string): base dir used for registry/log storage; default process.cwd()
  • options.tmuxSocketName (string): tmux socket name for tmux -L; default ccx
  • options.tmuxBinary (string): tmux binary; default tmux

Project management

  • create_project(name, cwd?){ project, cwd, created, storageDir }
  • list_projects()Array<{ project, cwd, sessionExists, hasRegistry, current }>
  • switch_project(name){ project, switched, clients }
  • close_project(name){ project, killed, clearedCurrent }

Agent management

  • spawn_agent(type, name, options?) → agent entry (tmux window + registry + log path)
    • type: one of claude / codex / gemini
    • options.cwd (string): agent working dir (defaults to project cwd)
    • options.command / options.cmd (string): override executed command
    • options.args (string[]): extra args appended to defaults (or used with custom command)
  • list_agents(project?){ project, agents: [...entries with alive:boolean] }
  • attach_agent(name){ project, agent, attached, clients }
  • interrupt_agent(name){ project, agent, interrupted } (sends Ctrl+C)
  • kill_agent(name){ project, agent, killed }

Agent I/O

  • send_to_agent(name, text){ project, agent, sent, bytes }
  • send_to_window(window, text){ project, window, sent, bytes }
  • read_agent_output(name, lines=200){ project, agent, lines, output }

Storage layout

By default, Agent Mux stores state under projectRoot/.ccx/projects/:

.ccx/projects/<project>/
  project.json
  agents.json
  logs/<agent>.log
.ccx/projects/current.json

If .ccx/ is not writable, it falls back to ${os.tmpdir()}/ccx-agent-mux/projects/.

License (MIT)

MIT License

Copyright (c) 2026 Agent Mux Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured