Skip to main content

Tools

The server offers 63 tools: five session tools, three read tools, 54 edit tools, one per editing operation, and erd_batch, which runs several edit tools as one edit.

Every tool but erd_list_documents takes the document's path as its first argument, and the tables below leave it out. An argument marked ? is optional.

Session Tools

ToolArgumentsWhat it does
erd_list_documentsLists ERD documents with path, open, active, dirty, and readonly: a VS Code window's documents when one serves the working directory, otherwise the ERD files under the working directory.
erd_open_documentcreate?Opens a document for editing, in the ERD Editor when a window serves it. With create it makes the file first if it is missing, and a name with no extension gets .erd.json.
erd_saveSaves a document the editor holds. Headless, every edit is already written and this does nothing.
erd_undoReverts the last edit this agent made, never yours. Calls that made no undo entry are passed over and named.
erd_redoApplies again the edit erd_undo last reverted.

See Live and Headless for what saving and undo do in each mode.

Reading a Document

ToolArgumentsWhat it does
erd_listquery?, offset?, limit?, namesOnly?The settings and counts, then a page of tables, each with its id, position and size on the canvas, and column count, with their indexes and relationships, and after the tables, unless it searches, the memos.
erd_gettableIds?, tableNames?, relationshipIds?, indexIds?, memoIds?The entities named, in full: tables with their columns, relationships and indexes with their columns, memos with their text.
erd_readformat, vendor?, tableIds?, tableNames?The whole document at once in one of three formats, or the DDL of just some tables.

An agent finds ids with erd_list, reads columns and other details with erd_get, and passes those ids to the edit tools. A table's size in erd_list is the box it takes on the canvas: the height exact, the width approximate. Each relationship is listed once, with one of its two tables.

erd_read takes one of three formats:

formatWhat it answers
snapshotCompact JSON with every entity and its id. Large on a big schema.
sqlDDL for one of the eight databases, Databricks, MariaDB, MSSQL, MySQL, Oracle, PostgreSQL, Snowflake, or SQLite. vendor defaults to the database the document is set to. With tableIds or tableNames, only those tables, with the foreign keys they hold.
jsonThe raw .erd.json document.

Large Schemas

Schemas of hundreds or thousands of tables work too. A read answers at most 40,000 characters, under the point where Claude Code sets a tool result aside in a file.

  • erd_list answers a page of 100 tables by default, and says where the next page starts with nextOffset and a note. Pass that nextOffset as offset, with the same query.
  • query finds tables by words in a table or column name or comment, in any case. Tables whose names hold more of the words come first.
  • namesOnly lists the table names alone, about 2,000 short names in one answer.
  • erd_get and erd_read take tableNames as well as ids, so an agent asked for a SQL query on a large schema reads the DDL of just the tables it needs.
  • erd_get lists ids and names that name nothing under missing, and the ids one answer has no room for under notReturned, to ask for again.
  • A read too large for one answer is refused with tooLarge, with how to narrow it.

Edit Tools

Ids come from erd_list and erd_get, or from the createdIds of the call that made the entity. x and y are the left and top edges on the canvas, in pixels, and a color is a CSS hex color such as #3b82f6.

Tables

ToolArgumentsWhat it does
erd_add_tableAdds an empty table at a free spot and returns its id in createdIds.
erd_remove_tabletableIdRemoves a table with its columns, indexes, and every relationship that touches it.
erd_change_table_nametableId, valueRenames a table.
erd_change_table_commenttableId, valueSets the comment of a table. An empty string clears it.
erd_change_table_colortableId, colorSets the color of a table.
erd_move_tabletableId, x, yMoves a table to a position on the canvas.
erd_move_tablespositionsMoves several tables in one edit, which one erd_undo reverts. positions holds { tableId, x, y } per table, each table at most once.
erd_sort_tablesPlaces every table in rows across the canvas, fewest columns first, as an import places them.

Columns

