# DrawSQL MCP server

Connect your AI editor to DrawSQL over streamable HTTP. Send SQL DDL or a DrawSQL schema patch and get back an editable ER diagram. The server is hosted and anonymous. Diagrams open without an account.

## Connect your editor

### Claude Code

Run this once to make DrawSQL available in every project:

```bash
claude mcp add --transport http --scope user drawsql https://drawsql.app/mcp
```

To limit DrawSQL to the current project, omit `--scope user`.

### Codex

```bash
codex mcp add drawsql --url https://drawsql.app/mcp
```

### Cursor

Add to `.cursor/mcp.json` in your project, or `~/.cursor/mcp.json` for all projects:

```json
{
  "mcpServers": {
    "drawsql": {
      "url": "https://drawsql.app/mcp"
    }
  }
}
```

### Windsurf

Add to `~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "drawsql": {
      "serverUrl": "https://drawsql.app/mcp"
    }
  }
}
```

### VS Code

Add to `.vscode/mcp.json` in your workspace:

```json
{
  "servers": {
    "drawsql": {
      "type": "http",
      "url": "https://drawsql.app/mcp"
    }
  }
}
```

Once connected, ask your agent for a diagram. "Visualize this schema in DrawSQL" or "Diagram the tables in `schema.sql`" is enough. The agent will choose the tool when it needs it.

## What it does

The server exposes a single tool: `visualize_schema`. Pass either SQL DDL or a DrawSQL schema patch. The tool returns a `drawsql.app/draw` link and a summary containing the driver, table count, column count, and relationship count.

The link opens a full DrawSQL canvas with the tables arranged and foreign keys connected. Anyone with the link can edit, rearrange, or export the diagram without an account.

Links that are never opened expire after 30 days. Opening a link extends its expiry for one year, and each later view renews that period. Save the diagram to an account to keep a permanent copy.

Use the tool whenever your agent can see a schema, whether it lives in a migration folder, a dump file, or the current conversation.

## Tool reference

`visualize_schema` takes exactly one of `ddl` or `schema`.

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `ddl` | string | Yes, unless `schema` is set | SQL `CREATE TABLE` and `ALTER TABLE` statements. Up to 200 KB. |
| `schema` | string | Yes, unless `ddl` is set | A DrawSQL schema patch as a JSON string. Supports tables, columns, indexes, relationships, groups, and sticky notes. See the format in [llms-full.txt](/llms-full.txt). Up to 500 KB. |
| `driver` | string | No | SQL dialect: `mysql`, `pgsql`, or `sqlsrv`. Defaults to `mysql`. |

An invalid patch returns every problem in one response, each naming the field and the valid values, so the client can fix the whole patch in a single retry. The tool is limited to 10 calls per minute per IP address. The `x-ratelimit-*` response headers track a separate, looser limit on the HTTP transport (all requests, including handshakes); the tool limit is enforced inside the tool and reported in its error message.

Every call creates a new diagram, so patch fields that describe changes to an existing one are rejected: omit `deletions`, and omit `schema_version` unless you have a reason to pin it.

Identifiers are matched exactly, and the tool rejects a patch rather than repairing it: no leading or trailing whitespace and no control characters in names, uuids, or references; table and group names unique; uuids non-empty and unique across the whole patch; and entries that repeat a uuid (to split a large table across entries) must repeat its name. The error names the exact field, so a retry is one edit away.

## FAQ

### Do I need a DrawSQL account or an API key?

No. The server is anonymous, and returned links open the full editor without signup. Save the diagram to an account if you want a permanent copy or need to share it with your team.

### What happens to the schema I send?

DrawSQL stores the submitted DDL or schema patch so the returned link can load it. An unopened link and its data expire after 30 days. Opening the link extends that period for one year, and each later view renews it.

A success response includes only the driver and parsed counts, never your table or column names. Validation errors quote the specific invalid value they reject, so the client can fix it.

### What are the limits?

DDL input is limited to 200 KB and schema patches to 500 KB. Either input may describe more than 20 tables; the returned diagram opens with the first 20, and the response says so.

The tool accepts 10 calls per minute per IP address. The HTTP transport allows 20 requests per minute, which also covers handshake and discovery calls; the `x-ratelimit-*` headers describe that transport limit, not the tool limit.

### Which databases are supported?

MySQL, PostgreSQL, and SQL Server. Pass `driver` to choose one. The default is MySQL.

### Which editors and agents work with it?

Any MCP client that supports streamable HTTP can connect. The examples above cover Claude Code, Codex, Cursor, Windsurf, and VS Code. There is no local binary to install.

### Can my agent read or edit my existing DrawSQL diagrams?

No. This first version only creates new diagrams from the schema you provide. Use the [REST API](/developers/api) to read existing DrawSQL diagrams. Authenticated MCP tools for workspace diagrams are planned.
