MCP MySQL Server
Enables interaction with MySQL databases through MCP, supporting query execution, table operations (insert, update, delete), and schema inspection for natural language database management.
README
MCP MySQL Server
This is a Node.js-based MCP (Managed Connector Platform) server for MySQL, exposing functionalities to interact with a MySQL database.
Features
- query: Executes a SQL query with optional parameters.
- describe_table: Describes the schema of a specified table.
- list_tables: Lists all tables in the connected database.
- update: Performs update operations on a table.
- insert: Inserts a single record into a table.
- delete: Deletes records from a table based on a condition (implemented by
deleteSingleinternally).
Setup and Configuration
Prerequisites
- Node.js (LTS version recommended)
- npm (Node Package Manager)
- MySQL Server running and accessible
- Express.js (included as a dependency)
Installation
-
Clone the repository (or create the project structure manually):
git clone <repository-url> cd mcp-mysqlIf you are setting this up manually, ensure you have
package.jsonandindex.jsas provided. -
Install dependencies:
Navigate to the project directory and run:
npm install
Configuration
-
Create a
.envfile:In the root directory of the project, create a file named
.env. -
Add database credentials to
.env:Populate the
.envfile with your MySQL database connection details:DB_HOST=localhost DB_PORT=3306 DB_USER=root DB_PASSWORD=password DB_DATABASE=mysql_dbNote: Replace
localhost,3306,root,password,mysql_db, andyour_mysql_portwith your actual database host, port, username, password, database name, and desired server port respectively.
MCP JSON Configuration for IDEs (e.g., Cursor AI, VS Code)
To allow IDEs to automatically discover and interact with your MCP MySQL server, you can add the following JSON configuration to your IDE's .cursor/mcp.json file.
{
"mcpServers": {
"mcp_mysql_dheer": {
"command": "node",
"args": ["index.js"],
"env": {
"DB_HOST": "your_db_host",
"DB_PORT": "your_db_port",
"DB_USER": "your_db_user",
"DB_PASSWORD": "your_db_pwd",
"DB_DATABASE": "your_db"
}
}
}
}
Docker Usage
This MCP server runs as a stdio application. Below are the instructions to build a Docker image and run the server within a container.
-
Build the Docker Image:
Navigate to the project directory containing the
Dockerfileandpackage.json, then run:docker build -t mcp_mysql_dheer . -
Run the Docker Container (as a stdio server):
When running the Docker container, you'll need to provide the MySQL database credentials as environment variables.
docker run -i mcp_mysql_dheer node index.js \ -e DB_HOST=your_mysql_host \ -e DB_USER=your_mysql_user \ -e DB_PASSWORD=your_mysql_password \ -e DB_DATABASE=your_mysql_database \ -e DB_PORT=your_mysql_portNote:
-iflag is crucial forSTDINto remain open, allowing the MCP client to communicate with the server.- Replace
your_mysql_host,your_mysql_user,your_mysql_password,your_mysql_database, andyour_mysql_portwith your actual database connection details.
Usage (Example with a hypothetical MCP Client)
This server is designed to be consumed by an MCP client. Here's a conceptual example of how an MCP client might interact with these functionalities:
const client = new MCPClient({
server: {
command: 'docker',
args: [
'run',
'-i',
'--rm',
'mcp_mysql_dheer',
'node',
'index.js',
'-e', 'DB_HOST=your_mysql_host',
'-e', 'DB_USER=your_mysql_user',
'-e', 'DB_PASSWORD=your_mysql_password',
'-e', 'DB_DATABASE=your_mysql_database',
'-e', 'DB_PORT=your_mysql_port'
],
},
});
async function exampleUsage() {
// Example: List tables
const tables = await client.callTool('list_tables', {});
console.log('Tables:', tables);
// Example: Query data
const users = await client.callTool('query', { sql: 'SELECT * FROM users' });
console.log('Users:', users);
}
exampleUsage();
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。