Skip to main content

cdt-mcp

Coherence Data Types (CDTs) as a Model Context Protocol server. Multi-agent state synchronization by wave superposition instead of conflict resolution.

CI PyPI License: MIT

When several Claude Code, Gemini / Antigravity, or other MCP clients work on the same problem, they need a place to reconcile diverging state. CRDTs do this by detecting conflicts and imposing an order. A CDT does something different: every proposal is a coherence impulse added to a shared complex field,

Ψ_state = Σ_i  w_i · ψ_i        with   ψ_i = coherence_i · value_i · e^{i·phase_i}

and the "truth" is simply the region of highest spectral density. Nothing is overwritten, disagreement is real (negative impulses interfere destructively), stale proposals fade by decay, and merging replicas is a commutative, associative, idempotent union.

Install

pip install cdt-mcp            # or: uv tool install cdt-mcp
cdt-mcp --version

Requires Python 3.10+ and mcp>=2.

Use with Claude Code

claude mcp add cdt -- cdt-mcp --state-dir ~/.cdt-mcp

Or add it to .mcp.json in a project so every collaborator's Claude Code shares the config:

{
  "mcpServers": {
    "cdt": {
      "command": "cdt-mcp",
      "args": ["--state-dir", ".cdt-state"]
    }
  }
}

Use with Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "cdt": {
      "command": "cdt-mcp",
      "args": ["--state-dir", "/Users/you/.cdt-mcp"]
    }
  }
}

Use with Gemini / Antigravity

In Gemini CLI or Google Antigravity, add CDT to your project's .mcp.json or Antigravity configuration:

{
  "mcpServers": {
    "cdt": {
      "command": "cdt-mcp",
      "args": ["--state-dir", ".cdt-state"]
    }
  }
}

Or via Gemini CLI:

gemini mcp add cdt -- cdt-mcp --state-dir ~/.cdt-mcp

Shared server for a swarm

Run one HTTP instance and point every agent at it. All clients then superpose into the same fields without exchanging snapshots.

cdt-mcp --transport streamable-http --host 0.0.0.0 --port 8000 --state-dir /var/lib/cdt
# clients connect to http://host:8000/mcp
claude mcp add --transport http cdt http://localhost:8000/mcp

A Dockerfile is included:

docker build -t cdt-mcp .
docker run -p 8000:8000 -v cdt-state:/state cdt-mcp

Tools

Tool Purpose
cdt_create Create a field (idempotent). Choose bins, decay_rate, kernel_width.
cdt_write Emit an impulse: key or phase, coherence (confidence), payload (the proposal), agent_id. Negative value = disagreement. Auto-creates the field.
cdt_read Amplitude at a key/phase plus the payloads that landed there.
cdt_consensus The highest-density bin: top_payload, share (0-1), confidence, and the strongest alternatives.
cdt_snapshot Export a field as JSON for another replica.
cdt_sync Absorb a remote snapshot. Idempotent union of write events.
cdt_merge Superpose several local fields into one.
cdt_decay Record a decay event on all writes so far, then prune negligible impulses.
cdt_list, cdt_delete, cdt_phase_of Housekeeping and the key-to-phase hash.

Resources: cdt://fields, cdt://field/{name}, cdt://field/{name}/consensus. Prompt: cdt_reconcile(field, topic) walks an agent through propose / sync / read-consensus.

Every tool declares MCP annotations (readOnlyHint, destructiveHint, idempotentHint) so hosts can auto-approve the safe ones.

Example: three agents reconcile a merge strategy

agent-1  cdt_write field=merge key=rebase       coherence=0.9 payload="Rebase onto main"
agent-2  cdt_write field=merge key=merge-commit coherence=0.7 payload="Merge commit"
agent-3  cdt_write field=merge key=rebase       coherence=0.4 payload="Rebase onto main" value=-1
anyone   cdt_consensus field=merge
{
  "top_payload": "Merge commit",
  "share": 0.583,
  "confidence": 37.3,
  "alternatives": [
    {"payloads": [{"payload": "Merge commit", "weight": 0.7, "agents": ["agent-2"]}]},
    {"payloads": [{"payload": "Rebase onto main", "weight": 0.5, "agents": ["agent-1", "agent-3"]}]}
  ]
}

