# erd-editor MCP server

> Lets coding agents design and edit database schemas visually through ERD diagrams in your IDE or browser.

- Repository: https://github.com/dineug/erd-editor
- Page: https://hostedmcp.org/servers/dineug/erd-editor
- Transport: stdio
- Stars: 1751
- License: MIT

## Install

### Claude Code

```sh
claude mcp add erd-editor -- npx -y @dineug/erd-editor-mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "erd-editor": {
      "command": "npx",
      "args": [
        "-y",
        "@dineug/erd-editor-mcp"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "erd-editor": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@dineug/erd-editor-mcp"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"erd-editor","type":"stdio","command":"npx","args":["-y","@dineug/erd-editor-mcp"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "erd-editor": {
      "command": "npx",
      "args": [
        "-y",
        "@dineug/erd-editor-mcp"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add erd-editor -- npx -y @dineug/erd-editor-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.erd-editor]
command = "npx"
args = ["-y", "@dineug/erd-editor-mcp"]
```

### Gemini CLI

```sh
gemini mcp add -s user erd-editor npx -- -y @dineug/erd-editor-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "erd-editor": {
      "command": "npx",
      "args": [
        "-y",
        "@dineug/erd-editor-mcp"
      ]
    }
  }
}
```

## Tools (77)

- `erd_list_documents`: Lists ERD documents with path, open, active, dirty and readonly. With an editor serving the working directory (the VS Code extension, the Obsidian plugin or the JetBrains IDE plugin) it lists that editor's, every open project's in a JetBrains IDE; otherwise the ERD files under the working directory. (read-only)
- `erd_open_document`: Opens a document for editing, in the ERD editor of the editor that serves it, if one does (the VS Code extension, the Obsidian plugin or the JetBrains IDE plugin). With create it makes the file first if missing; a name with no extension gets .erd.json.
- `erd_save`: Saves a document an editor holds to disk. VS Code keeps edits unsaved until this is called; Obsidian and JetBrains IDEs save them as they save the user’s edits, and this writes them at once. On disk, with no editor, edits are written at once and this does nothing.
- `erd_undo`: Reverts the last edit this agent made to the document, never the user’s edits. Calls that made no undo entry are skipped and named.
- `erd_redo`: Applies again the edit erd_undo last reverted.
- `erd_read`: Reads a document as a snapshot, as DDL, as its raw JSON or, with the scripts format, its before and after scripts alone. The sql format of the whole document includes the document's before and after scripts. The sql format with tableIds, tableNames or groupNames gives the DDL of just those tables, the way to read a large schema; a read too large for one answer is refused with how to narrow it. For ids and details prefer erd_list and erd_get. Change a document only through the erd_ tools, never by writing its file. (read-only)
- `erd_list`: Lists a document: its settings and counts, then a page of tables, each with its id, position and size on the ERD canvas (the width approximate, the height exact), with their indexes and relationships (each relationship once, with one of its tables) and, for a table in a table group or with a logical name, its groupId or logicalName; after the tables come the table groups, the memos, then the rows of the domain, term and word dictionaries, each with its name and what it gives a physical name or column. A small schema fits in one page. On a larger one, nextOffset and note say how to go on: query finds tables by a word, namesOnly lists every table name in a call or a few. Columns, comments, memo text, the tables of a group and every field of a dictionary row come from erd_get; the foreign keys a table holds, from erd_read sql with tableNames. (read-only)
- `erd_get`: Gives the entities named, in full: tables with their columns and size, relationships with their columns, indexes with their columns, memos with their text, table groups with their tables, and words, terms and domains with every field. Ids and names that name nothing live are listed in missing; ids one answer has no room for are listed in notReturned, to ask for again. (read-only)
- `erd_list_checks`: Lists what the word, term and domain dictionaries find, as the Checks sheet of the editor's Dictionary tab does, and changes nothing. Errors: a name two rows of one dictionary share, a link to a domain the document does not list, a forbidden word in a logical name or a term's name. Warnings: a word no dictionary lists, a synonym used for a standard word, each in a logical name or a term's name, a physical name other than the one the term of its logical name gives, a column type other than its domain's. Each check names its target (a table, a column with its table, or a word, term or domain row) with its names, the field read, the text found and, where the dictionaries have them, the suggestions to use instead, and counts gives each code's total. The words, terms and domains come first in sheet order, then each table and its columns in document order. With no dictionary row nothing is checked. A long list comes a page at a time: pass nextOffset, or list again from offset 0 after fixing some, since a fixed check leaves the list. (read-only)
- `erd_add_table`: Adds an empty table at a free spot and returns its id in createdIds. Name it with erd_change_table_name.
- `erd_remove_table`: Removes a table with its columns, indexes and every relationship that touches it.
- `erd_change_table_name`: Renames a table. The name is then its own: nameDerived goes off, so a later logical name leaves a name that is not empty as it is.
- `erd_change_table_comment`: Sets the comment of a table.
- `erd_set_table_logical_name`: Sets the logical name of a table. While its physical name is empty or derived, the dictionaries derive it as erd_set_column_logical_name does, a term giving no domain to a table. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_change_table_color`: Sets the color of a table.
- `erd_move_table`: Moves a table to an absolute canvas position.
- `erd_move_tables`: Moves several tables to absolute canvas positions in one edit, which one erd_undo reverts. Plan the layout from the positions and sizes erd_list gives.
- `erd_sort_tables`: Arranges every table on the canvas automatically, as the editor sort command does: the tables of a table group stay together and the group's rect is fitted round them, which tables it holds unchanged.
- `erd_add_column`: Adds an empty column to a table and returns its id in createdIds. Set it with the erd_change_column_ and erd_set_column_ tools.
- `erd_remove_columns`: Removes columns from one table, with the relationships and index entries that use them.
- `erd_change_column_data_type`: Sets the data type of a column, such as INT or VARCHAR(255). With relationship data type sync on, the change spreads along relationships both ways: into the foreign keys that copy the column, a serial type as the integer it stores (as erd_add_relationship copies it), and from a foreign key back to the key it copies, except a serial key, which keeps its type and stops the change there. A column linked to a dictionary domain is unlinked from it when set to another type than the domain's, and so is any column the sync reaches, a foreign key or the key it copies, whose new type differs from its own domain's.
- `erd_change_column_name`: Renames a column. The name is then its own: nameDerived goes off, so a later logical name leaves a name that is not empty as it is.
- `erd_change_column_default`: Sets the default value of a column.
- `erd_change_column_comment`: Sets the comment of a column.
- `erd_set_column_logical_name`: Sets the logical name of a column. While its physical name is empty or derived, the dictionaries derive it: a term of that name gives its physical name and links its domain, otherwise the words of the name compose one, their abbreviations joined with underscores. A physical name written by hand stays, and a name another column of the table holds is not given again. The domain a term links gives the column its data type, spread along relationships while relationship data type sync is on. A column the sync reaches whose new type differs from its own domain's is unlinked from that domain. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_set_column_domain`: Links a column to a dictionary domain, which gives it the domain's data type, spread along relationships while relationship data type sync is on; null or an empty name unlinks it and keeps its type. A column the sync reaches whose new type differs from its own domain's is unlinked from that domain. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_set_column_primary_key`: Sets whether the column is part of the primary key. Setting the value it already has changes nothing.
- `erd_set_column_unique`: Sets whether the column is unique. Setting the value it already has changes nothing.
- `erd_set_column_not_null`: Sets whether the column is NOT NULL. Setting the value it already has changes nothing.
- `erd_set_column_auto_increment`: Sets whether the column is auto increment. Setting the value it already has changes nothing.
- `erd_move_column`: Moves a column within its table to the position of another column.
- `erd_add_relationship`: Relates two tables: copies the parent primary key into the child as foreign key columns, creating an unnamed primary key column first if the parent has none (its foreign key column is unnamed too). Each foreign key column is named from its key: a key of one word, only letters and digits with no camelCase break and no switch between cased letters and caseless ones such as Hangul or kana (id, ID, uuid, id2), gets the parent table and an underscore in front (users_id for the key id of users), any other key (member_id, userId, UserID, 회원ID, _id, order-no) or one equal to the table name stays as it is, and a name the child already has is numbered (users_id_2). Each foreign key column copies the data type of its key, but a serial key gives the integer it stores: serial4 integer, smallserial and serial2 smallint, bigserial and serial8 bigint, and a bare serial integer under PostgreSQL, bigint unsigned under MySQL and MariaDB and serial elsewhere, written in capitals when the type of the key is. Each foreign key column also takes the logical name of its key, whatever name it gets, and links the dictionary domain its key links, unless a serial key gives it another type than the domain's. Name the parent table first: an unnamed parent gives the key name alone (id), and a later rename leaves these names as they are. createdIds holds, in order, that new parent key column if one was made, the foreign key columns, then the relationship id last.
- `erd_link_columns`: Draws a relationship between columns that already exist, such as a foreign key imported from code. Pairs start and end columns by position.
- `erd_remove_relationship`: Removes a relationship line; its foreign key columns stay in the table.
- `erd_change_relationship_type`: Changes the cardinality of a relationship.
- `erd_change_relationship_on_delete`: Sets the ON DELETE action of a relationship: what deleting a parent row does to its child rows. An ERD Editor extension or plugin released before referential actions ignores this setting, so the user should update it.
- `erd_change_relationship_on_update`: Sets the ON UPDATE action of a relationship: what changing a parent key does to its child rows. An ERD Editor extension or plugin released before referential actions ignores this setting, so the user should update it.
- `erd_add_index`: Adds an empty index to a table and returns its id in createdIds; add columns with erd_add_index_column.
- `erd_remove_index`: Removes an index.
- `erd_change_index_name`: Renames an index.
- `erd_set_index_unique`: Sets whether an index is unique. Setting the value it already has changes nothing.
- `erd_add_index_column`: Adds a column of the index table to the index, returning the new index column id; a column already in the index is left alone.
- `erd_remove_index_column`: Removes one column from an index.
- `erd_move_index_column`: Moves a column within an index to the position of another of its columns.
- `erd_set_index_column_order`: Sets the sort order of one column in an index. Setting the order it already has changes nothing.
- `erd_add_memo`: Adds an empty memo note at a free spot and returns its id in createdIds.
- `erd_remove_memo`: Removes a memo.
- `erd_change_memo_value`: Replaces the text of a memo.
- `erd_change_memo_color`: Sets the color of a memo.
- `erd_move_memo`: Moves a memo to an absolute canvas position.
- `erd_resize_memo`: Resizes a memo. erd_undo cannot revert it: the editor keeps no undo entry for a single resize.
- `erd_add_table_group`: Adds a table group, a named box drawn behind its tables, and returns its id in createdIds. Pass tableIds to wrap those tables, each leaving any group it was in, or a rect (x, y, width and height), which takes in every table in no group whose centre lies inside it, as drawing a group in the editor does. A table is in one group at most. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_remove_table_group`: Removes a table group; its tables stay where they are, in no group. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_change_table_group_name`: Renames a table group. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_change_table_group_color`: Sets the color of a table group, which its box and the headers of its tables take. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_move_table_group`: Moves a table group so its rect starts at an absolute canvas position, its tables by the same step. Moving a table or a group never changes which tables a group holds. A move under 20 pixels in all makes no undo entry. An ERD Editor extension or plugin released before table groups moves only the tables of the group and drops every group when it saves, so the user should update it.
- `erd_resize_table_group`: Sets the rect of a table group, its tables staying where they are; the editor draws the box grown to hold each of them. It is refused smaller than 160 by 100 or than the tables with their padding, naming the box the rect must hold. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_set_table_group`: Puts tables in a table group, each leaving any group it was in, or with groupId null takes them out of their groups. Tables already where they go are left alone. An ERD Editor extension or plugin released before table groups ignores this edit and drops every group when it saves, so the user should update it.
- `erd_add_word`: Adds a word to the word dictionary, the standard words a logical name is composed of, and returns its id in createdIds. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_update_word`: Changes the fields of a word that the call passes and leaves the rest; values it already holds change nothing. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_remove_word`: Removes a word from the word dictionary; the names it composed stay as they are. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_add_term`: Adds a term, a logical name with the physical name and the domain it gives, and returns its id in createdIds. Without a physical name the words compose one. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_update_term`: Changes the fields of a term that the call passes and leaves the rest; values it already holds change nothing. The tables and columns named from it keep their names and domains. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_remove_term`: Removes a term; the tables and columns named from it keep their names and domains. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_add_domain`: Adds a domain, a named data type columns link to, and returns its id in createdIds. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_update_domain`: Changes the fields of a domain that the call passes and leaves the rest; values it already holds change nothing. A new data type reaches every column linking the domain, and along relationships while relationship data type sync is on. A column the sync reaches whose new type differs from its own domain's is unlinked from that domain. A name another row of the same dictionary holds is refused. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_remove_domain`: Removes a domain; the columns linking it keep their data type and show no domain. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_derive_physical_names`: Derives physical names again from the logical names, as the editor's Derive Physical Names Again does. Each covered table or column with a logical name goes back under the dictionaries, its nameDerived on, and takes the name they give now, a physical name written by hand included: a term's physical name and, for a column, its domain, else the words' composition. A name with no logical name stays as it is, and so does a column whose new name another column of its table holds or took first, such as a second foreign key to one table or a role name. Changing a word's abbreviation or a term's physical name leaves the names given before as they are, so call this after one; a term's own physical name is never composed again, so update the term first. One erd_undo reverts the call. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_set_database_name`: Sets the database name of the document. erd_undo cannot revert it: the editor keeps no undo entry for this setting.
- `erd_set_database`: Sets the database vendor, which picks the data types and the default DDL of erd_read sql. erd_undo cannot revert it: the editor keeps no undo entry for this setting.
- `erd_set_ddl_script`: Sets one of the two SQL scripts the document keeps for its Schema SQL: before, written ahead of the tables, such as CREATE EXTENSION or CREATE SCHEMA, or after, written past the generated DDL, such as GRANT or CREATE VIEW. It replaces the whole script, so read the current one first with erd_read format scripts. The text goes as is into the DDL of every database, so write it for the document's database; SQL Server output gets GO after a script that does not end with GO. An empty string removes it. erd_read sql shows it in place. An ERD Editor extension or plugin released before scripts neither shows nor keeps them, so the user should update it.
- `erd_import_sql`: Replaces every table, relationship, index, memo and table group of the document with the schema parsed from SQL DDL (CREATE TABLE statements), keeping its settings but the view, which goes to the start of the canvas, and keeping its word, term and domain dictionaries; erd_undo restores what it replaced. With mode append it instead adds the schema's tables, relationships and indexes as new ones in a grid below the diagram, leaving every table and setting already there as it is; a foreign key to a table the text does not declare is dropped.
- `erd_import_graphql`: Replaces every table, relationship, index, memo and table group of the document with the schema parsed from a GraphQL SDL, keeping its settings but the view, which goes to the start of the canvas, and keeping its word, term and domain dictionaries; erd_undo restores what it replaced. With mode append it instead adds the schema's tables, relationships and indexes as new ones in a grid below the diagram, leaving every table and setting already there as it is; a foreign key to a table the text does not declare is dropped.
- `erd_import_dbml`: Replaces every table, relationship, index, memo and table group of the document with the schema parsed from DBML, keeping its settings but the view, which goes to the start of the canvas, and keeping its word, term and domain dictionaries; erd_undo restores what it replaced. With mode append it instead adds the schema's tables, relationships and indexes as new ones in a grid below the diagram, leaving every table and setting already there as it is; a foreign key to a table the text does not declare is dropped. Either way a TableGroup becomes a table group of the tables it names, with its name and color, its box round them; a table named by two groups stays in the first, and a group naming no declared table is left out. An ERD Editor extension or plugin released before table groups drops every group when it saves, so the user should update it.
- `erd_import_aml`: Replaces every table, relationship, index, memo and table group of the document with the schema parsed from AML, keeping its settings but the view, which goes to the start of the canvas, and keeping its word, term and domain dictionaries; erd_undo restores what it replaced. With mode append it instead adds the schema's tables, relationships and indexes as new ones in a grid below the diagram, leaving every table and setting already there as it is; a foreign key to a table the text does not declare is dropped.
- `erd_import_json`: Replaces the whole document, its settings included, with an erd-editor JSON document such as another .erd.json file: the settings and locks it holds take the place of this document's, and one without lockSettings turns every lock on and puts the view at the start of the canvas. To keep this document's settings, start from the text erd_read json gives. erd_undo restores the previous document. With mode append it instead adds that document's tables, relationships, indexes, memos and table groups as new ones below the diagram, apart as the file places them, and keeps this document's settings; the tables bring their logical names and derived flags, but no column links a domain and none of the document's words, terms and domains is added. An ERD Editor extension or plugin released before table groups drops every group when it saves, so the user should update it. An ERD Editor extension or plugin released before dictionaries, logical names and domains ignores what this edit writes of them and leaves them out when it saves, so the user should update it.
- `erd_batch`: Runs several edit tools in order as one edit, all or none: they are tried on a copy first, so a refusal names the operation and leaves the document as it was. One erd_undo reverts the whole batch. Name an operation with as, then pass $name for its first created id, $name.1 for its second or $name.last for its last, where a later operation takes an entity id.

## FAQ

### How can I use erd-editor with coding agents?

You can ask Claude Code, Codex, or any MCP client to change the schema, and the agent will edit the diagram on the canvas.

### What databases can I export DDL for?

The editor supports exporting DDL for Databricks, MariaDB, MSSQL, MySQL, Oracle, PostgreSQL, Snowflake, and SQLite.

### Can I import existing schemas?

Yes, you can import SQL DDL, GraphQL SDL, DBML, and AML to replace or add to your existing diagram.

### What are the system requirements for the MCP server?

The MCP server requires Node.js version 22.12 or later.
