MySQL Schema MCP Server

by shion-serizawa

Not rated
GitHub

About

A server for retrieving MySQL database schema information using the FastMCP framework.

Details

Author
shion-serizawa
Categories
Database, Other

Setup

Install MySQL Schema MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/shion-serizawa/mcp-first

Follow the installation instructions in the repository README, then restart your MCP client.

A server for retrieving MySQL database schema information using the FastMCP framework.

A Metadata Change Proposal (MCP) server for retrieving MySQL database schema information using theFastMCPframework.

- Retrieve database list
- Retrieve table list from databases
- Get table schema (columns) information
- Get table indexes information
- Get table foreign key information
- Clone this repository
- Install
uvif you don't have it already:

pip install uv
uv venv uv pip install -r requirements.txt
MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=information_schema

- Clone this repository
- Install dependencies:

pip install -r requirements.txt
MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=information_schema

Run the Docker container with environment variables for MySQL connection:

docker run -p 8000:8000 \ -e MYSQL_HOST=host.docker.internal \ -e MYSQL_PORT=3306 \ -e MYSQL_USER=your_username \ -e MYSQL_PASSWORD=your_password \ -e MYSQL_DATABASE=information_schema \ mysql-mcp-server

Note:host.docker.internalis used to connect to the MySQL instance running on your host machine from inside the Docker container.

For Mac and Windows,host.docker.internalresolves to the host machine. For Linux, you may need to use:

docker run -p 8000:8000 \ --add-host=host.docker.internal:host-gateway \ -e MYSQL_HOST=host.docker.internal \ -e MYSQL_USER=your_username \ -e MYSQL_PASSWORD=your_password \ mysql-mcp-server

Run the Docker container (as shown in the setup section):

docker run -p 8000:8000 \ -e MYSQL_HOST=host.docker.internal \ -e MYSQL_USER=your_username \ -e MYSQL_PASSWORD=your_password \ mysql-mcp-server

You can also create a.envfile and mount it to the container:

docker run -p 8000:8000 \ -v $(pwd)/.env:/app/.env \ mysql-mcp-server

To use this MCP server with MCP-compatible clients, you'll need to configure the client with the appropriate JSON configuration. Here are examples for both local and Docker setups:

{ "mcpServers": { "mysql-schema": { "command": "python", "args": [ "main.py" ], "cwd": "/path/to/mcp-first", "alwaysAllow": [ "databases", "tables", "schema", "indexes", "foreign_keys" ] } } }
{ "mcpServers": { "mysql-schema": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "MYSQL_HOST=host.docker.internal", "-e", "MYSQL_USER=your_username", "-e", "MYSQL_PASSWORD=your_password", "mysql-mcp-server" ], "alwaysAllow": [ "databases", "tables", "schema", "indexes", "foreign_keys" ] } } }

The server provides the following tools:

- databases: List all databases
- tables: List all tables in a database
- schema: Get the schema (columns, indexes, and foreign keys) for one or more tables.
- indexes: Get the indexes for a specific table
- foreign_keys: Get the foreign keys for a specific table

from fastmcp.client import Client # Connect to the MCP server client = Client("http://localhost:8000") # List all databases databases = client.databases() # List tables in a specific database tables = client.tables(database="your_database") # Get schema for a specific table schema = client.schema(tables=["your_table"], database="your_database") # Get schema for multiple tables schemas = client.schema(tables=["table1", "table2"], database="your_database") # Get indexes for a specific table indexes = client.indexes(table="your_table", database="your_database") # Get foreign keys for a specific table foreign_keys = client.foreign_keys(table="your_table", database="your_database")

Multi-database agent access (PostgreSQL, SQLite, MySQL, Oracle, SQL Server) with batch queries, pre-configured connections, and SQLGlot-enforced read-only safety

A read-only MCP server for MySQL, enabling LLMs to query live data using the CData JDBC Driver.

Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite

A single-binary MCP server for MySQL, MariaDB, PostgreSQL, and SQLite

A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.

Allows Claude AI to interact directly with MySQL databases.

Update various databases (PostgreSQL, MySQL, MongoDB, SQLite) using data from CSV and Excel files.

Enables AI assistants to interact with various databases through JDBC connections.

An MCP server for retrieving data from a MariaDB database.

Access and manage MariaDB or MySQL databases using an MCP server.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.