- Explore MCP Servers
- mcp-server-sql
Mcp Server Sql
What is Mcp Server Sql
mcp-server-sql is a Model Context Protocol (MCP) server that allows AI assistants, such as Claude, to securely interact with SQL Server databases through local connections, providing tools for database exploration, query execution, and data analysis.
Use cases
Use cases for mcp-server-sql include enabling AI assistants to perform data queries, allowing developers to explore database schemas, and providing a safe environment for executing SQL commands.
How to use
To use mcp-server-sql, clone the repository from GitHub, install the necessary dependencies using npm, configure the environment variables in a .env file, and set up the Claude Desktop configuration to connect to the MCP server.
Key features
Key features include secure local database access using SQL Authentication, schema exploration to discover tables and relationships, query execution with error handling, and built-in safety controls to prevent harmful operations.
Where to use
mcp-server-sql can be used in various fields that require secure database interactions, such as data analysis, application development, and AI assistant integration.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Server Sql
mcp-server-sql is a Model Context Protocol (MCP) server that allows AI assistants, such as Claude, to securely interact with SQL Server databases through local connections, providing tools for database exploration, query execution, and data analysis.
Use cases
Use cases for mcp-server-sql include enabling AI assistants to perform data queries, allowing developers to explore database schemas, and providing a safe environment for executing SQL commands.
How to use
To use mcp-server-sql, clone the repository from GitHub, install the necessary dependencies using npm, configure the environment variables in a .env file, and set up the Claude Desktop configuration to connect to the MCP server.
Key features
Key features include secure local database access using SQL Authentication, schema exploration to discover tables and relationships, query execution with error handling, and built-in safety controls to prevent harmful operations.
Where to use
mcp-server-sql can be used in various fields that require secure database interactions, such as data analysis, application development, and AI assistant integration.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCP SQL Server
A Model Context Protocol (MCP) server that enables AI assistants like Claude to securely interact with SQL Server databases through local connections. This server provides tools for database exploration, query execution, and data analysis through a controlled interface.
Features
- 🔒 Secure Local Database Access: Connect to SQL Server using SQL Authentication
- 🔍 Schema Exploration: Discover tables, columns, and relationships
- 📊 Query Execution: Run SQL queries with proper error handling
- 🛡️ Safety Controls: Built-in protections against harmful operations
Prerequisites
- Node.js 18.0 or higher
- npm (Node package manager)
- SQL Server
- Claude Desktop application
Installation
1. Clone the Repository
git clone https://github.com/MKhan997733/mcp-server-sql.git
cd mcp-server-sql
2. Install Dependencies
npm install
3. Configure Environment Variables
Create a .env
file in the project root:
DB_SERVER= DB_NAME= DB_USER= DB_PASSWORD= DB_PORT=
Claude Desktop Configuration
1. Locate Claude Desktop Config File
The configuration file is located at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
2. Add MCP Server Configuration
Edit the claude_desktop_config.json
file and add your MCP server:
For SQL Authentication:
{
"mcpServers": {
"sql-server": {
"command": "node",
"args": [
"/absolute/path/to/mcp-server-sql/index.js"
],
"env": {
"DB_SERVER": "localhost",
"DB_NAME": "your_database",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_PORT": "port"
}
}
}
}
Important: Replace /absolute/path/to/mcp-server-sql/
with the actual path to your cloned repository.
3. Restart Claude Desktop
After saving the configuration file, restart Claude Desktop for the changes to take effect.
Usage
Once configured, you can interact with your SQL Server database through Claude by asking questions like:
- “What tables are in my database?”
- “Show me the schema of the Users table”
- “Query the Orders table and show me orders from the last week”
- “Find the top 10 customers by total purchase amount”
- “Show me all stored procedures in the database”
Example Interactions
Discovering Tables:
You: Can you show me what tables exist in my database? Claude: I'll help you discover the tables in your SQL Server database...
Querying Data:
You: Show me all customers who made purchases over $1000 in the last month Claude: I'll query your database to find customers with purchases over $1000...
Schema Exploration:
You: What columns does the Products table have? Claude: Let me examine the structure of the Products table...
Available Tools
The MCP server provides these tools to Claude:
- discover_tables: List all tables in the SQL Server database
- table_details: Get detailed schema information for a specific table
- execute_query: Run SELECT queries (read-only by default)
- get_stored_procedures: List all stored procedures
- get_table_indexes: View indexes on tables
- get_table_constraints: View constraints (PK, FK, etc.)
Security Best Practices
- Use Dedicated SQL Server Login: Create a specific login for the MCP server with minimal required permissions
- Read-Only Access: Configure the database user with read-only access
- Local Connections Only: Server only accepts connections to localhost
- Audit Logging: Enable SQL Server audit logging to track all queries
Running the Server
# Run directly
npm build
node <absolute-path>/build/index.js
(AI GENERATED, REVIEWED BY MKHAN997733)
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.