MSSQL MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MSSQL MCP Server
A Model Context Protocol (MCP) server for SQL Server database integration that provides comprehensive database interaction capabilities through AI assistants like Claude Desktop and VS Code with GitHub Copilot.
Features
This MCP server provides the following tools for interacting with SQL Server databases:
š§ Core Database Tools
test_connection- Test the database connection to ensure proper connectivityexecute_query- Execute custom SQL queries on the databaseget_database_schema- Get a complete overview of the database schema
š Database Discovery Tools
get_database_tables- List all tables in the database with schema informationget_database_views- List all views in the databaseget_database_procedures- List all stored proceduresget_database_functions- List all user-defined functionsget_database_triggers- List all triggers in the databasesearch_database_objects- Search for database objects by name across all object types
š Table Analysis Tools
get_table_info- Get detailed information about a specific table (columns, data types, constraints, descriptions)get_table_indexes- Retrieve all indexes for a specific tableget_table_constraints- Get all constraints (primary keys, foreign keys, check constraints) for a tableget_table_stats- Get table statistics including row count, size, and space usage
Related MCP server: MSSQL MCP Server
Installation
Clone the repository:
git clone <repository-url>
cd mssql-mcpInstall dependencies:
npm installBuild the project:
npm run buildConfiguration
Environment Variables
Create a .env file in the project root with your SQL Server connection details:
DB_USER=your_username
DB_PASSWORD=your_password
DB_SERVER=localhost
DB_DATABASE=your_database_nameMCP Configuration File
The mcp-config.json file contains the server configuration for the MCP client:
{
"servers": {
"mssql-mcp": {
"command": "node",
"args": ["path/to/your/project/dist/server.js"],
"env": {
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_SERVER": "localhost",
"DB_DATABASE": "your_database_name"
}
}
}
}Quick Start
For Claude Desktop
Install and build the MCP server (see Installation section above)
Locate Claude Desktop's configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add the server configuration to Claude's config file:
{
"mcpServers": {
"mssql-mcp": {
"command": "node",
"args": ["C:\\path\\to\\your\\project\\dist\\server.js"],
"env": {
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_SERVER": "localhost",
"DB_DATABASE": "your_database_name"
}
}
}
}Restart Claude Desktop to load the new MCP server
Verify the connection by asking Claude to test the database connection:
Can you test the database connection using the mssql tools?
For VS Code with GitHub Copilot
Install and build the MCP server (see Installation section above)
Enable MCP in VS Code:
Open the Extensions panel in VS Code
Look for MCP-related extensions or GitHub Copilot settings
Ensure MCP integration is enabled
Create or locate the MCP configuration file:
Create
mcp.jsonin your VS Code user directory:C:\Users\<username>\AppData\Roaming\Code\User\mcp.jsonIf the file already exists, you can add the server configuration to the existing file
Add the server configuration to your
mcp.jsonfile:
{
"servers": {
"mssql-mcp": {
"command": "node",
"args": ["./dist/server.js"],
"cwd": "C:\\path\\to\\your\\mssql-mcp\\project",
"env": {
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_SERVER": "localhost",
"DB_DATABASE": "your_database_name"
}
}
}
}Important::
Replace
C:\\path\\to\\your\\mssql-mcp\\projectwith the actual absolute path to your project directory.Replace the environment variables in the
envsection with your actual database credentials:
Start the MSSQL-MCP server in VS Code:
Open the Extensions panel in VS Code (Ctrl+Shift+X)
Find the MCP server management section
Start or enable the mssql-mcp server from the list of configured servers
Verify the server status shows as "Running" or "Connected"
Test the connection by asking GitHub Copilot to interact with your database:
Can you test the database connection using the mssql tools?
Usage Examples
Once configured, you can interact with your SQL Server database through natural language:
Basic Database Exploration
"What tables are available in the database?"
"Show me the structure of the Users table"
"List all stored procedures in the database"Data Analysis
"How many rows are in the Orders table?"
"What are the indexes on the Products table?"
"Show me the constraints for the Customers table"Custom Queries
"Execute a query to find all customers from France"
"Get the top 10 most recent orders"
"Show me sales data for the last month"Schema Analysis
"Give me an overview of the entire database schema"
"Search for any objects containing 'user' in their name"
"What triggers exist in the database?"Development
Project Structure
āāā src/
ā āāā server.ts # Main MCP server setup
ā āāā database.ts # Database connection management
ā āāā tools.ts # Tool definitions and implementations
āāā dist/ # Compiled JavaScript output
āāā package.json
āāā tsconfig.json
āāā mcp-config.json # MCP server configuration
āāā .env # Environment variables (create this)Running in Development
# Build and start the server
npm run build
npm start
# Or build in watch mode during development
npx tsc --watchAdding New Tools
To add new database tools, edit src/tools.ts and follow the existing pattern:
server.registerTool(
"your_tool_name",
{
title: "Your Tool Title",
description: "Description of what your tool does",
inputSchema: {
// Define your input parameters using Zod schema
parameter: z.string().describe("Parameter description"),
},
},
async ({ parameter }) => {
// Tool implementation
try {
const connection = getDbConnection();
const result = await connection.request().query("YOUR SQL");
return {
content: [
{
type: "text",
text: JSON.stringify(result.recordset, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`,
},
],
};
}
}
);Security Considerations
Environment Variables: Never commit your
.envfile or actual database credentials to version controlSQL Injection: The server uses parameterized queries where possible to prevent SQL injection
Access Control: Ensure the database user has only the necessary permissions for your use case
Network Security: Use secure connections and proper firewall configurations for production deployments
Troubleshooting
Common Issues
Connection Errors:
Verify database server is running and accessible
Check firewall settings
Confirm SQL Server authentication mode allows your connection type
Permission Errors:
Ensure the database user has necessary permissions for the operations you're trying to perform
Check if the user can access system views for metadata queries
MCP Client Not Recognizing Server:
Verify the path to the compiled server (
dist/server.js) is correctCheck that all dependencies are installed
Restart the MCP client after configuration changes
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Query, explore, and manage your databases through natural conversation.
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to securely interact with Microsoft SQL Server databases to query data, inspect schemas, and retrieve metadata with read-only operations by default and optional write capabilities.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Microsoft SQL Server databases through a standardized interface. Supports executing SQL queries, browsing database schemas, and viewing table data with flexible authentication options for both local and Azure SQL databases.5MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with SQL Server databases through natural language, providing capabilities for executing queries, exploring schemas, analyzing performance, backing up tables, and managing data with built-in safety limits.-
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze and query SQL Server databases, including schema discovery, health checks, and data retrieval.10-