npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-server-mysql-schema

v1.0.0

Published

MCP server for MySQL database schema introspection — tables, columns, foreign keys, indexes, relationships

Readme

mcp-server-mysql-schema

npm License Node CI GitHub stars

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 [email protected]: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