Skip to main content
Glama
dixitayush
by dixitayush

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.

MCP TypeScript License

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: PostgreSQL MCP Server

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

  1. Parse your ER diagram β†’ parse_er_diagram

  2. Review the SQL β†’ generate_sql

  3. Create database tables β†’ create_schema

  4. Start the API server β†’ start_api_server

  5. 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

A
license - permissive license
-
quality - not tested
D
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    D
    maintenance
    Enables 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.
  • A
    license
    -
    quality
    D
    maintenance
    Enables natural language interaction with PostgreSQL databases, supporting query execution, schema management, data operations, user management, and database maintenance with secure remote access via HTTP/SSE transport.
    MIT
  • F
    license
    -
    quality
    D
    maintenance
    Enables querying PostgreSQL and MySQL databases using natural language, with RESTful endpoints for listing tables, describing schemas, and executing read-only queries.
    1
  • F
    license
    -
    quality
    D
    maintenance
    Acts as a secure bridge connecting PostgreSQL databases to AI models, enabling natural language querying, schema analysis, and controlled write operations with multi-layer security.

View all related MCP servers

Related MCP Connectors

  • 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.

  • Let Claude, Cursor, or ChatGPT author Mermaid diagrams your team can read and share.

View all MCP Connectors

Latest Blog Posts

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