Skip to main content
Glama
README.md
# dify-canvas-mcp

**MCP server for Dify workflow canvases.** Read, patch, publish and test drafts through the user's signed-in Chrome — in any MCP client (Qoder, DSH, Claude Desktop, …).

## Tools

| Tool | What it does |
| --- | --- |
| `dify_instances` | List configured instances |
| `dify_setup` | Add/update an instance (alias + site URL only) |
| `dify_browser_status` | Show which browser channel is available |
| `dify_browser_launch` | Start a dedicated Chrome with a debugging port |
| `dify_apps` | List apps (an app can be referenced by name later) |
| `dify_canvas_get` | Draft node index (+ hash), or one node in full |
| `dify_canvas_patch` | Patch nodes; dry-run by default, `apply:true` writes with backup + self-check + reload verification |
| `dify_canvas_publish` | Publish and verify the published hash |
| `dify_run` | Run the draft once and return the executed node path |

## Install

```sh
npm i -g dify-canvas-mcp
# or run without installing:
npx -y dify-canvas-mcp
```

MCP client config (stdio):

```json
{
  "mcpServers": {
    "dify-canvas": {
      "command": "npx",
      "args": ["-y", "dify-canvas-mcp"]
    }
  }
}
```

## First use

1. Make sure Chrome is signed in to your Dify site. Preferred: the chrome-pool multiplexer on `127.0.0.1:3333` (one authorization, reused) — or your daily Chrome started with `--remote-debugging-port=9222`.
2. Ask the agent to call `dify_browser_status`; if nothing is available, call `dify_browser_launch` to open a dedicated Chrome window and sign in there once.
3. `dify_setup { alias: "prod", baseUrl: "https://dify.example.com" }`.
4. From then on, say the app's **name** — no UUID needed.

## Credentials

The credential is the browser session. No cookie or token is stored on disk. Config lives in `~/.dify-canvas/config.json`; backups of every written draft go to `~/.dify-canvas/backups/`.

## Write safety

- `dify_canvas_patch` is dry-run unless `apply:true`.
- Pre-write: on-disk backup + self-check (dangling edges, self loops, `default_value` types, code-node parameter mismatch).
- Post-write: page reload, rendered-node count, crash banners.
- `dify_canvas_publish` verifies the published hash against the draft hash.

MIT.