ToolArgumentsWhat it does
erd_add_columntableIdAdds an empty column to a table and returns its id in createdIds.
erd_remove_columnstableId, columnIdsRemoves columns from one table, with the relationships and index entries that use them.
erd_change_column_nametableId, columnId, valueRenames a column.
erd_change_column_data_typetableId, columnId, valueSets the data type, such as INT or VARCHAR(255). Foreign keys that copy it follow when Relationship DataType Sync is on.
erd_change_column_defaulttableId, columnId, valueSets the default, as SQL text. An empty string clears it.
erd_change_column_commenttableId, columnId, valueSets the comment. An empty string clears it.
erd_set_column_primary_keytableId, columnId, valuetrue makes the column part of the primary key, false takes it out.
erd_set_column_uniquetableId, columnId, valueSets whether the column is unique.
erd_set_column_not_nulltableId, columnId, valueSets whether the column is NOT NULL.
erd_set_column_auto_incrementtableId, columnId, valueSets whether the column auto-increments.
erd_move_columntableId, columnId, targetColumnIdMoves a column within its table to the position of another column.

Relationships

relationshipType is the cardinality at the child end: ZeroOne, ZeroN, OneOnly, or OneN. The start table is the parent, the referenced side that holds the primary key, and the end table is the child.

ToolArgumentsWhat it does
erd_add_relationshipstartTableId, endTableId, relationshipTypeRelates two tables. It copies the parent's primary key into the child as foreign key columns, creating a primary key column first if the parent has none. createdIds holds that new key column if one was made, the foreign key columns, and the relationship id last.
erd_link_columnsstartTableId, startColumnIds, endTableId, endColumnIds, relationshipTypeDraws a relationship between columns that already exist, pairing start and end columns by position.
erd_remove_relationshiprelationshipIdRemoves a relationship line. Its foreign key columns stay in the table.
erd_change_relationship_typerelationshipId, relationshipTypeChanges the cardinality of a relationship.

Indexes

An index column id is an entry of the index's column list that erd_get gives, not the table column's id.

ToolArgumentsWhat it does
erd_add_indextableIdAdds an empty index to a table and returns its id in createdIds.
erd_remove_indexindexIdRemoves an index.
erd_change_index_nameindexId, valueRenames an index.
erd_set_index_uniqueindexId, valueSets whether the index is unique.
erd_add_index_columnindexId, columnIdAdds a column of the index's table and returns the new index column id. A column already in the index is left alone.
erd_remove_index_columnindexId, indexColumnIdRemoves one column from an index.
erd_move_index_columnindexId, indexColumnId, targetIndexColumnIdMoves a column within an index to the position of another of its columns.
erd_set_index_column_orderindexId, indexColumnId, orderTypeSets the sort order of one column in an index, ASC or DESC.

Memos

ToolArgumentsWhat it does
erd_add_memoAdds an empty memo at a free spot and returns its id in createdIds.
erd_remove_memomemoIdRemoves a memo.
erd_change_memo_valuememoId, valueReplaces the text of a memo.
erd_change_memo_colormemoId, colorSets the color of a memo.
erd_move_memomemoId, x, yMoves a memo to a position on the canvas.
erd_resize_memomemoId, width, heightResizes a memo. The width must be at least about 116 pixels and the height at least 100. It makes no undo entry, since the editor records a memo resize only from a drag.

Settings

The settings stored in the document, such as the database, the Code Generator options, and those on the Settings tab. None of them but erd_set_show makes an undo entry, so erd_undo cannot revert them.

ToolArgumentsValues
erd_set_databasevalueMariaDB, MSSQL, MySQL, Oracle, PostgreSQL, SQLite, Databricks, Snowflake. It picks the database's data types, and the DDL erd_read writes when no vendor is given.
erd_set_database_namevalueThe database name.
erd_set_languagevalueThe Code Generator language: GraphQL, csharp, Java, Kotlin, TypeScript, JPA, Scala, Go, SQLAlchemy, TypeORM, Sequelize, Drizzle, DBML, AML.
erd_set_table_name_casevalueThe name case of generated table names: none, camelCase, pascalCase, snakeCase.
erd_set_column_name_casevalueThe same, for column names.
erd_set_bracket_typevalueHow generated SQL quotes names: none, doubleQuote, singleQuote, backtick.
erd_set_relationship_data_type_syncvaluetrue keeps foreign key columns on the data type of the columns they reference.
erd_set_relationship_optimizationvalueThe relationship optimization flag stored in the document.
erd_set_column_ordercolumnType, targetColumnTypeMoves one part of a table row to the place of another: columnName, columnDataType, columnNotNull, columnUnique, columnAutoIncrement, columnDefault, columnComment.
erd_set_max_width_commentvalueThe widest a comment is drawn in a table, in pixels, or -1 for no limit.
erd_set_ignore_save_settingssaveSettingType, valuetrue leaves scroll or zoomLevel out of the saved file.
erd_set_showshow, valueShows or hides one part of the diagram: tableComment, columnComment, columnDataType, columnDefault, columnAutoIncrement, columnPrimaryKey, columnUnique, columnNotNull, relationship.

