twining-mcp
v1.7.0
Published
Agent coordination MCP server — shared blackboard, decision tracking, and context assembly
Maintainers
Readme
The Problem
You spend two hours with Claude Code making architectural decisions. You choose PostgreSQL over MongoDB. You settle on JWT for auth. You flag a race condition in the payment module. Then the session ends.
Tomorrow you start a new session. Claude has no idea what happened. The decisions are gone. The warnings are gone. The rationale is gone. You re-explain everything — or worse, Claude silently contradicts yesterday's choices.
This gets worse with multiple agents. Agent A decides on REST. Agent B picks gRPC for the same service. Neither knows the other exists. You find out when the code doesn't compile.
Context windows are ephemeral. Your project's decisions shouldn't be.
How Twining Fixes It
Twining is an MCP server that gives your AI agents persistent project memory. Decisions survive context resets. New sessions start informed. Multi-agent work stays coordinated.
# Install in 10 seconds
claude plugin install twiningRecord a decision with rationale:
> Use twining_decide to record: chose PostgreSQL over MongoDB for ACID complianceTwining captures the decision, rationale, alternatives considered, confidence level, and affected files — as a structured record, not chat history.
Start a new session. Get caught up instantly:
> Use twining_assemble for the database moduleTwining scores every decision, warning, and finding by relevance to your task, then fills a token budget in priority order. You get exactly the context you need — no firehose, no re-explaining.
Ask why things are the way they are:
> Use twining_why src/auth/middleware.tsReturns the full decision chain for any file: what was decided, when, why, what alternatives were rejected, and which commit implemented it.
Why Not Just Use CLAUDE.md?
CLAUDE.md is static. You write it once and update it manually. It doesn't capture decisions as they happen, doesn't track rationale or alternatives, doesn't detect conflicts between agents, and can't selectively assemble context within a token budget.
Twining is dynamic. Every twining_decide call records a structured decision. Every twining_post shares a finding or warning. Every twining_assemble scores relevance and delivers precisely what the current task needs. The .twining/ directory is your project's living institutional memory.
Why Not an Orchestrator?
Orchestrators (like agent swarms and hierarchical coordinators) route work by assigning tasks. Twining coordinates by sharing state. The difference matters:
- Orchestrators hold coordination context in their own context window — a single point of failure that degrades as the window fills
- Twining's blackboard persists coordination state outside any agent's window, surviving context resets without information loss
Agents self-select into work by reading the blackboard. No central bottleneck. No relay that drops context. Every agent sees every other agent's decisions and warnings, directly.
Install
Plugin Install (Recommended)
claude plugin install twiningOne step. Includes the MCP server, skills, hooks, and commands. Skills teach Claude when and how to use Twining — everything works automatically.
Team Auto-Install
Commit this to your repo's .claude/settings.json so every team member gets Twining on clone:
{
"enabledPlugins": {
"twining@daveangulo": true
}
}MCP-Only Install
For non-Claude-Code clients (Cursor, Windsurf, etc.):
claude mcp add twining -- npx -y twining-mcp --project .Or add to .mcp.json:
{
"mcpServers": {
"twining": {
"command": "npx",
"args": ["-y", "twining-mcp", "--project", "."]
}
}
}MCP server instructions are included automatically in the initialize response.
Upgrading from Manual Install
If you previously configured Twining manually, switch to the plugin:
- Remove manual MCP server:
claude mcp remove twining - Install plugin:
claude plugin install twining - Clean up: remove Twining hooks from
.claude/settings.json, remove.claude/agents/twining-aware.mdif present, remove Twining sections fromCLAUDE.md(skills handle this now) - Keep:
.twining/directory (all state preserved) - Verify:
/twining:status
Get the Most Out of It
The plugin handles agent instructions automatically via skills. For the MCP-only install path, add Twining instructions to your project's CLAUDE.md so agents use it automatically — see docs/CLAUDE_TEMPLATE.md for a ready-to-copy template.
Dashboard
A web dashboard starts automatically at http://localhost:24282 — browse decisions, blackboard entries, knowledge graph, and agent state. Configurable via TWINING_DASHBOARD_PORT.
What's Inside
Persistent Decisions
| Tool | What It Does |
|------|-------------|
| twining_decide | Record a decision with rationale, alternatives, confidence, and traceability |
| twining_why | Get the full decision chain for any file or scope |
| twining_trace | Trace a decision's dependency chain upstream and downstream |
| twining_reconsider | Flag a decision for reconsideration with impact analysis |
| twining_override | Override a decision, optionally creating a replacement |
| twining_search_decisions | Search decisions by keyword or semantic similarity |
| twining_link_commit | Link a git commit to a decision |
| twining_commits | Find decisions by git commit |
Shared Blackboard
| Tool | What It Does |
|------|-------------|
| twining_post | Share a finding, warning, need, or question with all agents |
| twining_read | Read entries filtered by type, scope, or agent |
| twining_query | Semantic search across all entries |
| twining_recent | Get the latest entries |
Context Assembly
| Tool | What It Does |
|------|-------------|
| twining_assemble | Build tailored context for a task within a token budget |
| twining_summarize | High-level summary of project state |
| twining_what_changed | What changed since a given point in time |
| twining_status | Health check — entry counts, warnings, agent status |
| twining_archive | Move stale entries to archive |
| twining_export | Export full state as markdown |
Knowledge Graph
| Tool | What It Does |
|------|-------------|
| twining_add_entity | Add or update an entity |
| twining_add_relation | Add a relation between entities |
| twining_neighbors | Traverse from an entity up to depth 3 |
| twining_graph_query | Search by name or property |
Decisions auto-populate the graph: twining_decide creates file and function entities with decided_by relations for every affected file.
Agent Coordination
| Tool | What It Does |
|------|-------------|
| twining_agents | List agents with capabilities and liveness |
| twining_discover | Find agents matching required capabilities |
| twining_delegate | Post a delegation request with capability requirements |
| twining_handoff | Hand off work with results and auto-assembled context |
| twining_acknowledge | Acknowledge receipt of a handoff |
How It Works
All state lives in .twining/ as plain files — JSONL for the blackboard, JSON for decisions, graph, agents, and handoffs. Everything is jq-queryable, grep-able, and git-diffable. No database. No cloud. No accounts.
Architecture layers:
- Storage — File-backed stores with locking for concurrent access
- Engine — Decision tracking, blackboard, graph traversal, context assembly with token budgeting, agent coordination
- Embeddings — Local all-MiniLM-L6-v2 via
@huggingface/transformers, lazy-loaded, with keyword fallback. The server never fails to start because of embedding issues. - Dashboard — Read-only web UI with cytoscape.js graph visualization and vis-timeline
- Tools — MCP tool definitions validated with Zod, mapping 1:1 to the tool surface
See TWINING-DESIGN-SPEC.md for the full specification.
FAQ
Does Twining slow down Claude Code? No. It's a local MCP server — tool calls are local file reads/writes. Semantic search loads lazily on first use.
Can I use it with Cursor, Windsurf, or other MCP clients? Yes. Twining is a standard MCP server. Any MCP host can connect to it.
Where does my data go?
All coordination state is local in .twining/. Tool call metrics are stored locally in .twining/metrics.jsonl (gitignored). Optional anonymous telemetry can be enabled — see Analytics below.
Is Twining an agent orchestrator? No. It's a coordination state layer. It captures what agents decided and why, and makes that knowledge available to future agents. Use it alongside orchestrators, agent teams, or standalone sessions.
Analytics
Twining includes a three-layer analytics system to help you understand the value it provides.
Insights Dashboard Tab
The web dashboard includes an Insights tab showing:
- Value Metrics — Blind decision prevention rate, warning acknowledgment, test coverage via
tested_bygraph relations, commit traceability, decision lifecycle, knowledge graph stats, and agent coordination metrics - Tool Usage — Call counts, error rates, average/P95 latency per tool
- Error Breakdown — Errors grouped by tool and error code
All value metrics are computed from existing .twining/ data — no new data collection needed.
Tool Call Metrics
Every MCP tool call is automatically instrumented with timing and success/error tracking. Metrics are stored locally in .twining/metrics.jsonl (gitignored — operational data, not architectural).
To disable local metrics collection, set in .twining/config.yml:
analytics:
metrics:
enabled: falseOpt-in Telemetry
Anonymous aggregate usage data can optionally be sent to PostHog to help improve Twining. Disabled by default. To enable, add to .twining/config.yml:
analytics:
telemetry:
enabled: trueThat's it — the PostHog project key is built into the source code. If you run your own PostHog instance, you can override with posthog_api_key and posthog_host.
What is sent: tool names, call durations, success/failure booleans, server version, OS, architecture.
What is never sent: file paths, decision content, agent names, error messages, tool arguments, environment variables.
Privacy safeguards:
DO_NOT_TRACK=1environment variable always overrides configCI=trueauto-disables telemetry- Identity is a SHA-256 hash of hostname + project root (never raw paths)
- Network failures are silent — no retries
posthog-nodeis an optional dependency — graceful no-op if not installed
Development
npm install # Install dependencies
npm run build # Build
npm test # Run tests (570+ tests)
npm run test:watchRequires Node.js >= 18.
CI/CD
Two GitHub Actions workflows automate build verification and publishing:
CI (.github/workflows/ci.yml) — runs on every PR and push to main:
- Builds and tests across Node 18, 20, and 22
- Cancels in-progress runs when a new push arrives on the same branch
Publish (.github/workflows/publish.yml) — runs on v* tag push:
- Builds with
POSTHOG_API_KEYbaked in for published packages - Runs the full test suite as defense-in-depth
- Publishes to npm with
--provenancefor supply chain attestation - Creates a GitHub Release with auto-generated release notes
- Supports manual trigger via
workflow_dispatchwith a dry-run option
To publish a new version:
npm version patch # or minor, major
git push && git push --tagsRequired secrets (configured in GitHub repo Settings > Secrets):
| Secret | Purpose |
|--------|---------|
| NPM_TOKEN | npm access token (granular, scoped to twining-mcp) |
| POSTHOG_API_KEY | PostHog ingest key for published packages |
