mcp-server-mysql-schema

mcp-server-mysql-schema

Enables AI assistants to explore MySQL database schema — tables, columns, foreign keys, indexes, and relationships — through structured tools and resources, without any write access.

Category
Visit Server

README

mcp-server-mysql-schema

npm License Node CI GitHub stars

<div align="center"> <img src="demo.gif" width="720" alt="MySQL Schema MCP Server Demo"> <br> <em>Explore tables, columns, FKs, indexes via MCP</em> </div>

MySQL Schema MCP Server — explore tables, columns, foreign keys, indexes, and relationships through the Model Context Protocol. Works with opencode, Claude Desktop, Cursor, and any MCP-compatible AI client.

No more writing SHOW TABLES and DESCRIBE manually. Ask your AI assistant "what tables are in this database?", "show me the foreign keys of the orders table", or "find all columns named 'status'" — and get structured JSON responses.


Quick Start

# Install
npx mcp-server-mysql-schema

# Or clone
git clone git@github.com:rendi-febrian/mcp-server-mysql-schema.git
cd mcp-server-mysql-schema
npm install && npm run build

opencode Configuration

{
  "mcp": {
    "mysql-schema": {
      "type": "local",
      "command": ["node", "/path/to/mcp-server-mysql-schema/dist/index.js"],
      "environment": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "your-password"
      },
      "enabled": true
    }
  }
}

Claude Desktop / Cursor / Other MCP Clients

{
  "mcpServers": {
    "mysql-schema": {
      "command": "node",
      "args": ["/path/to/mcp-server-mysql-schema/dist/index.js"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "your-password"
      }
    }
  }
}

Features

Tools

Tool Description Example
schema_databases List all non-system databases with charset schema_databases()
schema_tables All tables — engine, row count, auto-increment, comments schema_tables(database: "myapp")
schema_views All views in a database schema_views(database: "myapp")
schema_table_detail Columns: type, nullable, default, key, extra, comment schema_table_detail(database: "myapp", table: "users")
schema_foreign_keys FK relationships — all DB, per-table, incoming/outgoing schema_foreign_keys(database: "myapp", table: "orders")
schema_indexes Indexes: name, columns, seq, unique, type, comment schema_indexes(database: "myapp", table: "users")
schema_relationships Full PK/FK map across all tables schema_relationships(database: "myapp")
schema_search Search table and column names by keyword schema_search(database: "myapp", keyword: "user")

Resources

URI Content
schema://{db}/tables All tables in the database
schema://{db}/relationships Full relationship map
schema://{db}/{table}/columns Column details
schema://{db}/{table}/indexes Index details
schema://{db}/{table}/foreign-keys Foreign key details

Security

100% read-only. Every query targets information_schema only. No SELECT on user tables. No INSERT, UPDATE, DELETE, or DDL. The server cannot modify any data.

Why Not Just Use MySQL MCP?

MySQL MCP Schema MCP (this)
Purpose Run arbitrary SQL Introspect database structure
Query target Any table / any query information_schema only
Write access Optional (configurable) Never
Structured tools Single mysql_query tool 8 focused tools
Resources Table-level Table + FK + relationship maps
Best for Data CRUD, ad-hoc queries Schema discovery, ERD, migrations

Requirements

  • Node.js >= 18
  • MySQL 5.7+ or MariaDB 10.2+
  • MySQL user with SELECT on information_schema (default)

Environment Variables

Variable Required Default Description
MYSQL_HOST No 127.0.0.1 MySQL host
MYSQL_PORT No 3306 MySQL port
MYSQL_USER No root MySQL user
MYSQL_PASS No "" MySQL password
MYSQL_DEFAULT_DB No — Default database for resource URIs

Architecture

src/
├── index.ts              # MCP server entry point (raw Server)
├── db.ts                 # MySQL connection pool
├── schema.ts             # information_schema queries
├── tools/
│   ├── tables.ts         # schema_databases, schema_tables, schema_views
│   ├── detail.ts         # schema_table_detail
│   ├── foreignKeys.ts    # schema_foreign_keys
│   ├── indexes.ts        # schema_indexes
│   ├── relationships.ts  # schema_relationships
│   └── search.ts         # schema_search
└── resources/
    └── index.ts          # schema:// URIs

No ORM, no migrations, no configuration files — just raw information_schema queries over mysql2.

Contributing

See CONTRIBUTING.md.

License

MIT

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured