mcp-first
Documentation
MySQL Schema MCP Server
A Metadata Change Proposal (MCP) server for retrieving MySQL database schema information using the FastMCP framework.
Features
- Retrieve database list
- Retrieve table list from databases
- Get table schema (columns) information
- Get table indexes information
- Get table foreign key information
Setup
Local Setup with uv
1. Clone this repository
2. Install uv if you don't have it already:
pip install uv3. Create a virtual environment and install dependencies:
uv venv
uv pip install -r requirements.txt4. Create a `.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_schemaLocal Setup with pip
1. Clone this repository
2. Install dependencies:
pip install -r requirements.txt3. Create a `.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_schemaDocker Setup
Building and Running the Docker Image
1. Clone this repository
2. Build the Docker image:
docker build -t mysql-mcp-server .3. 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-serverNote: `host.docker.internal` is used to connect to the MySQL instance running on your host machine from inside the Docker container.
4. 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-serverUsage
Local Usage
Start the server:
python main.pyDocker Usage
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-serverYou can also create a `.env` file and mount it to the container:
docker run -p 8000:8000 \
-v $(pwd)/.env:/app/.env \
mysql-mcp-serverMCP JSON Configuration
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:
Local MCP Configuration
{
"mcpServers": {
"mysql-schema": {
"command": "python",
"args": [
"main.py"
],
"cwd": "/path/to/mcp-first",
"alwaysAllow": [
"databases",
"tables",
"schema",
"indexes",
"foreign_keys"
]
}
}
}Docker MCP Configuration
{
"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"
]
}
}
}Available Tools
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
Example
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")Frequently asked questions
What is mcp-first?
mcp-first is a Model Context Protocol (MCP) server listed in the TrackMCP directory.
How do I install mcp-first?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-first open source?
Yes — it is hosted on GitHub at https://github.com/Shion-Serizawa/mcp-first.
Related MCP tools
5. Update .env file in the root directory with your mem0 API key: for the Model Context Protocol. Enhance AI assistants with powerful integrations.
Model Context Protocol integration for Python. Enhance AI assistants with powerful Python-based capabilities and integration support.
This repository contains Model Context Protocol (MCP) servers that enable MCP clients (like Claude Desktop or the cline.
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.
基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择ChatGPT/Claude/DeepSeek/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP