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
访问服务器

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选