causal-dag-explorer-mcp

causal-dag-explorer-mcp

A local-first MCP server for manually building, inspecting, and saving directed acyclic graphs (DAGs) for custom days, with optional evidence summaries from Home Assistant.

Category
Visit Server

README

Causal DAG Explorer MCP

CI

A local-first MCP server and React website for manually building, inspecting, and saving directed acyclic graphs (DAGs) for custom days. It combines Lucidchart-like box editing with optional, explicitly supplied evidence summaries. It does not perform causal inference or invent missing observations.

Causal DAG Explorer UI

What it does

  • Creates, renames, switches, and deletes multiple saved days.
  • Adds rounded rectangular boxes with four visible connection handles.
  • Renames boxes by double-clicking or using the edit control.
  • Drags boxes and automatically preserves their coordinates.
  • Draws arrowed directed edges from any box handle to another.
  • Supports branching and merging: many outgoing edges and many incoming edges.
  • Rejects self-edges, duplicate source-target pairs, missing endpoints, and directed cycles.
  • Selects boxes or edges and deletes them with Delete or Backspace.
  • Shows a relationship inspector with an editable rationale and supplied evidence metadata.
  • Shows aligned timelines, a day-pattern strip, hourly drill-down, descriptive summaries, and provenance notes when those bounded values were explicitly supplied.
  • Saves to one local JSON file using atomic replacement and restores the exact graph after restart.
  • Supports Save, Ctrl+S, or Command+S and shows an unsaved-changes indicator.
  • Exports the current day as JSON.

The repository includes a fully synthetic five-node example. It contains no personal Home Assistant data.

Architecture

Causal DAG Explorer MCP architecture

The MCP host is the orchestrator. If Home Assistant evidence is requested, the host reads it through HA Unofficial AI and then passes bounded summaries to this local MCP. The Day DAG MCP never connects to Home Assistant or another MCP directly.

The editable architecture source is docs/architecture.svg.

Requirements

  • Node.js 20 or newer
  • pnpm 10 or newer
  • A desktop browser

Install and run

git clone https://github.com/resace3/causal-dag-explorer-mcp.git
cd causal-dag-explorer-mcp
corepack enable
pnpm install --frozen-lockfile
pnpm build
pnpm start

Open http://127.0.0.1:3000.

The first launch starts with an empty local store. To copy the public synthetic example into the runtime store:

pnpm seed:example
pnpm start

seed:example refuses to overwrite an existing data/days.json. Use pnpm seed:example -- --force only when you intentionally want to replace that local file.

For development:

pnpm dev

Vite serves the UI at http://127.0.0.1:5173 and proxies API calls to the Express server on port 3000.

MCP configuration

Build once, then register the stdio server in your MCP client. Replace the placeholder with the absolute path to your clone.

{
  "mcpServers": {
    "causal-dag-explorer": {
      "command": "node",
      "args": [
        "/absolute/path/to/causal-dag-explorer-mcp/dist/node/mcp/index.js"
      ],
      "cwd": "/absolute/path/to/causal-dag-explorer-mcp"
    }
  }
}

MCP tools

Tool Purpose
launch_day_diagram_app Starts and health-checks the localhost website.
create_day Creates an empty saved day.
list_days Lists saved day metadata.
get_day Reads boxes, edges, and compact evidence for one day.
save_day Validates and saves a complete day.
update_day_diagram Replaces only the boxes and edges of a day.
create_dag_from_ha_evidence Saves a DAG from compact HA evidence already collected by the MCP host.
delete_day Deletes one saved day.

Each tool has a strict JSON schema. Invalid labels, handles, endpoints, duplicate relationships, and cycles return structured errors.

Website controls

  • Use New Day to create a separate diagram.
  • Click Add Box or double-click blank canvas space to add a box.
  • Double-click a box to rename it.
  • Drag a box to move it.
  • Drag from any handle to a handle on another box to create a directed edge.
  • Click a box or arrow and press Delete or Backspace to remove it.
  • Select an arrow to edit its rationale and inspect any supplied evidence.
  • Use Clear Canvas; the app asks for confirmation before clearing.
  • Use Save, Ctrl+S, or Command+S to persist labels, edges, rationales, and coordinates.
  • Use the left navigation to open DAG, timeline, evidence, data, and settings views.

Home Assistant evidence boundary

create_dag_from_ha_evidence is intentionally an import tool:

  1. An MCP host searches and reads relevant entities through HA Unofficial AI.
  2. The host compacts the observations into labels, summaries, optional aligned day/hour values, and limitations.
  3. The host calls this MCP with that bounded payload.
  4. This server validates the DAG and saves it locally.
  5. The user inspects and edits the result manually.

Only supplied summaries are displayed. The app does not:

  • query Home Assistant itself;
  • store Home Assistant credentials;
  • copy raw API payloads;
  • infer causal effects;
  • calculate p-values or model fit;
  • fill missing series with generated values.

Arrows are editable hypotheses for exploration, not proof of causation.

Local data

Runtime data is stored in data/days.json, which is intentionally ignored by Git. The tracked data/example-days.json is synthetic.

Set these optional environment variables:

Variable Default Purpose
DAY_DIAGRAM_PORT 3000 Local web-server port.
DAY_DIAGRAM_DATA_FILE data/days.json Alternate local JSON store.
DAY_DIAGRAM_WEB_ORIGIN disabled Optional CORS origin for Vite development.

Writes use a temporary file followed by an atomic rename.

Validation and tests

pnpm typecheck
pnpm test:unit
pnpm build
pnpm test:mcp
pnpm test:release
pnpm exec playwright install chromium
pnpm test:e2e

The automated coverage includes:

  • JSON store create/list/get/save/rename/delete and restart restoration;
  • exact label, position, connection-handle, rationale, and evidence persistence;
  • five-node branching and merging DAGs;
  • rejection of self, duplicate, cyclic, malformed, and missing-endpoint edges;
  • REST API persistence;
  • MCP tool names and JSON schemas;
  • a real stdio MCP client calling app launch and every data tool;
  • public example validation and privacy checks;
  • real browser creation and rename of five boxes;
  • real pointer dragging and handle-to-handle edge drawing;
  • edge selection/deletion, invalid-edge UI messages, save, hard reload, day switching, clear confirmation, and deletion;
  • evidence inspector, timeline, day-pattern, descriptive-summary, data, and settings views.

GitHub Actions runs type checking, unit tests, a production build, release/privacy checks, and the Chromium browser suite on every push and pull request.

Project structure

src/
  mcp/       MCP tool contracts, dispatcher, and launcher
  server/    Express API and static website
  storage/   Atomic local JSON persistence
  web/       React and React Flow explorer
  shared/    Types, validation, graph rules, evidence import
tests/       Unit and API tests
e2e/         Playwright browser tests
docs/        Public-safe UI and architecture images
data/        Synthetic example; runtime file is ignored

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured