MCP Mermaid ER Server
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
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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dixitayush/mcp-api'
If you have feedback or need assistance with the MCP directory API, please join our Discord server