MCP Mermaid ER Server
Generates type-safe GraphQL queries and mutations for all entities.
Parses Mermaid ER diagrams to extract entities, attributes, and relationships for database schema generation.
Automatically creates PostgreSQL tables from ER diagrams and generates CRUD APIs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Mermaid ER Server Parse my ER diagram and create the tables"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Mermaid ER Server
An open-source Model Context Protocol (MCP) server that parses Mermaid ER diagrams, creates PostgreSQL database tables, and exposes automatic REST/GraphQL CRUD APIs.
Features
π Parse Mermaid ER Diagrams - Extract entities, attributes, and relationships
ποΈ Auto-Create PostgreSQL Tables - Generate DDL and execute against your database
π REST API Generation - Automatic CRUD endpoints for all entities
π GraphQL API Generation - Type-safe queries and mutations
π Key Detection - Identifies PK, FK, and UK constraints
βοΈ Configurable - Environment variables for database and API settings
Related MCP server: mcp-db-server
Installation
git clone https://github.com/yourusername/mcp-mermaid-er-server.git
cd mcp-mermaid-er-server
npm install
npm run buildConfiguration
Create a .env file (copy from .env.example):
# Mermaid Source
MERMAID_DIAGRAM_PATH=./examples/sample-er.mmd
# Database (PostgreSQL)
DB_HOST=localhost
DB_PORT=5432
DB_NAME=mydb
DB_USER=postgres
DB_PASSWORD=password
# API Server
API_TYPE=rest # rest, graphql, or both
API_PORT=3000
API_HOST=0.0.0.0Claude Desktop Integration
Add to claude_desktop_config.json:
{
"mcpServers": {
"mermaid-er": {
"command": "node",
"args": ["/path/to/mcp-tools/dist/index.js"],
"env": {
"MERMAID_DIAGRAM_PATH": "/path/to/your/diagram.mmd",
"DB_HOST": "localhost",
"DB_NAME": "mydb",
"DB_USER": "postgres",
"DB_PASSWORD": "password"
}
}
}
}Available MCP Tools (12 Total)
Parsing Tools
Tool | Description |
| Parse ER diagram, return full schema |
| List all entity names |
| Get attributes for an entity |
| Get all relationships |
| Validate diagram syntax |
Database Tools
Tool | Description |
| Test PostgreSQL connection |
| Generate DDL without executing |
| Create tables in database |
| Drop all tables (requires confirmation) |
API Tools
Tool | Description |
| Start REST/GraphQL server |
| Stop the API server |
| List all endpoints |
Workflow Example
Parse your ER diagram β
parse_er_diagramReview the SQL β
generate_sqlCreate database tables β
create_schemaStart the API server β
start_api_serverUse the auto-generated endpoints!
API Endpoints
REST (when API_TYPE=rest or both)
GET /api/{entity} - List all records
GET /api/{entity}/:id - Get by ID
POST /api/{entity} - Create record
PUT /api/{entity}/:id - Update record
DELETE /api/{entity}/:id - Delete recordGraphQL (when API_TYPE=graphql or both)
# Queries
query { customers { customer_id email } }
query { customer(id: "1") { email } }
# Mutations
mutation { createCustomer(input: { email: "test@example.com" }) { customer_id } }
mutation { updateCustomer(id: "1", input: { email: "new@example.com" }) { email } }
mutation { deleteCustomer(id: "1") { customer_id } }Supported ER Syntax
erDiagram
CUSTOMER {
int customer_id PK "Primary key"
string email UK "Unique email"
string name
}
ORDER {
int order_id PK
int customer_id FK
datetime order_date
}
CUSTOMER ||--o{ ORDER : "places"Development
npm run dev # Run with ts-node
npm run build # Compile TypeScript
npm test # Run testsLicense
MIT License - see LICENSE
Available Tools
12 toolscreate_schemaA
Create PostgreSQL tables from the ER diagram. This will execute DDL statements to create tables and foreign key constraints.
Inputs: diagram, dropExisting.
drop_schemaA
Drop all tables defined in the ER diagram. WARNING: This will delete all data!
Inputs: confirm (required), diagram.
generate_sqlA
Generate SQL DDL statements from the ER diagram without executing them. Useful for reviewing the SQL before creating tables.
Inputs: diagram.
get_api_endpointsB
Get information about the running API server and its endpoints.
Inputs: no named parameters.
get_entity_detailsA
Get detailed information about a specific entity including all its attributes, types, and keys (PK, FK, UK).
Inputs: entityName (required), diagram.
get_relationshipsB
Get all relationships between entities in the ER diagram with cardinality information.
Inputs: diagram, entityName.
list_entitiesC
List all entities (tables) in the ER diagram with their names and aliases.
Inputs: diagram.
parse_er_diagramB
Parse a Mermaid ER diagram and extract the complete database schema including entities, attributes, and relationships.
Inputs: diagram.
start_api_serverA
Start the REST/GraphQL API server for the entities in the ER diagram.
Inputs: diagram.
stop_api_serverB
Stop the running API server.
Inputs: no named parameters.
test_connectionA
Test the PostgreSQL database connection. Returns success or error message.
Inputs: no named parameters.
validate_diagramB
Validate a Mermaid ER diagram for syntax errors and structural issues.
Inputs: diagram (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 12 tools
Each tool targets a distinct action or resource: read operations are separated into entities, relationships, and diagram parsing, while generate_sql is clearly distinct from create_schema since one only outputs DDL and the other executes it. The API server lifecycle is also cleanly split into start, stop, and endpoint inspection. No two tools appear likely to be confused.
All tool names follow a consistent lower_snake_case verb_noun convention. The verbs clearly indicate the action being taken, such as list, get, validate, generate, create, drop, start, and stop. The minor use of both list and get for read operations is not a meaningful inconsistency.
With 12 tools, the server is well-scoped for its combined purpose of parsing Mermaid ER diagrams, managing PostgreSQL schema, and controlling an API server. Each tool supports a distinct part of the workflow without unnecessary duplication. The count fits comfortably within the ideal range.
The core lifecycle is well covered: parse and validate the diagram, inspect entities and relationships, generate and execute SQL, drop the schema, and start/stop the API server. Minor gaps exist, such as no tool for incremental schema updates or altering existing tables, but these are not essential to the stated purpose. Overall, the surface is complete enough for the primary workflow.
Maintenance
Related MCP Connectors
ER diagrams from SQL, Prisma or ORM models. One tool, no account, nothing stored.
Generate dynamic Mermaid diagrams and charts with AI assistance. Customize styles and export diagrβ¦
Query PostgreSQL databases in plain English β LLM-generated, safety-validated SQL.
Generate, edit, and export data-architecture diagrams from your AI. Column lineage, PNG in chat.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI to query and manage PostgreSQL and MongoDB databases through natural language. Supports automatic schema discovery, safe data operations, and network-wide database access with zero-configuration deployment.-
- FlicenseNot gradedqualityDmaintenanceEnables querying PostgreSQL and MySQL databases using natural language, with RESTful endpoints for listing tables, describing schemas, and executing read-only queries.1-
- FlicenseNot gradedqualityDmaintenanceActs as a secure bridge connecting PostgreSQL databases to AI models, enabling natural language querying, schema analysis, and controlled write operations with multi-layer security.-
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of PostgreSQL databases with intelligent SQL generation using LLMs.1Apache 2.0