@dineug/erd-editor-mcp 0.2.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,34 +1,47 @@
1
1
  # @dineug/erd-editor-mcp
2
2
 
3
- > An MCP server that lets a coding agent edit [erd-editor](https://github.com/dineug/erd-editor)
3
+ > An MCP server that lets a coding agent edit [ERD Editor](https://github.com/dineug/erd-editor)
4
4
  > diagrams, live in VS Code, Obsidian or a JetBrains IDE, or straight on disk
5
5
 
6
- Claude Code, Codex and any other client of the [Model Context Protocol](https://modelcontextprotocol.io)
7
- get one tool per editing operation on an `.erd.json` document: add a table, rename a column,
8
- relate two tables, import a DDL dump, read the schema back as SQL. When the document is open in
9
- the [ERD Editor VS Code extension](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode),
10
- the [ERD Editor Obsidian plugin](https://community.obsidian.md/plugins/erd-editor) or the
11
- [ERD Editor plugin](https://plugins.jetbrains.com/plugin/23594-erd-editor) for IntelliJ-based IDEs,
12
- the agent joins the editor as a collaborator: every call shows up on the canvas as it happens, with
13
- the agent's focus on the cell it is editing. With no editor around, the same tools edit the file
14
- itself.
6
+ Ask Claude Code, Codex or any [Model Context Protocol](https://modelcontextprotocol.io) client to
7
+ change your schema, and watch the change land on the canvas.
15
8
 
16
9
  ![coding agents](https://github.com/dineug/erd-editor/blob/main/img/coding-agents.webp?raw=true)
17
10
 
18
- The package is one self-contained file with no runtime dependencies. It needs Node.js 22.12 or
19
- later.
11
+ - **One tool per edit** — add a table, rename a column, relate two tables, import a DDL dump, read
12
+ the schema back as SQL
13
+ - **Live in your editor** — when
14
+ [VS Code](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode),
15
+ [Obsidian](https://community.obsidian.md/plugins/erd-editor) or a
16
+ [JetBrains IDE](https://plugins.jetbrains.com/plugin/23594-erd-editor) holds the diagram, the
17
+ agent joins as one more collaborator, and its undo reverts only its own edits
18
+ - **Headless on disk** — with no editor around, the same tools edit the file itself
19
+ - **Large schemas** — paged, searchable reads, and DDL of just the tables the agent needs
20
+ - **Self-contained** — one file with no runtime dependencies
20
21
 
21
22
  ## Install
22
23
 
24
+ The server needs Node.js 22.12 or later; `npx` downloads it the first time the agent starts it.
25
+ Keep ERD Editor and the server up to date together: when one speaks an older hub protocol than the
26
+ other, the server refuses to connect and says which one to update.
27
+
23
28
  ### Claude Code
24
29
 
30
+ Run in your project folder:
31
+
25
32
  ```sh
26
33
  claude mcp add --transport stdio erd-editor -- npx -y @dineug/erd-editor-mcp
27
34
  ```
28
35
 
29
36
  ### Codex
30
37
 
31
- Add to `~/.codex/config.toml`, or to `.codex/config.toml` in a trusted project:
38
+ Run once; the Codex CLI, app and IDE extension share the setting:
39
+
40
+ ```sh
41
+ codex mcp add erd-editor -- npx -y @dineug/erd-editor-mcp
42
+ ```
43
+
44
+ Or add it to `~/.codex/config.toml`, or to `.codex/config.toml` in a trusted project:
32
45
 
33
46
  ```toml
34
47
  [mcp_servers.erd-editor]
@@ -38,115 +51,99 @@ args = ["-y", "@dineug/erd-editor-mcp"]
38
51
 
39
52
  ### Any other MCP client
40
53
 
41
- Run `npx -y @dineug/erd-editor-mcp` as a stdio server. It resolves relative document paths
42
- against its working directory, so start it in your project.
43
-
44
- On Windows it refuses a document name with a colon, such as `orders:v2.erd`, a device name such
45
- as `NUL.erd` or `CON.erd`, or a name ending in a dot or a space, and leaves such files out when it
46
- lists documents from disk: Windows would store another file than the one named. Use `-` in place
47
- of `:`.
54
+ Run `npx -y @dineug/erd-editor-mcp` as a stdio server, started in your project folder: it resolves
55
+ relative document paths against its working directory.
48
56
 
49
57
  ## Live and headless
50
58
 
51
- For every edit the server looks for an editor that holds the document, a VS Code window with the
52
- ERD Editor extension, an Obsidian vault window with the ERD Editor plugin or an IntelliJ-based IDE
53
- with the ERD Editor plugin, which keeps one lock for all its open projects, through the lock files
54
- each keeps in `~/.erd-editor/ide/`:
59
+ For each call, the server looks in `~/.erd-editor/ide/` for an editor that holds the document: one
60
+ that has it open, or whose workspace, vault or project contains it.
55
61
 
56
62
  | What it finds | What an edit does |
57
63
  | --- | --- |
58
- | A window whose workspace or vault contains the document, an IDE with a project that contains it, or an editor that has it open | **Live.** Opens the document in the ERD editor if needed, joins the editing session and applies the change there. Edits appear at once. VS Code keeps them unsaved until the agent calls `erd_save` (or you save); Obsidian saves them about two seconds later and a JetBrains IDE a fraction of a second after editing stops, as each saves your own edits, and `erd_save` writes them at once. The agent's `erd_undo` reverts only its own edits. |
59
- | No editor | **Headless.** Loads the file, applies the change and replaces the file atomically. `erd_save` has nothing to do. A read-only file, such as a Perforce or TFVC file not checked out, is refused with `readonly` until you make it writable. On Windows, a file with permissions of its own, unlike its folder's, is written in place so that it keeps them, and a file another program holds open is tried again for up to two seconds. |
60
- | An editor with its hub off | **Refused.** Reads still work, from disk. Writing the file under an open editor would be overwritten by its next save, so the server does not. |
61
- | On Windows, an editor that holds the document under another path to the same file: the agent named it through a network share or a mapped drive of this computer, such as `\\localhost\C$\…`, and the editor opened it by its drive path, or the other way round | **Refused**, reads included; the result names the path the editor holds the document by, to call again with. |
62
- | An editor Windows keeps the agent out of: one started as administrator while the agent was not, or any editor when the agent runs in a sandbox | **Refused**, reads included, with a result that says why. Run the editor and the agent with the same rights, for example by starting the editor again without administrator rights. With Windows 11's Administrator protection on, an editor started as administrator runs as a separate account whose lock files the agent never sees, so the edit goes headless under that editor: start it without administrator rights there. |
63
-
64
- In VS Code the live hub runs in trusted workspaces and is on by default. Turn it off with the
65
- setting `dineug.erd-editor.agentHub.enabled`; the window then still guards its documents from
66
- headless writes. The extension activates in workspaces that contain `.erd`, `.erd.json`, `.vuerd`
67
- or `.vuerd.json` files.
68
-
69
- In Obsidian the live hub runs in every vault window while the ERD Editor plugin is enabled, and is
70
- on by default. Turn it off with the plugin's coding-agent setting; the vault window then still
71
- guards its files from headless writes.
72
-
73
- In a JetBrains IDE the live hub runs while the ERD Editor plugin is enabled, one for the whole IDE
74
- and every project open in it, and is on by default. Turn it off with Coding agents under
75
- Settings | Tools | ERD Editor; the IDE then still guards the files of its projects from headless
76
- writes. Trust is per project: an agent reads the ERD files of a project the IDE does not trust but
77
- cannot change them. On Windows it listens on a named pipe, as the VS Code and Obsidian hubs do.
78
-
79
- The server never falls back to the file on its own while an editor holds a document: if the
80
- connection drops it reconnects, and only when that editor has exited, or has closed the document
81
- and stopped serving it, as Obsidian does when the plugin is disabled and a JetBrains IDE does when
82
- a project closes or the plugin is disabled, does it edit the file and say so in the result.
64
+ | An editor that holds the document | **Live.** The change shows on the canvas at once. VS Code keeps it unsaved until you, Auto Save or `erd_save` save it; Obsidian and JetBrains IDEs save it as they save your own edits. |
65
+ | No editor | **Headless.** The change is written to the file. |
66
+ | An editor with its connection off, or an untrusted workspace or project | **Refused**, since the editor's next save would overwrite the change. Reads still come from disk. |
67
+ | An editor on another hub protocol | **Refused**, naming the side to update. |
68
+
69
+ The connection is on by default in each editor:
70
+
71
+ - **VS Code** — a hub per window, in trusted workspaces, off with `dineug.erd-editor.agentHub.enabled`.
72
+ The extension starts once the folder holds an `.erd.json` file or you open a diagram.
73
+ - **Obsidian** — a hub per vault window, off with **Settings → ERD Editor → Coding agents**.
74
+ - **JetBrains IDEs** — one hub for every open project, off with
75
+ **Settings | Tools | ERD Editor → Coding agents**.
76
+
77
+ Obsidian from Flathub and a JetBrains IDE installed as a Flatpak run no hub, so there the agent
78
+ edits the file on disk even while the diagram is open. Close it first in a JetBrains IDE, which
79
+ does not reload it and would overwrite the agent's change with your next edit; in Obsidian, an edit
80
+ you have not saved yet gives way to the agent's.
81
+
82
+ Windows paths, Flatpak sandboxes, reconnecting and conflicts on disk are in
83
+ [Live and Headless](https://docs.erd-editor.io/docs/mcp/live-and-headless).
83
84
 
84
85
  ## Documents
85
86
 
86
- New documents are `.erd.json`: `erd_open_document` with `create` adds the extension to a name that
87
- has none. Existing `.erd`, `.vuerd` and `.vuerd.json` files open too. A file that is not an ERD
88
- document the editor can read, such as one left with merge conflict markers, is refused with
89
- `invalidDocument` and left as it is, never loaded as an empty diagram and written back.
90
-
91
- An agent finds ids with `erd_list`, which lists the settings, the counts and the tables by id, each
92
- with its position and its size on the canvas (the width approximate, the height exact), with their
93
- relationships and indexes, then the memos, and reads columns and other details with `erd_get`, then
94
- passes those ids to the edit tools. `erd_read` answers the whole document at once: the
95
- `snapshot` format lists every entity with its id, the `sql` format generates DDL for any of the
96
- eight supported databases and the `json` format is the raw file. Editing the JSON file by hand is
97
- not supported.
98
-
99
- Schemas of hundreds or thousands of tables work too. A read answers at most 40,000 characters,
100
- under the point where Claude Code sets a tool result aside in a file. `erd_list` answers a page of
101
- 100 tables and says where the next one starts; its `query` finds tables by a word in a table or
102
- column name or comment, and `namesOnly` lists the table names alone, 2,000 short names in one
103
- answer. `erd_get` and `erd_read` take `tableNames` as well as ids, so an agent asked for a SQL query
104
- on a large schema reads the DDL of just the tables it needs. A read too large for one answer is
105
- refused with how to narrow it.
87
+ - `erd_open_document` with `create` makes a missing file, adding `.erd.json` to a name with no
88
+ extension. In an Obsidian vault, name it `.erd`, which the file explorer lists.
89
+ - `erd_list` lists the tables by id, 100 to a page, then the table groups, memos and dictionary
90
+ rows, and finds tables by name, logical name or comment with `query`. `erd_get` reads entities by
91
+ id or table name.
92
+ - `erd_read` answers the whole document as a `snapshot`, as `sql` for any of the eight databases,
93
+ as `json` or as its `scripts`, or the DDL of just the tables or table groups it names.
94
+ - A read answers at most 40,000 characters, or one larger entity whole: `erd_read` says how to
95
+ narrow a larger read, and `erd_get` lists the ids it had no room for.
96
+ - Have the agent edit through the tools rather than write the JSON file itself.
106
97
 
107
98
  ## Tools
108
99
 
109
100
  | Group | Tools |
110
101
  | --- | --- |
111
- | Session | `erd_list_documents`, `erd_open_document`, `erd_list`, `erd_get`, `erd_read`, `erd_save`, `erd_undo`, `erd_redo` |
112
- | Tables | `erd_add_table`, `erd_remove_table`, `erd_change_table_name`, `erd_change_table_comment`, `erd_change_table_color`, `erd_move_table`, `erd_move_tables`, `erd_sort_tables` |
113
- | Columns | `erd_add_column`, `erd_remove_columns`, `erd_change_column_name`, `erd_change_column_data_type`, `erd_change_column_default`, `erd_change_column_comment`, `erd_set_column_primary_key`, `erd_set_column_unique`, `erd_set_column_not_null`, `erd_set_column_auto_increment`, `erd_move_column` |
102
+ | Session | `erd_list_documents`, `erd_open_document`, `erd_list`, `erd_get`, `erd_read`, `erd_list_checks`, `erd_save`, `erd_undo`, `erd_redo` |
103
+ | Tables | `erd_add_table`, `erd_remove_table`, `erd_change_table_name`, `erd_change_table_comment`, `erd_set_table_logical_name`, `erd_change_table_color`, `erd_move_table`, `erd_move_tables`, `erd_sort_tables` |
104
+ | Columns | `erd_add_column`, `erd_remove_columns`, `erd_change_column_name`, `erd_change_column_data_type`, `erd_change_column_default`, `erd_change_column_comment`, `erd_set_column_logical_name`, `erd_set_column_domain`, `erd_set_column_primary_key`, `erd_set_column_unique`, `erd_set_column_not_null`, `erd_set_column_auto_increment`, `erd_move_column` |
114
105
  | Relationships | `erd_add_relationship`, `erd_link_columns`, `erd_remove_relationship`, `erd_change_relationship_type`, `erd_change_relationship_on_delete`, `erd_change_relationship_on_update` |
115
106
  | Indexes | `erd_add_index`, `erd_remove_index`, `erd_change_index_name`, `erd_set_index_unique`, `erd_add_index_column`, `erd_remove_index_column`, `erd_move_index_column`, `erd_set_index_column_order` |
116
107
  | Memos | `erd_add_memo`, `erd_remove_memo`, `erd_change_memo_value`, `erd_change_memo_color`, `erd_move_memo`, `erd_resize_memo` |
117
- | Settings | `erd_set_database`, `erd_set_database_name`, `erd_set_language`, `erd_set_table_name_case`, `erd_set_column_name_case`, `erd_set_bracket_type`, `erd_set_relationship_data_type_sync`, `erd_set_relationship_optimization`, `erd_set_column_order`, `erd_set_max_width_comment`, `erd_set_ignore_save_settings`, `erd_set_show` |
108
+ | Table groups | `erd_add_table_group`, `erd_remove_table_group`, `erd_change_table_group_name`, `erd_change_table_group_color`, `erd_move_table_group`, `erd_resize_table_group`, `erd_set_table_group` |
109
+ | Dictionaries | `erd_add_word`, `erd_update_word`, `erd_remove_word`, `erd_add_term`, `erd_update_term`, `erd_remove_term`, `erd_add_domain`, `erd_update_domain`, `erd_remove_domain`, `erd_derive_physical_names` |
110
+ | Settings | `erd_set_database`, `erd_set_database_name`, `erd_set_ddl_script` |
118
111
  | Import | `erd_import_sql`, `erd_import_graphql`, `erd_import_dbml`, `erd_import_aml`, `erd_import_json` |
119
112
  | Batch | `erd_batch` |
120
113
 
121
- `erd_batch` runs several edit tools in order as one edit, all or none: the operations are tried on
122
- a copy of the document first, so a refused one is named and nothing is applied, and one `erd_undo`
123
- reverts the whole batch. An operation named with `as` lets a later one pass `$name` (or `$name.1`
124
- for its second created id) where it takes an entity id, so a table and its columns take one call.
114
+ - `erd_batch` runs up to 100 edits in order as one, all or none, and one `erd_undo` reverts it. A
115
+ step named with `as` passes the ids it creates to later steps as `$name`, so a table and its
116
+ columns take one call.
117
+ - A logical name set with `erd_set_table_logical_name` or `erd_set_column_logical_name` gives the
118
+ physical name, and a column its domain, from the word, term and domain dictionaries, as in the
119
+ editor; a name set by hand stays while it is not empty. `erd_derive_physical_names` derives the
120
+ names of a column, a table or the whole document again, as the editor's Derive Physical Names
121
+ Again does, after a word or term changed.
122
+ - `erd_list_checks` lists what the dictionaries find, as the Dictionary tab's Checks sheet does:
123
+ forbidden words, words no dictionary lists, synonyms, names two rows share, links to a removed
124
+ domain, physical names other than a term gives and column types other than their domain's, with
125
+ what to use instead where the dictionaries have it.
126
+ - The import tools replace the diagram by default and add to it with `mode: "append"`. The SQL,
127
+ GraphQL, DBML and AML imports keep the dictionaries.
128
+ - The agent sets the database, its name and the Schema SQL scripts; the view and code settings stay
129
+ yours to set in the editor.
130
+ - The edit and read tools refuse an unknown or mistyped argument before the document changes.
131
+
132
+ Every tool with its arguments and results is in [Tools](https://docs.erd-editor.io/docs/mcp/tools).
125
133
 
126
- `erd_change_relationship_on_delete` and `erd_change_relationship_on_update`, and the `onDelete` /
127
- `onUpdate` of `erd_add_relationship` and `erd_link_columns`, set a foreign key's ON DELETE and ON
128
- UPDATE actions. An ERD Editor extension or plugin released before referential actions ignores them
129
- when it serves the document, so update it.
130
-
131
- Every edit tool takes the document `path`. Settings other than `erd_set_show`, and
132
- `erd_resize_memo`, make no undo entry in the editor, so `erd_undo` passes over them and the result
133
- says so.
134
+ ## Documentation
134
135
 
135
- The edit tools, `erd_batch` and the read tools (`erd_list`, `erd_get`, `erd_read`) refuse an
136
- argument they do not declare, or one of the wrong type, with a JSON-RPC invalid params error
137
- (-32602) before touching the document, so a misspelled argument is never silently dropped. The
138
- other session tools ignore arguments they do not know.
136
+ - [Introduction](https://docs.erd-editor.io/docs/mcp/introduction) — what an agent can do and how it
137
+ works
138
+ - [Install](https://docs.erd-editor.io/docs/mcp/installation) — each client and each editor
139
+ - [Live and Headless](https://docs.erd-editor.io/docs/mcp/live-and-headless) — where an edit lands,
140
+ saving, undo, conflicts
141
+ - [Tools](https://docs.erd-editor.io/docs/mcp/tools) — every tool, paging a large schema, results
142
+ and refusals
139
143
 
140
- ## Documentation
144
+ ## Issues
141
145
 
142
- - [Introduction](https://docs.erd-editor.io/docs/mcp/introduction) — what an agent can and cannot
143
- do, how it works, requirements
144
- - [Install](https://docs.erd-editor.io/docs/mcp/installation) — Claude Code, Codex and any other
145
- client, setting up VS Code, updating
146
- - [Live and Headless](https://docs.erd-editor.io/docs/mcp/live-and-headless) — where an edit
147
- lands, saving, undo, a window that goes away, conflicts on disk
148
- - [Tools](https://docs.erd-editor.io/docs/mcp/tools) — every tool with its arguments, paging a
149
- large schema, `erd_batch`, results and refusals
146
+ Found a bug or want a feature? [Open an issue](https://github.com/dineug/erd-editor/issues).
150
147
 
151
148
  ## License
152
149