Import

Each of these replaces the whole document, and erd_undo restores the one before. They read a schema the way the editor's Import menu does — see Importing or Exporting Files.

ToolArgumentsWhat it does
erd_import_sqlvalueLoads SQL DDL, CREATE TABLE statements and the like.
erd_import_graphqlvalueLoads a GraphQL SDL.
erd_import_dbmlvalueLoads DBML.
erd_import_amlvalueLoads AML.
erd_import_jsonvalueLoads an erd-editor JSON document, such as another .erd.json file. An empty text gives an empty document.

erd_batch

erd_batch runs several edit tools in order as one edit, all or none.

  • operations holds up to 100 entries, each { tool, as?, args? }, where args are the tool's arguments without path.
  • The operations are tried on a copy of the document first. A refused one is named, such as operations[1] erd_remove_table: …, and nothing is applied.
  • One erd_undo reverts the whole batch. historyEntries in the result counts the editor's history entries inside it, not erd_undo calls.
  • In a live session the editor takes the whole batch or none of it.

An agent cannot know the ids a batch creates before it calls, so an operation named with as lets a later one refer to them: $name or $name.0 for its first created id, $name.1 for its second, and $name.last for its last. A reference resolves only where an argument takes an entity id, so a name or comment that reads $x stays text.

A table with its columns and a relationship, in one call:

{
"path": "shop.erd.json",
"operations": [
{ "tool": "erd_add_table", "as": "users" },
{ "tool": "erd_change_table_name", "args": { "tableId": "$users", "value": "users" } },
{ "tool": "erd_add_column", "as": "uid", "args": { "tableId": "$users" } },
{ "tool": "erd_change_column_name", "args": { "tableId": "$users", "columnId": "$uid", "value": "id" } },
{ "tool": "erd_change_column_data_type", "args": { "tableId": "$users", "columnId": "$uid", "value": "BIGINT" } },
{ "tool": "erd_set_column_primary_key", "args": { "tableId": "$users", "columnId": "$uid", "value": true } },
{ "tool": "erd_add_table", "as": "orders" },
{ "tool": "erd_change_table_name", "args": { "tableId": "$orders", "value": "orders" } },
{ "tool": "erd_add_relationship", "args": { "startTableId": "$users", "endTableId": "$orders", "relationshipType": "ZeroN" } }
]
}

Results

An edit answers one line of JSON:

{"tool":"erd_add_table","mode":"live","createdIds":["b7u59tHkuXTA1hhtWh_bD"],"batches":1,"historyEntries":1}
FieldMeaning
modelive or headless — see Live and Headless.
createdIdsThe ids of what the call created, in order.
batches, historyEntriesHow many change batches the call sent and how many editor history entries it made.
undoable, undoNoteundoable is false when erd_undo will pass over the call, and undoNote says why: the tool makes no undo entry, or the document already held the value. An erd_batch result always carries an undoNote, which says that one erd_undo reverts the whole batch.
mismatchPresent when the call made a different number of batches or history entries than the tool declares.
notesPresent when something about the session changed, such as a window that exited or a file that changed on disk.

A refusal is an error result carrying a code and a message that says what to do:

{"error":{"code":"notFound","message":"tableId nope names no live table; read the document for current ids"}}
codeWhy
notFoundAn id names nothing live, or the file does not exist.
invalidArgsAn argument is missing or has the wrong value.
invalidPathThe path is not an ERD document.
invalidDocumentThe file is not a document the editor can read.
tooLargeA read does not fit in one answer.
blockedA VS Code window with its hub off holds the document.
conflictThe file changed on disk during the call. Nothing was written.
hubAppeared, hubGoneA window started or stopped serving the document during the edit. Nothing was written.
notSavederd_save could not save the editor's document.
readonlyThe document is open read-only.
protocolMismatchThe extension and the server speak different protocol versions.
hubUnreachable, timeout, disconnectedA window's hub did not accept the connection, did not answer within 30 seconds, or hung up during the call.

Other codes are rarer, and every refusal carries a message saying what happened.

The edit tools, erd_batch, and the three read tools refuse an argument they do not declare, or one of the wrong type, with a JSON-RPC invalid params error (-32602) before touching the document, so a misspelled argument is never silently dropped. The five session tools ignore arguments they do not know.