Sponsored by Deepsite.site

Mcp Sqlserver

Created By
bilims5 months ago
Content

MCP SQL Server

License TypeScript Node.js

A Model Context Protocol (MCP) server that enables AI agents to interact with Microsoft SQL Server databases through secure, intelligent database operations. This server provides comprehensive CRUD capabilities, schema introspection, stored procedure execution, transaction management, and bulk operations for production SQL Server environments.

🌟 Features

Core Database Operations

  • CRUD Operations: Complete SELECT, INSERT, UPDATE, DELETE functionality
  • Custom Queries: Safe execution of custom SELECT statements with security restrictions
  • Schema Introspection: Database, table, column, index, and foreign key exploration
  • Connection Management: Robust connection pooling with automatic reconnection

Advanced Operations (v1.1.0)

  • Stored Procedures: Execute stored procedures with parameters, multiple result sets, and output parameters
  • Transaction Management: BEGIN/COMMIT/ROLLBACK operations with isolation levels and savepoints
  • Bulk Operations: High-performance bulk insert, batch update/delete, and data import (CSV/JSON)

Security & Safety

  • Parameterized Queries: Full SQL injection prevention
  • Query Restrictions: DDL operations blocked in custom queries
  • Input Validation: Comprehensive Zod-based validation
  • Connection Validation: Health checks and timeout controls

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • TypeScript 5.0+
  • Microsoft SQL Server (2016+)
  • Claude Desktop or MCP-compatible client

Installation

# No installation required - run directly
npx @bilims/mcp-sqlserver

Option 2: Global Installation

npm install -g @bilims/mcp-sqlserver
mcp-sqlserver

Option 3: From Source

git clone https://github.com/bilims/mcp-sqlserver.git
cd mcp-sqlserver
npm install
npm run build
npm start

Configuration

Create a .env file with your SQL Server configuration:

# SQL Server Configuration
SQLSERVER_HOST=your-server-host
SQLSERVER_PORT=1433
SQLSERVER_DATABASE=your-database
SQLSERVER_USERNAME=your-username
SQLSERVER_PASSWORD=your-password
SQLSERVER_ENCRYPT=true
SQLSERVER_TRUST_SERVER_CERTIFICATE=true

# Connection Pool Settings
SQLSERVER_POOL_MIN=0
SQLSERVER_POOL_MAX=10
SQLSERVER_CONNECTION_TIMEOUT=15000
SQLSERVER_REQUEST_TIMEOUT=15000

Claude Desktop Integration

Add to your Claude Desktop MCP settings (claude_desktop_config.json):

{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": ["-y", "@bilims/mcp-sqlserver"],
      "env": {
        "SQLSERVER_HOST": "your-server-host",
        "SQLSERVER_DATABASE": "your-database",
        "SQLSERVER_USERNAME": "your-username",
        "SQLSERVER_PASSWORD": "your-password"
      }
    }
  }
}

Option 2: Global Installation

{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "mcp-sqlserver"
    }
  }
}

Option 3: From Source

{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "node",
      "args": ["/path/to/mcp-sqlserver/dist/index.js"],
      "cwd": "/path/to/mcp-sqlserver"
    }
  }
}

Note: For options 2 and 3, create a .env file in the appropriate directory with your SQL Server configuration.

🛠 Available Tools

Core Database Operations (10 tools)

  • sql_test_connection - Database connectivity testing
  • sql_select - Advanced SELECT queries with filtering and joins
  • sql_insert - Safe record insertion
  • sql_update - Conditional record updates
  • sql_delete - Safe record deletion
  • sql_query - Custom SELECT statement execution
  • sql_get_tables - Database table listing
  • sql_get_columns - Table column information
  • sql_get_table_structure - Complete table structure analysis
  • sql_get_schemas - Database schema exploration

Stored Procedures (3 tools)

  • sql_execute_stored_procedure - Execute stored procedures with parameters
  • sql_get_stored_procedures - List all stored procedures
  • sql_get_stored_procedure_info - Get detailed stored procedure information

