Counterfactual Forge
FreeNot checkedEnables AI agents to fork plans into counterfactual worlds, score them with rubrics and simulations, detect contradictions, measure regret, and merge a winner w
About
Enables AI agents to fork plans into counterfactual worlds, score them with rubrics and simulations, detect contradictions, measure regret, and merge a winner with a full audit trail.
README
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 |
|---|---|
@counterfactual-forge/core |
Deterministic domain model + fork/score/compare/merge/export |
@counterfactual-forge/mcp-server |
Stdio MCP tools (cf_*) |
@counterfactual-forge/cli |
cff / counterfactual-forge CLI |
@counterfactual-forge/studio |
Vite studio to inspect world trees & scores |
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.md
Studio UI:
npm run studio
# → http://localhost:5173
MCP (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 |
|---|---|
cf_create_session |
Create session + baseline world from goal + steps |
cf_fork_worlds |
Fork N strategies (aggressive, conservative, parallel, minimal, custom) |
cf_score_world |
Rubric scores + seeded simulation + confidence interval |
cf_compare |
Ranking, regret, contradiction detection |
cf_merge_winner |
Select winner via merge policy |
cf_get_audit_trail |
Append-only audit events |
cf_export_report |
Export json / markdown / mermaid |
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 mermaid
Sessions 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 build
Logging uses stderr only (CFF_LOG_LEVEL=debug|info|warn|error|silent) — safe for MCP stdio.
License
MIT
Installing Counterfactual Forge
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/SanjoyDat1/counterfactual-forgeFAQ
Is Counterfactual Forge MCP free?
Yes, Counterfactual Forge MCP is free — one-click install via Unyly at no cost.
Does Counterfactual Forge need an API key?
No, Counterfactual Forge runs without API keys or environment variables.
Is Counterfactual Forge hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Counterfactual Forge in Claude Desktop, Claude Code or Cursor?
Open Counterfactual Forge on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzMCP-Agent
A simple, composable framework to build agents using Model Context Protocol by [LastMile AI](https://www.lastmileai.dev)
by lastmile-aiSpring AI MCP Client
Provides auto-configuration for MCP client functionality in Spring Boot applications.
mcp.natoma.ai
A Hosted MCP Platform to discover, install, manage and deploy MCP servers by [Natoma Labs](https://www.natoma.ai)
MCPHub
Website to list high quality MCP servers and reviews by real users. Also provide online chatbot for popular LLM models with MCP server support.
MCP Servers Rating and User Reviews
Website to rate MCP servers, write authentic user reviews, and [search engine for agent & mcp](http://www.deepnlp.org/search/agent)
mkinf
An Open Source registry of hosted MCP Servers to accelerate AI agent workflows.
Compare Counterfactual Forge with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
