MCP Mermaid ER Server
Parses Mermaid ER diagrams to create PostgreSQL tables and automatically generates REST and GraphQL CRUD APIs.
README
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 build
Configuration
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.0
Claude 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 |
Parse ER diagram, return full schema |
list_entities |
List all entity names |
get_entity_details |
Get attributes for an entity |
get_relationships |
Get all relationships |
validate_diagram |
Validate diagram syntax |
Database Tools
| Tool | Description |
|---|---|
test_connection |
Test PostgreSQL connection |
generate_sql |
Generate DDL without executing |
create_schema |
Create tables in database |
drop_schema |
Drop all tables (requires confirmation) |
API Tools
| Tool | Description |
|---|---|
start_api_server |
Start REST/GraphQL server |
stop_api_server |
Stop the API server |
get_api_endpoints |
List all endpoints |
Workflow Example
- Parse your ER diagram →
parse_er_diagram - Review the SQL →
generate_sql - Create database tables →
create_schema - Start the API server →
start_api_server - Use 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 record
GraphQL (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 tests
License
MIT License - see LICENSE
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.