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 the FastMCP framework.
pip install uv
uv venv
uv pip install -r requirements.txt
.env
file based on .env.example
with your MySQL connection details:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=information_schema
pip install -r requirements.txt
.env
file based on .env.example
with your MySQL connection details:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=information_schema
Clone this repository
Build the Docker image:
docker build -t mysql-mcp-server .
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.internal
is used to connect to the MySQL instance running on your host machine from inside the Docker container.
For Mac and Windows, host.docker.internal
resolves 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
Start the server:
python main.py
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 .env
file 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 databasestables
: List all tables in a databaseschema
: Get the schema (columns) for a specific tableindexes
: Get the indexes for a specific tableforeign_keys
: Get the foreign keys for a specific tablefrom 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(table="your_table", 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")
Provides AI assistants with a secure and structured way to explore and analyze data in GreptimeDB.
Stock market API made for AI agents
Interact with Verodat AI Ready Data platform
a lightweight, local RAG memory store to record, retrieve, update, delete, and visualize persistent "memories" across sessions—perfect for developers working with multiple AI coders (like Windsurf, Cursor, or Copilot) or anyone who wants their AI to actually remember them.
Open source MCP server specializing in easy, fast, and secure tools for Databases.
Access the OpenGenes database for aging and longevity research, with automatic updates from Hugging Face Hub.
Interact with the data stored in Couchbase clusters using natural language.
Connect to a Hologres instance, get table metadata, query and analyze data.
An MCP server for Firebird SQL databases, enabling LLMs to securely access, analyze, and manipulate database content.
Introspect and query your apps deployed to Convex.