counterfactual-forge
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Counterfactual Forge
What-if branching for AI agents. Fork a plan into counterfactual worlds, score them with rubrics + simulated outcomes (confidence intervals), detect contradictions, measure regret, and merge a winner — with a full audit trail.
Expose the whole loop as an MCP server so Cursor / Claude / any MCP client can fork → score → merge from tools.
Packages
Package | Role |
| Deterministic domain model + fork/score/compare/merge/export |
| Stdio MCP tools ( |
|
|
| Vite studio to inspect world trees & scores |
Related MCP server: pvc-mcp-server
Quick start
git clone https://github.com/SanjoyDat1/counterfactual-forge.git
cd counterfactual-forge
npm install
npm run build
npm test
npm run cff -- demo --out /tmp/cff-report.mdStudio UI:
npm run studio
# → http://localhost:5173MCP (Cursor)
Add to your MCP config (e.g. Cursor mcp.json):
{
"mcpServers": {
"counterfactual-forge": {
"command": "node",
"args": [
"/ABSOLUTE/PATH/TO/counterfactual-forge/packages/mcp-server/dist/index.js"
]
}
}
}Or after publishing / linking:
{
"mcpServers": {
"counterfactual-forge": {
"command": "npx",
"args": ["-y", "counterfactual-forge-mcp"]
}
}
}Tools
Tool | Description |
| Create session + baseline world from goal + steps |
| Fork N strategies ( |
| Rubric scores + seeded simulation + confidence interval |
| Ranking, regret, contradiction detection |
| Select winner via merge policy |
| Append-only audit events |
| Export |
Example agent flow
cf_create_sessionwith goal + plan stepscf_fork_worldswithaggressive+conservative(+ optional others)cf_score_worldfor each forked worldcf_compare→ inspect regret & contradictionscf_merge_winnercf_export_report(markdown) for the decision record
CLI
npx cff demo
npx cff create --goal "Ship X" --steps examples/fixtures/auth-redesign-steps.json
npx cff fork --session <id> --strategies aggressive,conservative,minimal
npx cff score --session <id> --world <id>
npx cff compare --session <id>
npx cff merge --session <id> --mode min_regret
npx cff export --session <id> --format mermaidSessions are in-memory per process — export / import to persist.
Creative metrics
Confidence intervals on overall scores (from outcome simulation percentiles)
Regret — how many points worse than the best alternative
Contradiction detection across assumptions / risks / strategy tags
Mermaid world-tree export embedded in Markdown reports
Architecture
See docs/ARCHITECTURE.md and docs/PLAN.md.
Development
npm run typecheck
npm run test:coverage # core ≥80%
npm run buildLogging uses stderr only (CFF_LOG_LEVEL=debug|info|warn|error|silent) — safe for MCP stdio.
License
MIT
Related MCP Connectors
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
A home for your agents: an owned book of record any AI agent can write to, with provenance and undo.
Turn grounded AI answers into trusted comparisons, plans, timelines, and decision views.
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI agents to branch, score, prune, and merge conversation strands with provenance and timeline export. Provides MCP tools and resources for managing parallel exploratory strands.-
- AlicenseNot gradedqualityDmaintenanceA Git-like version control system for AI agent decision tracking, enabling plan commits, diffs, branches, and history.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to be governed by formal Gentzen sequent calculus proof trees, with human-in-the-loop approval gates and cryptographic audit trails for consequential actions.MIT
- AlicenseNot gradedqualityCmaintenanceEnables autonomous agents to snapshot execution-tree and context states, evaluate branch viability, and roll back to previous checkpoints when an exploration path fails without restarting from scratch.MIT