mcp-sql
MySQL MCP server
claude mcp add --transport stdio ineersa-mcp-sql-server php bin/console mcp:server --port 8000 \ --env APP_ENV="prod" \ --env APP_DEBUG="false" \ --env LOG_LEVEL="warning" \ --env APP_LOG_DIR="/tmp/database-mcp/log" \ --env DATABASE_CONFIG_FILE="Path to your YAML database configuration file"
How to use
This MCP server provides read-only access to SQL databases across MySQL, MariaDB, PostgreSQL, SQLite, and SQL Server. It exposes two main tools you can invoke via the MCP client: query and schema. The query tool executes read-only SQL statements against a selected database connection and returns results encoded as TOON text payloads. The schema tool retrieves metadata about the database schema, including tables, columns, and other objects; use detail: full with includeViews and includeRoutines to obtain comprehensive definitions. The server supports PII redaction where configured, and you can enable this through the Database Configuration File by marking certain fields for redaction. Start the server using PHP (as shown in the installation steps) and connect your MCP client to the running instance; once connected, you can issue JSON-RPC like requests to query data or inspect schemas for any configured connection.
How to install
Prerequisites:
- PHP 8.4+ with required database extensions installed (depending on your databases: pdo_mysql, pdo_pgsql, pdo_sqlite, sqlsrv, etc.)
- Composer
Installation steps:
-
Clone the repository: git clone https://github.com/ineersa/mcp-sql-server.git cd mcp-sql-server
-
Install PHP dependencies (production only): composer install --no-dev
-
Create or provide your database configuration YAML file as described in the Documentation (e.g., databases.yaml) and set the DATABASE_CONFIG_FILE environment variable to its path.
-
Run the MCP server (example using built-in PHP server entrypoint via Symfony console): php bin/console mcp:server --port 8000
-
(Optional) If you prefer Docker, use the provided docker-compose.yaml from the Quick Start and follow the Docker-based setup in the README.
Notes:
- The exact command to start the server can vary depending on how you deploy (CLI Symfony command, PHP built-in server, or a container entrypoint). The example uses the Symfony-based command mcp:server which is typical for PHP/Symfony MCP servers.
- Ensure your database credentials in the YAML configuration are correct and that network access from the MCP server to the databases is permitted.
Additional notes
Tips and common considerations:
- Environment variables: DATABASE_CONFIG_FILE is required to locate the YAML file with database connections; APP_ENV, APP_DEBUG, and LOG_LEVEL control behavior and logging detail.
- For Docker deployments, the README provides a docker-compose example for running the MCP in a container alongside a database-mcp workflow; this is the recommended approach if you want isolated, reproducible environments.
- The MCP client configuration supports two primary tools (query and schema). Use query to fetch data from a specific connection and use schema to introspect the metadata of a connection before writing more complex queries.
- PII detection and redaction can be configured in your database configuration file; enabling redaction helps protect sensitive columns when returning results.
- If you run into PHP extension issues (e.g., missing PDO drivers), install the required PHP extensions corresponding to your target databases.
- Logs are written to APP_LOG_DIR; ensure the directory is writable by the web/User running the MCP server.
Related MCP Servers
drift
Codebase intelligence for AI. Detects patterns & conventions + remembers decisions across sessions. MCP server for any IDE. Offline CLI.
laravel
A Laravel package for implementing secure Model Context Protocol servers using Streamable HTTP and SSE transport, providing real-time communication and a scalable tool system for enterprise environments.
php
基于 PHP 实现的 MCP (Model Control Protocol) 服务器框架,通过注解优雅地定义 MCP 服务,支持 Tool、Prompt、Resource 三种处理器,支持Stdio、Sse 两种 transport。
mcp-profiler-bundle
The Symfony MCP Profiler Bundle mimics the WebProfiler Bundle. It bridges the gap between Profiler data and your favorite MCP-enabled AI-powered IDE.
elementor
Comprehensive Elementor MCP Server plugin.
mcp
Model Context Protocol for Hyperf