Metadata-Version: 2.4
Name: symm-mcp
Version: 0.3.7
Summary: A lightweight, symmetric, asynchronous MCP channel for handing work between independent agents.
Keywords: mcp,model-context-protocol,agents,claude-code,async,handoff
Author: tacticaldoll
License-Expression: Apache-2.0 OR MIT
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Requires-Dist: agent-client-protocol>=1.0,<1.1
Requires-Dist: mcp>=2.3,<3
Requires-Dist: pydantic>=2.12,<3
Requires-Python: >=3.12
Project-URL: Homepage, https://gitlab.com/116lab/ensemble/symm/symm-mcp
Project-URL: Repository, https://gitlab.com/116lab/ensemble/symm/symm-mcp
Project-URL: Issues, https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/work_items
Project-URL: Changelog, https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/CHANGELOG.md
Project-URL: Security, https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/SECURITY.md
Description-Content-Type: text/markdown

# symm-mcp

Symm is a lightweight asynchronous MCP channel for handing work between independent agents and
re-entering it with fresh attention.

> The work persists. The viewpoint changes.

Any MCP client can dispatch a task to another agent, keep working, and later observe the
result and record a resolution. Symm does not decide who implements and who reviews; that is
expressed in the prompt.

Symm sits between two protocols: toward its caller it is an **MCP server**, and toward the agents
it launches it is an **[Agent Client Protocol](https://agentclientprotocol.com) (ACP) client**.

```text
+-----------+      +----------------------+      +--------------+
| Dispatch  | ---> | Observe              | ---> | Resolve      |
|spawn_task |      |wait_tasks / get_task |      |resolve_task  |
+-----------+      +----------------------+      +-------+------+
       ^                                                 |
       |        Repeat: next task / new viewpoint        |
       +-------------------------------------------------+
```

## Status

0.3.7, the latest release
([changelog](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/CHANGELOG.md)), published on
PyPI as [`symm-mcp`](https://pypi.org/project/symm-mcp/). The package is classified as Alpha.

## How a Task Flows

`spawn_task` returns as soon as the agent process is running. ACP session setup and the prompt
continue after that; the caller can do other work and later read only events it has not seen yet.

```text
Caller                     Symm server                Agent
  | spawn_task(...)              |                       |
  |----------------------------->| start process group   |
  |<-- task_id, status=running --|                       |
  |                              | initialize, new or    |
  |                              | load session, settings|
  |                              |---- prompt over ACP ->|
  |                              |<- updates/permission -|
  | wait_tasks([task_id])        |                       |
  |----------------------------->|                       |
  |                              |<-- turn ends ---------|
  |<-- completed, terminal ------|                       |
  |    (status, final_message,   |                       |
  |     permissions_refused)     |                       |
  :                              :                       :
  : optional, when the outcome is not enough:            :
  | get_task(task_id)            |                       |
  |----------------------------->|                       |
  |<-- usage, session_id, ... ---|                       |
  | get_events(after_seq=cursor) |                       |
  |----------------------------->|                       |
  |<-- page, cursor, has_more ---| repeat until          |
  |                              | has_more is false     |
  :                              :                       :
  | resolve_task(...)            |                       |
  |----------------------------->|                       |
  |<-- task with resolution -----|                       |
```

`wait_tasks` and `get_task` both return the turn's `final_message` (its trailing `agent_message`
text, capped at the last 4,000 characters, with `final_message_truncated` saying whether the cap
cut it) and `permissions_refused`, so the usual path reads the outcome there. `get_task` alone also
returns `usage`. `get_events` pages through the full record when the outcome is not enough, and can
be read while the task runs.

The next task may swap the agent and caller roles.

## Two Independent Axes

Execution status says what happened to the process. Resolution says what a caller concluded
about the result. They never change each other: `succeeded` does not mean `accepted`, and a
resolution can be revised later.

```text
Execution status (owned by Symm)

created --> starting --> running --success--> succeeded
  |           |             |-- failure --> failed
  |           |             +-- cancel/shutdown --> cancelled*
  |           +-- start failure -----------------> failed
  |           +----------------------------------> cancelled
  +----------------------------------------------> cancelled

* If process-group cleanup cannot be confirmed, the task ends as failed.

Resolution (recorded by callers, finished tasks only)

unresolved --resolve_task--> judged
judged --resolve_task--> judged
judged = accepted | rejected | needs_followup | superseded
```

For a clean completion, `succeeded` means the agent's prompt turn ended with stop reason
`end_turn`.
This does not show that the agent did useful work: check for `agent_message` or `tool_call`
events, or verify the work, before accepting it.

## Symmetric by Design

There is no built-in implementer or reviewer role. The same thirteen tools cover every direction
work can travel:

```text
Implement, then verify yourself
  You -- implement X --> Agent
  You <-- result ------ Agent

Implement yourself, ask for review
  You -- review workspace --> Agent
  You <-- findings ------- Agent

Chain or fan out
  Agent A -- implement --> Agent B -- find flaws --> Agent C
      |-- review 1 --> Reviewer 1
      +-- review 2 --> Reviewer 2
```

`initiator_id` and `executor_id` are descriptive labels only. They never grant ownership or
authority.

## Use

Requires [uv](https://docs.astral.sh/uv/), plus the CLI of each agent you use on `PATH`
(`agy`, `claude-agent-acp`, `cline`, `codex-acp`, `copilot`, `cursor-agent`, `opencode`).
Symm does not install, update, or document the installation of agents: install and authenticate
each one following its vendor's instructions
([intent/agent-adapters.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/intent/agent-adapters.md)).
Symm runs the first match for each executable name in the absolute entries of the server's own
`PATH`; which copy and version that is, is up to you.

Register Symm with an MCP client, for example Claude Code:

```bash
claude mcp add symm -- uvx symm-mcp@0.3.7
```

Or in a client's JSON configuration:

```json
{
  "mcpServers": {
    "symm": {
      "command": "uvx",
      "args": ["symm-mcp@0.3.7"]
    }
  }
}
```

A typical loop, as the calling agent sees it:

1. `spawn_task(agent="claude_code", prompt="Review the authentication changes in this
   workspace and list concrete flaws.", workspace="/path/to/repo")` returns a `task_id` while
   the reviewer starts working.
2. Continue with other work.
3. `wait_tasks([task_id])` until it returns `reason` `terminal` with the task in its `completed`
   list. Each call waits at most 30 seconds. Read the outcome there: `status`, `final_message`
   (check `final_message_truncated`) and `permissions_refused`, the count of the task's permission
   requests that were rejected or cancelled.
4. Only when that is not enough, read the record with `get_events(task_id, after_seq=<cursor>)`,
   passing the returned `cursor` back while `has_more` is true; `event_types` narrows what is
   returned. `get_task` adds `usage`.
5. `resolve_task(task_id, resolution="needs_followup", note="two findings to fix")`, then
   dispatch the next task, possibly with the reviewer and implementer roles swapped.
6. When the result is no longer needed, `forget_task(task_id)` frees the task and its events.
   If it was the last remaining task naming an ended or never-kept handle, it also frees that
   kept-agent record. Do this after anything waiting on its `notify_path` has woken, because
   forgetting removes the marker.

### Waiting Without Polling

`spawn_task` returns `notify_path`. When a task ends while the server is running, Symm creates an
empty file at that path. If the server shuts down first, it removes the directory and no marker
appears; read the outcome with `get_task`. A caller whose host wakes it when a
background command ends, as Claude Code does, can run this in the background instead of calling
`wait_tasks` again and again:

```bash
until [ -e "$P" ] || [ ! -d "$(dirname "$P")" ]; do sleep 1; done
```

`P` is the `notify_path`. The loop checks before it waits, because a task can end before
`spawn_task` returns. The file only signals that the task ended. Read the outcome with `get_task`.
If the directory is gone, the server has usually exited. Call `get_task` anyway: if the server
still answers, its base directory was moved, and you can fall back to `wait_tasks`. A server
killed with SIGKILL, or one whose file system stalls during shutdown, can leave the directory
behind, so give the loop your own deadline if the wait must end.

Markers live in a directory of their own for each server process, inside a per-user base:
`$XDG_RUNTIME_DIR/symm-mcp`, or `symm-mcp-<uid>` in the system temporary directory, where `<uid>`
is the effective uid. Pass `--notify-dir DIR` to choose another base, or `--no-notify` to turn
markers off, after the package in the registration above, for example `symm-mcp --no-notify`. If
the base is a symbolic link, is not yours, or is writable by others, Symm logs a warning and starts
with markers off. `notify_path` is `null` when markers are off, whether because of `--no-notify` or
because Symm refused the base at startup
([intent/completion-markers.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/intent/completion-markers.md)).

Agents run in the given workspace with the server's environment plus values their adapter sets;
adapter values override inherited ones. Every agent also receives `SYMM_MCP_DEPTH`, set to the
server's depth plus one, and a server started with `SYMM_MCP_DEPTH` of 1 or more, or a malformed
value, or below a Linux ancestor that carries the nesting marker, lists no tools and says why in
its instructions: an agent Symm launched cannot dispatch further agents through Symm. The
opencode adapter rewrites `OPENCODE_CONFIG_CONTENT` to include its permission configuration. The
`agy` adapter reads `HOME` and writes `$HOME/.gemini/antigravity-cli/symm-mcp/settings.json`
before each `agy` launch. Pass `workspace` explicitly: the
default is the server's working directory, which your MCP client chose and may be your home
directory. Symm does not copy, isolate, or clean workspaces.

## Agents and Permissions

Symm is the Agent Client Protocol (ACP) client for seven agents, and drives every agent over ACP.
The Claude Code and Codex adapters launch the user-installed `claude-agent-acp` and `codex-acp`
executables. Antigravity (`agy`), Copilot, Cline, Cursor, and opencode are launched through their
ACP commands.

The caller's `model` and `effort` choices reach each agent through the interface it accepts. Claude
Code uses ACP session settings `model` and `effort`. Codex and Copilot use `model` and map `effort`
to the session setting `reasoning_effort`. Antigravity (`agy`) uses `model` and maps `effort` to
`thought_level`. Symm checks session settings against the agent's ACP offer before sending the
prompt. Cursor and opencode accept only `model` as a session setting. Cline takes `model` as a
session setting and passes `effort` as the launch flag `--thinking=<effort>`.

| Agent | Executable Symm launches | `options` |
|---|---|---|
| `agy` | `agy acp --cli_dir_name symm-mcp` | `allow`, `model`, `effort` |
| `claude_code` | `claude-agent-acp` | `allow`, `model`, `effort` |
| `codex` | `codex-acp` | `allow`, `model`, `effort` |
| `copilot` | `copilot --acp` | `allow`, `model`, `effort` |
| `cline` | `cline --acp` | `allow`, `model`, `effort` |
| `cursor` | `cursor-agent acp` | `allow`, `model` |
| `opencode` | `opencode acp` | `allow`, `model` |

### Permissions

Symm never widens an agent's permissions on its own: it approves only request kinds in `allow`,
never chooses an "always" option, and pins the permission settings the caller cannot set. Actions
an agent takes without sending Symm a permission request are outside what Symm observes or
enforces. Broader enforcement, such as sandboxing, belongs to the caller or an external policy
layer.

- **Symm answers agent-sent permission requests.** The `allow` option lists ACP tool kinds approved
  for this task: `read`, `edit`, `delete`, `move`, `search`, `execute`, `think`,
  `fetch`, and `other`. For an allowed kind, Symm chooses a one-time allow option;
  otherwise it chooses a one-time reject option. It never chooses an option that applies
  always. Mode-switch requests are never granted. If the one-time option it needs is not
  offered, Symm cancels the request. A decision Symm cannot record is cancelled, and the
  task fails. Each prompt-turn decision is recorded as a `permission` event. A request
  outside the prompt turn is cancelled without an event.
- **Permission settings are pinned.** Before the prompt, Symm sets Antigravity (`agy`)
  `mode=default`, Claude Code `mode=default`, Codex `mode=read-only`, Copilot its `agent` mode
  and then `allow_all=off`, and Cline `auto_approve=false`. Copilot's `autopilot` mode turns
  allow-all on and continues the turn on its own, and a resumed Copilot session keeps its saved
  mode. Cursor is pinned to `mode=agent` only when `allow` contains `edit`; otherwise its mode is
  `plan`. The opencode adapter is pinned to `mode=build` and configured to ask before edits, shell
  commands, and web fetches. Callers cannot set these pinned settings. If an ACP agent does not
  offer a setting or value Symm must pin, the task fails before the prompt and records an `error`
  event naming it. The `agy` adapter launches with `--cli_dir_name symm-mcp` and writes
  `toolPermission: "strict"` and `permissions.allow: []` to
  `$HOME/.gemini/antigravity-cli/symm-mcp/settings.json` before each launch; a missing or relative
  `HOME`, or an unwritable or symlinked settings path, fails the launch before any prompt. The
  opencode adapter's ask rules are supplied through `OPENCODE_CONFIG_CONTENT`:
  Symm preserves the user's other inline configuration, overrides those permission entries, and
  rejects a value that is not a JSON object. An empty value, or one of only JSON whitespace, counts
  as unset.
- **Cursor has a mode-specific limitation.** Symm pins Cursor to `plan` when `allow` lacks `edit`;
  in `plan` mode Cursor itself writes no files and runs no commands. In `agent` mode Cursor creates
  and edits files without asking, so Symm selects it only when `allow` includes `edit`. Cursor
  labels file deletions as `edit`, so allowing `edit` also allows deletion.
- **Launch flags are checked against no offer.** Cline's `effort` launch flag accepts `none`,
  `low`, `medium`, `high`, or `xhigh`; Symm refuses any other value with `invalid_request:` and
  creates no task. Model and effort session settings are checked against the agent's offer before
  the prompt.

## Tools

| Tool | What it does |
|---|---|
| `describe_agent` | Reads an agent's advertised model and effort offers, how each choice is delivered, the settings Symm pins, its `launch` profile, and supported `session_operations`. Creates no task. |
| `list_sessions` | Lists the sessions an agent can resume from a workspace, one page at a time, with a cursor for the next. Creates no task. |
| `delete_session` | Deletes one of an agent's sessions, which cannot be undone, and returns the agent, the resolved workspace, the session id and `deleted: true`. Creates no task. |
| `spawn_task` | Dispatches a prompt to a registered agent and returns the task summary plus the task's `notify_path` as soon as the agent process is running. With `keep_idle`, `keep_turns` or `on_agent` it also returns `kept_agent`. |
| `get_task` | Returns a task's current state: status, error, resolution and its outcome (`final_message`, `permissions_refused`, `usage`). |
| `get_events` | Returns one bounded page of a task's events after `after_seq`, with `cursor`, `has_more` and `status`. |
| `wait_tasks` | Waits for any of the given tasks to end and returns the finished ones with `final_message` and `permissions_refused`, and a `reason`. |
| `list_tasks` | Lists this server's tasks, newest first, as summaries; recovers task ids a caller lost. |
| `resolve_task` | Records `accepted`, `rejected`, `needs_followup` or `superseded` for a finished task and returns the task summary plus its resolution note, actor and time. It has no other effect and may be revised. |
| `cancel_task` | Stops a running task's agent process group and returns the task summary. A finished task is unchanged. |
| `forget_task` | Frees a finished task the caller has already resolved, with its event history and completion marker, and returns `{task_id, forgotten: true}`. Creates no task and cannot be undone. |
| `extend_agent` | Renews a kept agent's lease and returns `{handle, expires_at, turns_left}`. Creates no task. |
| `release_agent` | Ends a kept agent and returns `{handle, agent, session_id, released: true}` once its end is known. Creates no task. |

- **Keeping an agent.** `spawn_task` with `keep_idle` or `keep_turns` asks Symm to keep the
  agent process alive under a lease (at most 8 at once) when the turn ends `succeeded` with no
  unkept guarantee, and returns a `kept_agent` object whose `handle` is `agent_` and 12
  hexadecimal digits. Later turns run on it via `spawn_task(on_agent=<handle>)`;
  `extend_agent` renews the lease and `release_agent` ends it.
- **Events and errors.** Tasks record sequenced events (including `task_created`,
  `status_changed`, `session_started`, `agent_message`, `tool_call`, `permission`, `process_exited`,
  `agent_kept`, and `error`). Symm's own tool failures use `<code>: <message>`.

See [docs/reference.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/docs/reference.md) for
[per-tool results and limits](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/docs/reference.md#tool-results-and-limits),
[kept-agent leases](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/docs/reference.md#keeping-an-agent),
[event types and resume details](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/docs/reference.md#events), and
[error codes](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/docs/reference.md#error-codes).

## Scope and Limitations

- **stdio only, process-local task ledger.** Each MCP client launches its own Symm server, and
  each server sees only the tasks it dispatched. `stdio + in-memory = process-local task ledger`.

  ```text
  Agent A
     | stdio
     v
  Symm for A [ledger: task 1]
     | task 1
     v
  Agent B
     | stdio
     v
  Symm for B [ledger: task 2]
     | task 2
     v
  Agent C
  ```

  Agent A sees task 1 but not task 2, which B dispatched through its own server. A shared
  ledger needs an HTTP gateway with a shared store, which is deferred.
- **In memory only, by design.** Task state is lost when the server process exits, and Symm does
  not persist it. The agent keeps its own session; to continue later, even from
  a new client or server process, keep the task's `session_id` and pass it to `spawn_task`.
  `spawn_task` usually returns before an ACP session exists, so read `session_id` with
  `get_task` or from the `session_started` event. Resume with the same agent and workspace. The
  ledger and earlier task's events do not resume with it. If a live task or a kept agent of this
  server already holds that `(agent, session_id)`, `spawn_task` returns `session_in_use:` naming
  that task id or the handle without creating a task. This limit is process-local: another Symm server or the agent's CLI
  can still use the session because the agent owns its session store.
- **No cap on memory, output or retention.** Task records and their event histories live in the
  server's memory until a caller forgets them, with no limit on their number, their size or the
  total output. A keep reservation that does not create a task is dropped with that spawn. A
  kept-agent handle record remains while any retained task names it and is freed after its last
  task is forgotten, provided its lease has ended or its agent was never kept. These records are
  lost when the server exits; stderr lines longer than 1 MiB are split into pieces no larger than
  1 MiB. A server that is never asked to forget grows with every task and kept-agent handle, and
  high-output tasks grow it faster.
  A caller that has read a finished task's result and resolved it can free it with `forget_task`;
  Symm never frees a task on its own, because that would change what `get_task` and `get_events`
  return for old tasks. A forgotten task still costs its id and its place in creation order, so
  that cursors keep working and the id is never reused. Forgetting removes the task's completion
  marker, so forget a task only after anything waiting on its `notify_path` has woken.
- **Tools only.** No MCP resources or subscriptions yet. Wait for completion with `wait_tasks`,
  which returns within 30 seconds, or in the background on the task's completion marker. Read
  progress with `get_events` and its cursor.
- **Bounded process cleanup.** Before reporting completion, Symm tries to end every remaining
  member of the agent's process group, except for an agent the caller asked to keep after a turn
  that succeeded: its group ends with its lease, by the same bounded cleanup. When canceling a running ACP task, it first asks the agent
  to cancel its prompt turn, then uses SIGTERM and, if needed, SIGKILL with bounded waits. If
  Symm cannot confirm the group is empty, the task ends as `failed` and the pool stops
  managing it; a process can remain alive. On client disconnect or handled SIGTERM, SIGINT, or
  SIGHUP, the server applies the same bounded cleanup before it exits, and exits with status 1
  on every one of those paths, including a signal, which would otherwise end the process by that
  signal, if any agent's process group could not be confirmed empty, so a host can tell that
  agents may remain. A shutdown that itself fails after end of input also exits with status 1; one
  that fails during a signal still ends the process by that signal unless a group is unconfirmed.
  When every group is confirmed empty and shutdown itself did not fail, end of input exits 0 and a
  signal ends the process by itself. A task requested
  after shutdown begins fails rather than starting. A server killed with SIGKILL or one that crashes
  cannot run its shutdown handling, so its agents may survive.
- **Your environment, your permissions.** Symm does not install agent software or provide an
  operating-system sandbox for agent actions. Dependencies, secrets, sandboxing, and workspace
  cleanliness are the caller's responsibility. Symm pins adapter-controlled permission settings
  and answers the ACP permission requests an agent sends according to `allow`. It declines
  every elicitation request an agent sends during a turn, and cancels one that arrives outside a
  turn.
- **POSIX only.** Process groups and signals; Windows is not supported.

Rationale:
[PROJECT.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/PROJECT.md) and the decisions under
[intent/](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/tree/main/intent).
Security assumptions and how to report a vulnerability:
[SECURITY.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/SECURITY.md).

## Architecture

```text
MCP client
   | stdio
   v
+------------------------ symm-mcp process -------------------------+
| MCP server (thirteen tools, errors, signals)                      |
|    |                                                              |
|    v                                                              |
| TaskService (orchestration) -> ledger (per-task locks, writes)    |
|    +--> Task store (JSON strings in memory)                       |
|    +--> Agent registry (adapter option allowlists)                |
|    +--> ProcessPool (process groups, argv without a shell)        |
|              |                                                    |
|              +-- launches ACP agents in shared workspace          |
|              +-- keeps agents alive after a turn, under leases    |
|              |     (an idle clock per lease, 8 kept at most)      |
|              +-- serves describe_agent, list_sessions and         |
|              |     delete_session on short-lived probe processes  |
|              |     (no task, not through the ledger)              |
|              +-- reads agent stderr, observes exits               |
|              +-- runs the ACP session client                      |
|                    (sessions, settings, permissions)              |
|                         |                     ^                   |
+-------------------------|---------------------|-------------------+
                          | ACP over stdio      | session updates,
                          v                     | permission requests
                 ACP agent processes (own process groups)
```

Logical state (tasks, events, resolutions) lives in the store and is always serializable.
Runtime state (processes, pipes, process groups) lives only in the process pool. The MCP layer
stays a thin transport. These boundaries are part of the project contract in
[PROJECT.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/PROJECT.md).

## Run Locally

From a checkout:

```bash
uv run symm-mcp
```

The command speaks MCP over stdio, so it is meant to be launched by an MCP client rather than
used interactively.

## Development

This project records its decisions as [plerosis](https://gitlab.com/116lab/coherence/plerosis/plerosis)
intent under `intent/`; read
[AGENTS.md](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/AGENTS.md)
before changing anything. The Definition of Done:

```bash
uv sync
uv run python -m compileall -q src tests
uv run python -m pytest -n auto
uv run ruff check .
uv run ruff format --check .
./scripts/changelog-guard.sh
plerosis check --run
```

## License

Licensed under either of
[Apache-2.0](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/LICENSE-APACHE)
or [MIT](https://gitlab.com/116lab/ensemble/symm/symm-mcp/-/blob/main/LICENSE-MIT), at your option.
