SQL MCP Server
Dynamic MCP service for MySQL and PostgreSQL, allowing runtime database connections and SQL queries via tools.
README
SQL MCP
一个支持 MySQL 和 PostgreSQL 的动态 SQL MCP 服务。所有数据库连接在运行时通过 tool 参数传入,无需配置文件。
特性
- 支持 MySQL 和 PostgreSQL
- SSE/HTTP transport,适合 Docker 远程部署
- 运行时动态传入数据库连接
- 可选 alias 注册机制,便于复用连接
- 提供
list_db_servers、list_database_tables、get_table_schema、query_database工具
快速开始
本地运行
pip install -r requirements.txt
python -m src.server --transport sse --port 3000
Docker 运行
docker build -t sql-mcp .
docker run -p 3000:3000 sql-mcp
MCP Tools
register_database
注册一个数据库连接别名。
{
"alias": "prod-mysql",
"connection": {
"type": "mysql",
"host": "localhost",
"port": 3306,
"user": "root",
"password": "secret",
"database": "mydb"
}
}
list_db_servers
列出已注册的数据库连接(不返回密码)。
list_database_tables
列出数据库表。支持 alias 或完整 connection 对象。
{
"alias": "prod-mysql"
}
get_table_schema
获取表结构。
{
"alias": "prod-mysql",
"table_name": "users"
}
query_database
执行 SQL 查询。默认只读,可通过 allow_write: true 允许写入操作。
{
"alias": "prod-mysql",
"sql": "SELECT * FROM users LIMIT 10"
}
安全提示
当前版本通过 tool 参数明文传入数据库凭据,适用于受控内网或开发环境。生产环境建议:
- 启用 SSE TLS
- 服务端通过环境变量加载凭据模板,tool 参数只传 alias
- 限制可访问的源 IP
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.