add_relationship
Add a relationship (foreign key) between two tables with optional cardinality and constraint rules
Edit the database diagram open in your browser from your coding assistant — add tables, wire foreign keys, validate, export DDL.
LABSCO SUMMARY
Because it drives the drawdb tab you already have open, you watch the schema take shape instead of reading a text description of it — and get_issues plus export_sql mean the same session ends with validated DDL. The browser tab is the server's other half; nothing happens while drawdb is closed.
A bridge between your assistant and a drawdb diagram open in the browser. The command starts a local WebSocket relay, drawdb finds it, and the diagram becomes readable and writable.
Node.js 18 or newer and npx. drawdb has to be open in your browser — it scans for the relay on startup and shows a green MCP dot in its header once it has found one.
One command — npx mcp-drawdb
USE CASES
Tables and foreign keys appear on the canvas as you talk through the model, laid out where you want them.
Rename a table, alter a field's properties, drop a relationship — without hunting for the control in the UI.
Validation flags duplicate names, missing primary keys and type mismatches while the diagram is still cheap to change.
Set the target engine, then export DDL with constraints and foreign keys already correct for that dialect.
The full diagram including layout, so the assistant works from the current state rather than from what it drew earlier.
One call tells you whether the browser session is connected, before a change silently goes nowhere.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
add_relationshipAdd a relationship (foreign key) between two tables with optional cardinality and constraint rules
add_tableAdd a new table to the diagram
clear_diagramClear all tables and relationships from the diagram. Use with caution.
delete_relationshipDelete a relationship between two tables
delete_tableDelete a table from the diagram. Cascades to remove all relationships involving this table.
export_sqlGenerate DDL SQL for the target database. Returns CREATE TABLE statements with columns, constraints, and foreign keys. Note: requires database to be set to a specific type (not 'generic').
get_diagramGet full overview of the diagram: tables with fields, layout (x/y/width/height), relationships, database type
get_issuesGet validation issues/problems in the current diagram. Checks for: duplicate names, missing primary keys, empty fields, type mismatches, circular dependencies, and more. Call this after making changes to verify the diagram is valid.
list_tablesList all tables in the current drawdb diagram
pingTest connection to the drawdb browser session
set_databaseSet the target database type. This affects available field types, SQL generation, and validation. Options: mysql, postgresql, sqlite, mariadb, transactsql, oraclesql, generic.
set_layoutSet positions of tables on the canvas. Pass an array of {table_name, x, y} to reposition tables. For duplicate table names, pass entries in order.
undoView the last action on the undo stack. Returns a description of what would be undone. Note: full undo requires UI interaction.
update_tableUpdate a table: rename, change comment/color, add/drop/alter fields with full property control (unique, unsigned, check, increment, etc.)
BEFORE YOU INSTALL
14 tools when we connected.
CONTEXT COST
Rated by the size of the 14 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
Add the block to your client, or run the command directly.
{
"mcpServers": {
"mcp-drawdb": {
"command": "npx",
"args": [
"mcp-drawdb"
]
}
}
}npx mcp-drawdb