@dineug/erd-editor-mcp 0.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/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/erd-editor-mcp.js +66 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 SeungHwan-Lee <dineug2@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @dineug/erd-editor-mcp
|
|
2
|
+
|
|
3
|
+
> An MCP server that lets a coding agent edit [erd-editor](https://github.com/dineug/erd-editor)
|
|
4
|
+
> diagrams, live in VS Code or straight on disk
|
|
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 agent joins the editor as a collaborator: every call shows up on the canvas as it happens, with
|
|
11
|
+
the agent's focus on the cell it is editing. With no editor around, the same tools edit the file
|
|
12
|
+
itself.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
The package is one self-contained file with no runtime dependencies. It needs Node.js 22.12 or
|
|
17
|
+
later.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
### Claude Code
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
claude mcp add --transport stdio erd-editor -- npx -y @dineug/erd-editor-mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Codex
|
|
28
|
+
|
|
29
|
+
Add to `~/.codex/config.toml`, or to `.codex/config.toml` in a trusted project:
|
|
30
|
+
|
|
31
|
+
```toml
|
|
32
|
+
[mcp_servers.erd-editor]
|
|
33
|
+
command = "npx"
|
|
34
|
+
args = ["-y", "@dineug/erd-editor-mcp"]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Any other MCP client
|
|
38
|
+
|
|
39
|
+
Run `npx -y @dineug/erd-editor-mcp` as a stdio server. It resolves relative document paths
|
|
40
|
+
against its working directory, so start it in your project.
|
|
41
|
+
|
|
42
|
+
## Live and headless
|
|
43
|
+
|
|
44
|
+
For every edit the server looks for a VS Code window that holds the document, through the lock
|
|
45
|
+
files the extension keeps in `~/.erd-editor/ide/`:
|
|
46
|
+
|
|
47
|
+
| What it finds | What an edit does |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| A window whose workspace contains the document, or 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 and stay unsaved until the agent calls `erd_save` (or you save). The agent's `erd_undo` reverts only its own edits. |
|
|
50
|
+
| No window | **Headless.** Loads the file, applies the change and replaces the file atomically. `erd_save` has nothing to do. |
|
|
51
|
+
| A window 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. |
|
|
52
|
+
|
|
53
|
+
The live hub runs in trusted workspaces and is on by default. Turn it off with the VS Code setting
|
|
54
|
+
`dineug.erd-editor.agentHub.enabled`; the window then still guards its documents from headless
|
|
55
|
+
writes. The extension activates in workspaces that contain `.erd`, `.erd.json`, `.vuerd` or
|
|
56
|
+
`.vuerd.json` files.
|
|
57
|
+
|
|
58
|
+
The server never falls back to the file on its own while a window holds a document: if the
|
|
59
|
+
connection drops it reconnects, and only when that window has exited does it edit the file and say
|
|
60
|
+
so in the result.
|
|
61
|
+
|
|
62
|
+
## Documents
|
|
63
|
+
|
|
64
|
+
New documents are `.erd.json`: `erd_open_document` with `create` adds the extension to a name that
|
|
65
|
+
has none. Existing `.erd`, `.vuerd` and `.vuerd.json` files open too. A file that is not an ERD
|
|
66
|
+
document the editor can read, such as one left with merge conflict markers, is refused with
|
|
67
|
+
`invalidDocument` and left as it is, never loaded as an empty diagram and written back.
|
|
68
|
+
|
|
69
|
+
An agent finds ids with `erd_list`, which lists the settings, the counts and the tables by id, each
|
|
70
|
+
with its position and its size on the canvas (the width approximate, the height exact), with their
|
|
71
|
+
relationships and indexes, then the memos, and reads columns and other details with `erd_get`, then
|
|
72
|
+
passes those ids to the edit tools. `erd_read` answers the whole document at once: the
|
|
73
|
+
`snapshot` format lists every entity with its id, the `sql` format generates DDL for any of the
|
|
74
|
+
eight supported databases and the `json` format is the raw file. Editing the JSON file by hand is
|
|
75
|
+
not supported.
|
|
76
|
+
|
|
77
|
+
Schemas of hundreds or thousands of tables work too. A read answers at most 40,000 characters,
|
|
78
|
+
under the point where Claude Code sets a tool result aside in a file. `erd_list` answers a page of
|
|
79
|
+
100 tables and says where the next one starts; its `query` finds tables by a word in a table or
|
|
80
|
+
column name or comment, and `namesOnly` lists the table names alone, 2,000 short names in one
|
|
81
|
+
answer. `erd_get` and `erd_read` take `tableNames` as well as ids, so an agent asked for a SQL query
|
|
82
|
+
on a large schema reads the DDL of just the tables it needs. A read too large for one answer is
|
|
83
|
+
refused with how to narrow it.
|
|
84
|
+
|
|
85
|
+
## Tools
|
|
86
|
+
|
|
87
|
+
| Group | Tools |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| Session | `erd_list_documents`, `erd_open_document`, `erd_list`, `erd_get`, `erd_read`, `erd_save`, `erd_undo`, `erd_redo` |
|
|
90
|
+
| 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` |
|
|
91
|
+
| 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` |
|
|
92
|
+
| Relationships | `erd_add_relationship`, `erd_link_columns`, `erd_remove_relationship`, `erd_change_relationship_type` |
|
|
93
|
+
| 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` |
|
|
94
|
+
| Memos | `erd_add_memo`, `erd_remove_memo`, `erd_change_memo_value`, `erd_change_memo_color`, `erd_move_memo`, `erd_resize_memo` |
|
|
95
|
+
| 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` |
|
|
96
|
+
| Import | `erd_import_sql`, `erd_import_graphql`, `erd_import_dbml`, `erd_import_aml`, `erd_import_json` |
|
|
97
|
+
| Batch | `erd_batch` |
|
|
98
|
+
|
|
99
|
+
`erd_batch` runs several edit tools in order as one edit, all or none: the operations are tried on
|
|
100
|
+
a copy of the document first, so a refused one is named and nothing is applied, and one `erd_undo`
|
|
101
|
+
reverts the whole batch. An operation named with `as` lets a later one pass `$name` (or `$name.1`
|
|
102
|
+
for its second created id) where it takes an entity id, so a table and its columns take one call.
|
|
103
|
+
|
|
104
|
+
Every edit tool takes the document `path`. Settings other than `erd_set_show`, and
|
|
105
|
+
`erd_resize_memo`, make no undo entry in the editor, so `erd_undo` passes over them and the result
|
|
106
|
+
says so.
|
|
107
|
+
|
|
108
|
+
The edit tools, `erd_batch` and the read tools (`erd_list`, `erd_get`, `erd_read`) refuse an
|
|
109
|
+
argument they do not declare, or one of the wrong type, with a JSON-RPC invalid params error
|
|
110
|
+
(-32602) before touching the document, so a misspelled argument is never silently dropped. The
|
|
111
|
+
other session tools ignore arguments they do not know.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
[MIT](https://github.com/dineug/erd-editor/blob/main/LICENSE)
|