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

Metadata

Release files for cdt-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdt-mcp 0.1.0
File Size Uploaded Provenance
cdt_mcp-0.1.0.tar.gz 31.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cdt-mcp 0.1.0
File Interpreter ABI Platform
cdt_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / cdt_mcp-0.1.0.tar.gz

Download URL cdt_mcp-0.1.0.tar.gz
Size 31.9 kB
Tags Source
SHA-256 checksum
How to use checksums
18eb5592197bbde123516ea69ac2e35c52f4500cded769fbd6f3dac006142e2d
BLAKE2b-256 checksum
How to use checksums
1339bdf250b33671904d45a93dd6bf3588f498bfc20a12e08b292292b1f9b511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / cdt_mcp-0.1.0-py3-none-any.whl

Download URL cdt_mcp-0.1.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae97de4ec03efb368250f9e8511fe1b191fd32709170f1cd6c9f93004806ad16
BLAKE2b-256 checksum
How to use checksums
8a47d647a971319a58256f1fc87355d2e4e4798af48f3890c31f4a911a10522d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Security for cdt-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cdt_mcp-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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