The MCP SQL Server provides comprehensive access to SQL databases (starting with MSSQL support), enabling AI assistants to inspect database schemas, execute queries, and perform database operations with enterprise-grade security and performance monitoring.
# Install globally via NPM
npm install -g @donggyunryu/mcp-sql
Create a .env
file with your database settings:
# DB_TYPE=mssql # Currently only MSSQL supported
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=your_database
DB_USER=your_username
DB_PASSWORD=your_password
DB_ENCRYPT=false
DB_TRUST_SERVER_CERTIFICATE=true
# Test your database connection
npm run test:db # in local environment
# or
npx @donggyunryu/mcp-sql test:db
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"mcp-sql": {
"command": "npx",
"args": ["-y", "@donggyunryu/mcp-sql"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "1433",
"DB_DATABASE": "your_database",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_ENCRYPT": "false",
"DB_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}
Add to your MCP settings:
{
"mcpServers": {
"mcp-sql": {
"command": "npx",
"args": ["-y", "@donggyunryu/mcp-sql"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "1433",
"DB_DATABASE": "your_database",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_ENCRYPT": "false",
"DB_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}
After configuring your AI assistant, restart it and try the following prompts:
"Show me all tables in the database"
"What's the structure of the users table?"
"List all columns in the orders table with their data types"
"Find all active users registered in the last 30 days"
"Show me the top 10 customers by total order value"
"Get all pending orders from this month"
"Show me current connection pool status"
"What are the slowest queries in the last hour?"
"Generate a performance report for today"
Tool | Description | Parameters |
---|---|---|
list_tables |
List all tables in database | pattern (optional): Filter pattern |
describe_table |
Get detailed table structure | table_name : Name of table to describe |
get_schema |
Get complete database schema | include_system_tables : Include system tables |
get_schema_statistics |
Get schema statistics information | None |
Tool | Description | Parameters |
---|---|---|
execute_query |
Execute SQL queries safely | query : SQL statementparameters : Bind parameters |
start_batch_processing |
Process multiple queries in batch | queries : Array of SQL statements |
Tool | Description | Parameters |
---|---|---|
get_connection_pool_status |
Get database connection pool status | None |
get_query_stats |
Get query execution statistics | period : Time period (optional) |
start_performance_monitoring |
Start performance monitoring | interval : Monitoring interval (ms) |
generate_performance_report |
Generate performance analysis report | timeRange : Report period |
clear_caches |
Initialize cache data | None |
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.