# Schemity MCP Server A local database MCP server built into [Schemity](https://schemity.com), database design software for software engineers. Your AI agent reads the schema of your live PostgreSQL, MySQL, MariaDB, SQL Server, or SQLite database, sees what a migration would do before it runs, and stages diagram edits you review. The agent never gets database credentials, and nothing it does writes to a database. > The server ships inside the Schemity desktop app, which is closed source. This repository holds its documentation, the tool list it exposes ([`tools.json`](tools.json)), and ready-to-paste host configs ([`examples/`](examples)). Bug reports and feature requests go to [schemity-feedback](https://github.com/tbson/schemity-feedback/issues). ## Why a governed path Most database MCP servers hand the agent a connection string and run whatever SQL it writes. Schemity works the other way round: the agent works through the diagram you have open, which Schemity read from your database. - **Reads never change anything.** - **Edits are staged** in the open diagram as unsaved changes, recorded in undo history under the agent's name, for you to review and undo before you save. - **Nothing touches a database** until you run the migration yourself. - **No vendor cloud in the middle.** The HTTP server listens on `127.0.0.1` only and requires a bearer token kept in your OS keychain; stdio hosts talk to the app over a local socket. Your schema goes only where your agent host already sends your code, and with a local model it stays on your machine. ## Tools - **list_diagrams** - List the diagrams open in Schemity; call it first. Read-only. - **get_schema** - Entities, fields, relations, and legends of a diagram or one context view. Read-only. - **get_context_views** - Context views, the dependencies between them, and cycles. Read-only. - **get_dependencies** - Relations into and out of one entity, with the columns on both sides. Read-only. - **get_data_dictionary** - The documented schema as Markdown, descriptions included. Read-only. - **get_pending_changes** - The diagram's unsaved edits, as the undo history that produced them. Read-only. - **analyze_impact** - What the pending migration would cost: lost data, statements that fail on existing rows, table rewrites, locks on large tables, dependent views and functions. Read-only. - **analyze_migration_file** - The same analysis for a migration file, hand-written or generated by Prisma, Alembic, or Flyway, without running it. Read-only. - **lint** - Schema findings: conventions, missing indexes, type mismatches. Read-only. - **check_relation_lines** - Relation lines that overlap or cross. Read-only. - **count_rows** - An exact count behind a finding, run as a read-only query when you ask for it. - **open_schemity** - Start Schemity, or bring it to the front. - **show_preview** - Draw a proposed change in Schemity for you to look at; nothing is saved. - **propose_changes** - Create, change, and delete entities, fields, relations, legends, and context views. Staged as unsaved edits you review. - **group_entities** - Group entities into legends. Staged as unsaved edits you review. - **route_relations** - Route relation lines around the tables so they cross less. Staged as unsaved edits you review. 16 tools, as of Schemity 2.11.2. Read-only tools never change anything; staged edits land in the open diagram's undo history under the agent's name. Full input schemas are in [`tools.json`](tools.json). ## Databases PostgreSQL, Supabase, MySQL, MariaDB, SQL Server, and SQLite, directly or through an SSH tunnel. ## Setup 1. [Install Schemity](https://schemity.com/#pricing) on macOS, Windows, or Linux. 2. Open the diagram you want the agent to see. The server sees diagrams open in the Schemity window, not files on disk. 3. Open the **MCP** panel from the plug icon in the control bar, or with `Cmd+Shift+A` (macOS) / `Ctrl+Shift+A` (Windows, Linux). It shows the server status, a connection test, and a snippet for each host with the right path for your platform. The examples below use the macOS path. On Windows and Linux, copy the snippet from the MCP panel instead. ### stdio: Claude Code, Claude Desktop, Codex, OpenCode The host starts the Schemity binary with `--mcp`, so it can also launch Schemity when the app is closed. **Claude Code** ```bash claude mcp add --scope user schemity -- "/Applications/Schemity.app/Contents/MacOS/schemity" --mcp ``` **Claude Desktop** - `claude_desktop_config.json`, then restart Claude Desktop ```json { "mcpServers": { "schemity": { "command": "/Applications/Schemity.app/Contents/MacOS/schemity", "args": ["--mcp"] } } } ``` **Codex** - `~/.codex/config.toml` ```toml [mcp_servers.schemity] command = "/Applications/Schemity.app/Contents/MacOS/schemity" args = ["--mcp"] ``` **OpenCode** - `opencode.json` ```json { "mcp": { "schemity": { "type": "local", "command": ["/Applications/Schemity.app/Contents/MacOS/schemity", "--mcp"] } } } ``` ### Streamable HTTP: Cursor and other HTTP clients Keep Schemity open; an HTTP host cannot start it. The port defaults to 7332 and can be changed in the panel. **Cursor** - `~/.cursor/mcp.json` ```json { "mcpServers": { "schemity": { "url": "http://127.0.0.1:7332/mcp", "headers": { "Authorization": "Bearer " } } } } ``` ## Troubleshooting - **"Schemity is not running"** - only a stdio host can start the app. On an HTTP host such as Cursor, open Schemity yourself and retry. - **401 Unauthorized** - the token was regenerated in the panel; copy the current one into the host's config. - **Port in use** - pick another port in the panel and click Restart. - **A tool says a diagram is "not open"** - open that diagram in the Schemity window. ## Requirements and pricing The MCP server is a desktop feature. It runs during the 2-week free trial (every feature unlocked, no credit card) and with a license, a one-time purchase of $129. It is not part of Schemity Lite, the free browser version. ## Links - Documentation: [AI Agents via MCP](https://schemity.com/doc/ai-assisted-design/) - Impact analysis: [what a migration costs before it runs](https://schemity.com/doc/impact-analysis/) - Website: [schemity.com](https://schemity.com)