{
  "markdown": "# dag-studio-mcp\n\n[![CI](https://github.com/Black-Swan-Causal-Labs/dagstudio-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Black-Swan-Causal-Labs/dagstudio-mcp/actions/workflows/ci.yml)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n\nModel Context Protocol (MCP) server for the DAG Studio causal-inference engine. It lets AI agents construct, analyze, and validate causal directed acyclic graphs (DAGs) using the same engine that powers the [DAG Studio canvas](https://dagstudio.blackswancausallabs.com/).\n\nBuilt and maintained by [Black Swan Causal Labs](https://blackswancausallabs.com). Listed in the [RWE MCP Registry](https://black-swan-causal-labs.github.io/RWE-MCP-Registry/).\n\n## Tools\n\n| Tool | What it does |\n|---|---|\n| `analyze_dag` | Backdoor paths, minimal sufficient adjustment sets, identifiability |\n| `parse_dagitty` | Parse dagitty DSL (raw or R-wrapped) into the structured DAG model |\n| `generate_code` | R / Python analysis code for a DAG, plus a one-click DAG Studio URL |\n| `check_overadjustment` | Detect adjustment for mediators, colliders, and descendants of exposure |\n| `simulate_data` | Simulate data from a DAG under user-specified structural coefficients |\n| `compute_bias` | Empirical bias of an adjustment strategy against the simulated truth |\n| `classify_effect_modification` | Classify effect-modifier structure (direct, indirect, proxy, common-cause, pure interaction) |\n| `get_canonical_example` | Canonical teaching DAGs (confounding, M-bias, frontdoor, and others) |\n| `validate_engine` | Run the full canonical validation suite and report engine version |\n\nEvery analytical response carries an `engine_version` stamp, a `concordance` attestation, a `diagnostics` block with severity-coded flags, and citations to the underlying methods literature.\n\n## Validation\n\nThe engine is validated four ways for coherence: against Pearl (2009) theory, against the reference implementation dagitty (Textor et al. 2016), against DAG Studio's own analytical results, and empirically via `compute_bias` on simulated data.\n\n- 35 canonical cases: T01 to T15 (structural identification) and EM01 to EM20 (effect modification), runnable live via `validate_engine`.\n- A release-gate concordance check runs the engine head-to-head against dagitty (vendored at upstream commit `7a65777`) and stamps the attestation surfaced in tool responses.\n- 93 unit and integration tests across the engine bindings, the tool layer, and the auth gate.\n\n## Hosted endpoint\n\nThe server runs as a Cloudflare Worker (Streamable HTTP):\n\n```\nhttps://dagstudio-mcp.blackswancausallabs.com/mcp\n```\n\nAccess is token-gated during the trial period. Request a token at jdiazdecaro@blackswancausallabs.com. Tokens are accepted either as a bearer header or as a `?token=` query parameter (the query form exists for clients whose connector UI cannot set custom headers, such as the Claude.ai web connector).\n\nClaude Code:\n\n```sh\nclaude mcp add --transport http dag-studio \\\n  https://dagstudio-mcp.blackswancausallabs.com/mcp \\\n  --header \"Authorization: Bearer <your token>\"\n```\n\nClaude.ai web: add a custom connector pointed at `https://dagstudio-mcp.blackswancausallabs.com/mcp?token=<your token>`.\n\n## Repository layout\n\n- `dag-engine.js` / `dag-engine.d.ts`: the analytical engine, a pure ESM module with no runtime dependencies\n- `src/tools/`: one file per tool, each exporting `{ InputSchema, OutputSchema, descriptor, handler }`\n- `src/worker/`: Cloudflare Worker transport and the token gate (`auth.ts`)\n- `src/index.ts`: stdio entry point for local use\n- `ci/`: release-gate concordance harness against vendored dagitty\n- `tests/`: unit and integration tests (`npm test`)\n- `MCP_REQUIREMENTS.md`: the v1 specification\n- `FDA_GUIDANCE_ALIGNMENT.md`: mapping of DAG Studio capabilities onto FDA draft RWE guidance protocol elements\n\nThe engine is developed alongside the DAG Studio canvas app and the vendored copy here is synced at release time. This repository is self-contained: clone it, `npm install`, and everything builds and tests without further setup.\n\n## Development\n\n```sh\nnpm install\nnpm test                  # full suite\nnpm run dev               # stdio server via tsx\nnpm run worker:typecheck  # worker bundle typecheck\nnpm run worker:deploy     # deploy (stamps engine_version from git HEAD first)\n```\n\nFor interactive inspection: `npx @modelcontextprotocol/inspector`.\n\n## Protocol status\n\nBuilt on `@modelcontextprotocol/sdk` (TypeScript). Current against the finalized MCP specification revision 2025-11-25. Migration to the 2026-07-28 revision is planned once stable SDK support ships.\n\n## License\n\nApache License 2.0 (see `LICENSE`).\n\nException: `ci/dagitty-src/` contains the dagitty reference engine (GPL-2.0, Textor et al.), vendored at upstream commit `7a65777` solely as a release-time CI fixture for the concordance check. It retains its own license, is excluded from the published npm package, and is not part of the deployed worker bundle.\n",
  "bytes": 5030,
  "sha": "08e6df210e0605b1abc5fc8fe201f807f633747ce5bd9dcaa5ba927a9ecc04ea",
  "repo_slug": "black-swan-causal-labs/dagstudio-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_com_blackswancausallabs_dagstudio_mcp_176f3c71/readme"
}