Agent 3's objection (weight −0.4) interfered destructively with agent 1's proposal (0.9 → 0.5), so "Merge commit" carries the field. Nothing was deleted: cdt_read key=rebase still shows both contributors.

Library use

The core has no MCP dependency:

from cdt_mcp import CoherenceField

a = CoherenceField("replica-a", bins=64, decay_rate=1 / 3600)  # fades over hours
a.write(1.0, key="hypothesis:H1", coherence=0.8, payload="H1", agent_id="alice")

b = CoherenceField("replica-b", bins=64)
b.write(1.0, key="hypothesis:H2", coherence=0.6, payload="H2", agent_id="bob")

a.merge_from(b)  # union of write events; idempotent
print(a.consensus().top_payload)  # "H1"
snapshot = a.to_dict()  # JSON-safe

See examples/multi_agent_merge.py for a runnable end-to-end client script and docs/THEORY.md for the model and its guarantees.

Semantics and guarantees

  • Writes superpose. write never replaces; the field is Σ over all retained impulses.
  • Sync is a set union of events (writes and explicit decays) keyed by UUID. It is idempotent, commutative and associative, so replicas converge regardless of delivery order or duplication. The only exceptions are pruning operations: the max_records cap and prune_below drop the weakest impulses, which can make replicas diverge. Size fields accordingly (default 10,000 events).
  • Decay is continuous and clock-based. An impulse's weight at time t is coherence · value · exp(-decay_rate · (t - t_write)). cdt_decay records an extra decay event that multiplies every write made before it; it syncs like a write, so replicas that decayed at different moments still agree.
  • Disagreement is visible. Opposing proposals cancel in the coherent field, so cdt_consensus also returns contest_ratio and the most contested bins (Σ|w| − |Σ w·e^{iφ}| per bin) with the payloads and agents on each side.
  • Keys hash to phases via SHA-256, so the same key lands in the same bin on every replica. With 64 bins, distinct keys collide with probability ~1/64 per pair; raise bins if you use many keys in one field, or use explicit phase values.
  • Persistence is JSON, one file per field, written atomically. No pickle.
  • tau_k is carried as metadata and density-weighted on merge; it is not associative.

Configuration

Flag Env Default
--transport stdio|streamable-http CDT_MCP_TRANSPORT stdio
--host / --port CDT_MCP_HOST / CDT_MCP_PORT 127.0.0.1 / 8000
--state-dir DIR CDT_MCP_STATE_DIR in-memory only
--log-level CDT_MCP_LOG_LEVEL INFO

Development

git clone https://github.com/dirrrtyjesus/cdt-mcp && cd cdt-mcp
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check . && mypy src

Provenance

CDTs originate in the Fractal Harmonic Processing paradigm and its Ublox / PTO prototypes, where game world state was stored as a coherence field rather than a database row. This package composes with that primitive, makes synchronization idempotent, and exposes it over MCP.

Contributors

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdt_mcp-0.1.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdt_mcp-0.1.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file cdt_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: cdt_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdt_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18eb5592197bbde123516ea69ac2e35c52f4500cded769fbd6f3dac006142e2d
MD5 e500be8444a807c863cd4ee7f4a00fe5
BLAKE2b-256 1339bdf250b33671904d45a93dd6bf3588f498bfc20a12e08b292292b1f9b511

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdt_mcp-0.1.0.tar.gz:

Publisher: ci.yml on dirrrtyjesus/cdt-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdt_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cdt_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdt_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae97de4ec03efb368250f9e8511fe1b191fd32709170f1cd6c9f93004806ad16
MD5 b95cbe4a23a28a714db4ceea83edaced
BLAKE2b-256 8a47d647a971319a58256f1fc87355d2e4e4798af48f3890c31f4a911a10522d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdt_mcp-0.1.0-py3-none-any.whl:

Publisher: ci.yml on dirrrtyjesus/cdt-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page