M
MCP Sql Server
作者 @atarkowska
MCP server by atarkowska
创建于 12/7/2025
更新于 9 days ago
README
Repository documentation and setup instructions
MCP SQL Server
A Model Context Protocol (MCP) server implementation for PostgreSQL databases, providing AI assistants with secure and structured access to PostgreSQL databases.
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Features
- Database Introspection: List tables and explore database schemas
- Table Schema Discovery: Get detailed information about tables including columns, types, constraints, primary keys, and foreign keys
- Safe Query Execution: Execute read-only SELECT queries with built-in safety checks
- Full Query Support: Execute INSERT, UPDATE, DELETE, and SELECT queries with parameterized query support
- Type Safety: Built with Pydantic models for robust input validation
- Comprehensive Logging: Detailed logging for debugging and monitoring
Tools Available
list_tables- Lists all tables in a specified database schema.get_table_schema- Retrieves detailed schema information for a specific table.execute_safe_query- Executes read-only SELECT queries safely.execute_query- Executes any SQL query (SELECT, INSERT, UPDATE, DELETE) with optional parameterization.
Configuration with MCP Clients
Add the server to your MCP client configuration (e.g., Claude Desktop):
Testing
See tests/README_TESTING.md for detailed testing information.
Security Considerations
- Environment Variables: Store database credentials in
.envfiles or environment variables, never in code - Read-Only Access: Consider using
execute_safe_queryfor untrusted queries - Database Permissions: Use database users with minimal necessary permissions
- Parameterized Queries: Always use the
paramsargument for user-supplied values to prevent SQL injection - Network Security: Restrict database access to trusted networks
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.
Support
For issues, questions, or contributions, please visit the GitHub repository.
Related Projects
快速设置
此服务器的安装指南
安装包 (如果需要)
uvx mcp-sql-server
Cursor 配置 (mcp.json)
{
"mcpServers": {
"atarkowska-mcp-sql-server": {
"command": "uvx",
"args": [
"mcp-sql-server"
]
}
}
}