Transaction Management (5 tools)

  • sql_begin_transaction - Start database transactions with isolation levels
  • sql_commit_transaction - Commit active transactions
  • sql_rollback_transaction - Rollback transactions or to savepoints
  • sql_create_savepoint - Create transaction savepoints
  • sql_get_transaction_status - Check current transaction status

Bulk Operations (4 tools)

  • sql_bulk_insert - High-performance bulk insert operations
  • sql_batch_update - Batch update multiple records
  • sql_batch_delete - Batch delete multiple records
  • sql_import_data - Import data from CSV/JSON formats

Total: 22 tools available

📚 Usage Examples

Basic Query

// Using sql_select tool
{
  "table": "Users",
  "columns": ["id", "name", "email"],
  "where": [
    {"column": "active", "operator": "=", "value": true}
  ],
  "orderBy": [{"column": "created_at", "direction": "DESC"}],
  "limit": 10
}

Stored Procedure Execution

// Using sql_execute_stored_procedure tool
{
  "procedureName": "GetUsersByRole",
  "schema": "dbo",
  "parameters": [
    {"name": "role", "value": "admin", "type": "varchar", "size": 50}
  ]
}

Bulk Insert

// Using sql_bulk_insert tool
{
  "table": "Products",
  "data": [
    {"name": "Product 1", "price": 29.99, "active": true},
    {"name": "Product 2", "price": 39.99, "active": true}
  ],
  "batchSize": 100
}

Transaction Management

// Begin transaction
{"isolationLevel": "READ_COMMITTED"}

// Create savepoint
{"savepointName": "before_updates"}

// Rollback to savepoint if needed
{"savepoint": "before_updates"}

🗺️ Roadmap

  • v1.1.0 (Current): Enhanced database operations with stored procedures, transactions, and bulk operations
  • v1.2.0 (Q3 2025): Data Analysis & Insights - 15 new analytics and export tools
  • v1.3.0 (Q4 2025): Advanced Query Builder - Natural language processing and query templates
  • v1.4.0 (Q1 2026): Enterprise Features - Multi-database support and security auditing
  • v2.0.0 (Mid-2026): AI-Enhanced Features - Full AI assistant capabilities

See ROADMAP.md for detailed feature plans.

🔧 Development

Scripts

  • npm run build - Build TypeScript to JavaScript
  • npm run dev - Run in development mode
  • npm start - Start the compiled server
  • npm test - Run tests
  • npm run lint - Lint TypeScript files
  • npm run typecheck - Type check without emitting

Project Structure

├── src/
│   ├── config/         # Configuration management
│   ├── database/       # Database connection and query building
│   ├── tools/          # MCP tool implementations
│   ├── types/          # TypeScript type definitions
│   ├── utils/          # Utility functions
│   ├── server.ts       # Main MCP server
│   └── index.ts        # Entry point
├── dist/               # Compiled JavaScript (generated)
├── ROADMAP.md          # Detailed development roadmap
├── package.json
└── tsconfig.json

🛡️ Security

  • All queries use parameterized inputs to prevent SQL injection
  • DDL operations are blocked in custom queries
  • Connection validation and timeout controls
  • Comprehensive input validation using Zod schemas
  • Production-ready error handling and logging

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See ROADMAP.md for priority areas and upcoming features.

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🏢 About

Developed and maintained by Bilims.

For support, feature requests, or bug reports, please open an issue.


⚡ Ready to supercharge your SQL Server operations with AI? Get started today!

Server Config

{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@bilims/mcp-sqlserver"
      ],
      "env": {
        "SQLSERVER_HOST": "your-server-host",
        "SQLSERVER_DATABASE": "your-database",
        "SQLSERVER_USERNAME": "your-username",
        "SQLSERVER_PASSWORD": "your-password"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
CursorThe AI Code Editor
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"