MCP MS SQL Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP MS SQL Serverlist all tables in the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-mssql-server
A Model Context Protocol (MCP) server that provides a standardized interface for AI models to interact with MS SQL Server databases. This server implements the MCP specification to enable seamless database operations through a consistent API.
Features
Execute SQL queries with parameter support
List all tables in the database
Describe table schemas
Support for both stdio and HTTP transport modes
Comprehensive logging system
Environment-based configuration
Error handling and graceful shutdown
Related MCP server: MSSQL Database MCP Server
Prerequisites
Node.js (version that supports ES modules)
MS SQL Server instance
Access credentials for the database
Installation
Clone the repository
Install dependencies:
npm installYou can also install the package globally:
npm install -g mcp-mssql-serverCreate a
.envfile in the project root with the following required variables:
DB_SERVER=your_server_address
DB_USER=your_username
DB_PASSWORD=your_password
DB_DATABASE_NAME=your_database_nameUsage
The server can be started in two different transport modes:
stdio Mode (Default)
npm start
# or
npm run start:stdioHTTP Mode
npm run start:httpDevelopment Mode
npm run devJSON-RPC Protocol
The server implements the JSON-RPC 2.0 protocol with the following key methods:
initialize- Initialize the server connection:
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {}
},
"clientInfo": {
"name": "your-client",
"version": "1.0.0"
}
}
}tools/list- List available toolstools/call- Call a specific tool
Testing
The package includes a test client (test.package.js) that demonstrates how to interact with the MCP server:
node test.package.jsThe test client implements an MCPTestClient class that:
Spawns a server process using
npx mcp-mssql-serverInitializes the connection with protocol version '2024-11-05'
Lists available tools
Executes sample queries including:
Listing all tables
Running a specific SQL query to count documents
Handles server responses and errors through stdio streams
Includes proper error handling and process cleanup
Example test query from the client:
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "execute_sql_query",
"arguments": {
"query": "SELECT COUNT(*) as document_count FROM document_new"
}
}
}The test client provides a simple way to verify the server's functionality and can serve as a reference for implementing your own client.
Available Tools
The server provides the following MCP tools:
1. execute_sql_query
Execute SQL queries against the database with optional parameterization.
{
"query": "SELECT * FROM Users WHERE id = @userId",
"parameters": [
{
"name": "userId",
"type": "int",
"value": 1
}
]
}2. list_tables
List all available tables in the connected database.
3. describe_table
Get detailed schema information for a specific table.
{
"table_name": "Users"
}Logging
Logs are stored in the logs directory:
error.log: Error-level logscombined.log: All logs
In HTTP mode, logs are also output to the console.
Dependencies
Main dependencies:
@modelcontextprotocol/sdk: ^1.13.0
dotenv: ^16.4.5
express: ^5.1.0
mssql: ^11.0.1
winston: ^3.11.0
Development dependencies:
axios: ^1.10.0
License
MIT
Contributing
Fork the repository
Create your feature branch
Commit your changes
Push to the branch
Create a new Pull Request
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Microsoft SQL Server databases through query execution, schema discovery, CRUD operations, stored procedures, and data export with built-in safety controls.18Apache 2.0
- Alicense-qualityDmaintenanceEnables 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
- Alicense-qualityDmaintenanceEnables 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
- Flicense-qualityDmaintenanceProvides direct SQL query access to Microsoft SQL Server databases with full CRUD operations, enabling AI assistants to execute queries, modify data, and manage database objects through a simplified interface.
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Official Microsoft MCP Server to query Microsoft Entra data using natural language
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/techybolek/mcp_sql_server2'
If you have feedback or need assistance with the MCP directory API, please join our Discord server