mssql-mcp 1.0.3 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +98 -76
  2. package/dist/index.js +16 -20
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,38 +1,18 @@
1
- # MS SQL Server MCP Server
1
+ # MS SQL Server MCP Server v2.0.3
2
2
 
3
- Model Context Protocol (MCP) server for Microsoft SQL Server. Designed for use in IDEs like Claude Desktop, Cursor, Windsurf, and VS Code with enhanced security features.
3
+ šŸš€ **Smart Trust-Based Model Context Protocol (MCP) server** for Microsoft SQL Server with intelligent auto-connection and AI-friendly design.
4
4
 
5
- ## šŸ†• Version 1.0.2 - Security & Reliability Updates
5
+ ## šŸš€ Quick Start
6
6
 
7
- - āœ… **SQL Injection Protection**: Advanced pattern detection and parameterized query enforcement
8
- - āœ… **Input Validation**: Strict validation for table names, schema names, and query parameters
9
- - āœ… **Updated Dependencies**: Latest @modelcontextprotocol/sdk (v1.17.1)
10
- - āœ… **Better Error Handling**: Comprehensive logging and graceful error recovery
11
- - āœ… **Performance Monitoring**: Query execution time tracking
12
- - āœ… **Connection Security**: Enhanced SSL/TLS settings and connection pooling
7
+ ### 1. Install
13
8
 
14
- ## Features
15
-
16
- - šŸ”— **Database Connection Management**: Secure connection to MS SQL Server
17
- - šŸ“Š **SQL Query Execution**: Parameterized queries and DDL/DML operations with injection protection
18
- - šŸ—‚ļø **Schema Management**: Tables, views, stored procedures
19
- - šŸ“‹ **Table Operations**: Structure inspection, data viewing, pagination
20
- - āš™ļø **Stored Procedures**: Execute with parameters
21
- - šŸ¢ **Database Listing**: All databases in the instance
22
- - šŸ”’ **Security**: SQL injection protection, input validation
23
-
24
- ## IDE Configuration
25
-
26
- This MCP server can be used in IDEs like Claude Desktop, Cursor, Windsurf, and VS Code.
27
-
28
- ### Configuration Files
29
-
30
- **For Claude Desktop**: `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
31
-
32
- **For VS Code-based IDEs**: `.vscode/mcp.json`
9
+ ```bash
10
+ npm install -g mssql-mcp
11
+ ```
33
12
 
34
- ### Basic Configuration
13
+ ### 2. Configure IDE
35
14
 
15
+ **Claude Desktop** (`claude_desktop_config.json`):
36
16
  ```json
37
17
  {
38
18
  "mcpServers": {
@@ -41,10 +21,9 @@ This MCP server can be used in IDEs like Claude Desktop, Cursor, Windsurf, and V
41
21
  "args": ["-y", "mssql-mcp@latest"],
42
22
  "env": {
43
23
  "DB_SERVER": "your-server.com",
44
- "DB_DATABASE": "your-database",
24
+ "DB_DATABASE": "your-database",
45
25
  "DB_USER": "your-username",
46
26
  "DB_PASSWORD": "your-password",
47
- "DB_PORT": "1433",
48
27
  "DB_TRUST_SERVER_CERTIFICATE": "true"
49
28
  }
50
29
  }
@@ -52,63 +31,106 @@ This MCP server can be used in IDEs like Claude Desktop, Cursor, Windsurf, and V
52
31
  }
53
32
  ```
54
33
 
55
- > **Note**: Use `"servers"` instead of `"mcpServers"` in VS Code-based IDEs.
34
+ **Cursor/Windsurf/VS Code** (`.vscode/mcp.json`):
35
+ ```json
36
+ {
37
+ "servers": {
38
+ "mssql": {
39
+ "command": "npx",
40
+ "args": ["-y", "mssql-mcp@latest"],
41
+ "env": {
42
+ "DB_SERVER": "your-server.com",
43
+ "DB_DATABASE": "your-database",
44
+ "DB_USER": "your-username",
45
+ "DB_PASSWORD": "your-password",
46
+ "DB_TRUST_SERVER_CERTIFICATE": "true"
47
+ }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ > Replace with your actual database credentials. Server auto-connects using these.
54
+
55
+ ## šŸ› ļø Available Tools
56
56
 
57
- ### Platform Specific Settings
57
+ | Tool | Description |
58
+ |------|-------------|
59
+ | `execute_query` | Execute any SQL query with parameters |
60
+ | `get_schema` | List database objects (tables, views, procedures) |
61
+ | `describe_table` | Get detailed table structure |
62
+ | `get_table_data` | Retrieve data with pagination |
63
+ | `execute_procedure` | Execute stored procedures |
64
+ | `list_databases` | List all databases |
65
+ | `connection_status` | Check connection state |
66
+ | `connect_database` | Manual connection (rarely needed) |
67
+ | `disconnect_database` | Close connection |
68
+ | `clear_cache` | Clear query cache |
58
69
 
59
- - **macOS/Linux**: Use the configuration above as is
60
- - **Windows**: Use `"command": "cmd"` and `"args": ["/c", "npx", "-y", "mssql-mcp@latest"]`
61
- - **WSL**: Use `"command": "wsl"` and `"args": ["npx", "-y", "mssql-mcp@latest"]`
70
+ All tools auto-connect using environment variables.
62
71
 
63
- ## Environment Variables
72
+ ## šŸ”§ Environment Variables
64
73
 
65
- You can use the following environment variables:
74
+ | Variable | Required | Default |
75
+ |----------|----------|---------|
76
+ | `DB_SERVER` | āœ… | - |
77
+ | `DB_DATABASE` | āœ… | - |
78
+ | `DB_USER` | āœ… | - |
79
+ | `DB_PASSWORD` | āœ… | - |
80
+ | `DB_PORT` | āŒ | 1433 |
81
+ | `DB_TRUST_SERVER_CERTIFICATE` | āŒ | true |
82
+ | `DB_CONNECTION_TIMEOUT` | āŒ | 30000 |
83
+ | `DB_REQUEST_TIMEOUT` | āŒ | 30000 |
66
84
 
67
- - `DB_SERVER`: SQL Server address
68
- - `DB_DATABASE`: Database name
69
- - `DB_USER`: Username (leave empty for Windows Authentication)
70
- - `DB_PASSWORD`: Password
71
- - `DB_PORT`: Port number (default: 1433)
72
- - `DB_TRUST_SERVER_CERTIFICATE`: SSL certificate trust (true/false)
73
- - `DB_CONNECTION_TIMEOUT`: Connection timeout in milliseconds (default: 30000)
74
- - `DB_REQUEST_TIMEOUT`: Request timeout in milliseconds (default: 30000)
85
+ ## šŸ›”ļø Security
75
86
 
76
- ## Available Functions
87
+ **āœ… Supported:** All database operations (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP)
77
88
 
78
- This MCP server provides 9 database operations:
89
+ **🚨 Blocked:** Server-level operations only (SHUTDOWN, XP_CMDSHELL, RECONFIGURE)
79
90
 
80
- | Function | Description |
81
- |----------|-------------|
82
- | `connect_database` | Establishes connection to SQL Server |
83
- | `connection_status` | Checks connection status |
84
- | `disconnect_database` | Closes the connection |
85
- | `execute_query` | Executes SQL queries (SELECT, INSERT, UPDATE, DELETE) |
86
- | `execute_procedure` | Executes stored procedures |
87
- | `get_schema` | Lists database schema (tables, views, procedures) |
88
- | `describe_table` | Shows detailed table structure |
89
- | `list_databases` | Lists all databases |
90
- | `get_table_data` | Retrieves table data with pagination |
91
+ ## šŸ† Features
91
92
 
92
- ## Security Notes
93
+ - āœ… **Auto-Connection**: Environment-based, no manual steps
94
+ - āœ… **Complete SQL Support**: All database operations
95
+ - āœ… **No Rate Limiting**: Natural workflow
96
+ - āœ… **Query Caching**: 5-minute TTL for SELECT queries
97
+ - āœ… **Performance Monitoring**: Execution time tracking
98
+ - āœ… **Latest MCP SDK**: v1.20.2 with 2025 protocol
99
+ - āœ… **Clean Logging**: Minimal console output, MCP protocol compatible
93
100
 
94
- - **SQL Injection Protection**: The server includes pattern detection and enforces parameterized queries
95
- - **Input Validation**: All user inputs are validated and sanitized
96
- - **SSL/TLS**: Enable encryption for production environments
97
- - **Connection Pooling**: Automatic connection management with timeout settings
98
- - **Error Handling**: Comprehensive error logging without exposing sensitive information
99
- - **Parameterized Queries**: Always use parameters for user input to prevent SQL injection
101
+ ## šŸ” Troubleshooting
100
102
 
101
- ### 🚨 Important Security Recommendations
103
+ **āŒ Auto-connection failed**
104
+ - Set all required environment variables
105
+ - Verify server accessibility and credentials
106
+ - Check network connectivity
102
107
 
103
- 1. **Use strong passwords and consider Windows Authentication**
104
- 2. **Enable SSL/TLS encryption when possible**
105
- 3. **Use parameterized queries for all user input**
106
- 4. **Monitor logs for security warnings**
107
- 5. **Regularly update the package for security fixes**
108
+ **āŒ SQL Security Alert**
109
+ - Only server operations are blocked
110
+ - Database operations should work normally
108
111
 
109
- ## GitHub Repository
112
+ ## šŸ“‹ Version History
110
113
 
111
- This project is also available on GitHub:
114
+ ### v2.0.3 - Latest
115
+ - āœ… Updated documentation with modern styling
116
+ - āœ… Improved troubleshooting section
117
+ - āœ… Enhanced feature descriptions
118
+
119
+ ### v2.0.2 - Performance & Compatibility
120
+ - āœ… Simplified logging for MCP protocol compatibility
121
+ - āœ… All console output moved to stderr
122
+ - āœ… Clean, professional log messages
123
+ - āœ… Version bump to 2.0.2
124
+
125
+ ## šŸ“„ License
126
+
127
+ MIT License
128
+
129
+ ## šŸ†˜ Support
130
+
131
+ - **Issues**: [GitHub Issues](https://github.com/BYMCS/mssql-mcp/issues)
112
132
  - **Repository**: [BYMCS/mssql-mcp](https://github.com/BYMCS/mssql-mcp)
113
- - **Issues**: For bug reports and suggestions
114
- - **Releases**: Release notes and downloads
133
+
134
+ ---
135
+
136
+ **šŸŽ‰ v2.0.3: Enhanced documentation and user experience**
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ class MSSQLMCPServer {
24
24
  constructor() {
25
25
  this.server = new McpServer({
26
26
  name: "mssql-mcp-server",
27
- version: "1.0.3",
27
+ version: "2.0.3",
28
28
  });
29
29
  this.setupTools();
30
30
  this.setupResources();
@@ -511,10 +511,10 @@ class MSSQLMCPServer {
511
511
  try {
512
512
  // Close existing connection if any
513
513
  if (this.pool) {
514
- console.log("šŸ”„ Closing existing database connection...");
514
+ console.error("Closing existing connection...");
515
515
  await this.pool.close();
516
516
  }
517
- console.log(`šŸ”— Connecting to SQL Server: ${config.server}:${config.port}`);
517
+ console.error(`Connecting to ${config.server}:${config.port}`);
518
518
  // Create new connection pool with enhanced security settings
519
519
  this.pool = new sql.ConnectionPool({
520
520
  server: config.server,
@@ -538,17 +538,17 @@ class MSSQLMCPServer {
538
538
  });
539
539
  // Set up event handlers for better monitoring
540
540
  this.pool.on('connect', () => {
541
- console.log('āœ… Database connection established');
541
+ console.error('Database connected');
542
542
  });
543
543
  this.pool.on('error', (err) => {
544
- console.error('āŒ Database connection error:', err);
544
+ console.error('Database error:', err);
545
545
  });
546
546
  await this.pool.connect();
547
547
  this.config = config;
548
- console.log(`āœ… Successfully connected to database: ${config.server}${config.database ? `/${config.database}` : ''}`);
548
+ console.error(`Connected to ${config.server}${config.database ? `/${config.database}` : ''}`);
549
549
  }
550
550
  catch (error) {
551
- console.error("āŒ Database connection failed:", error);
551
+ console.error("Connection failed:", error);
552
552
  if (this.pool) {
553
553
  try {
554
554
  await this.pool.close();
@@ -566,18 +566,18 @@ class MSSQLMCPServer {
566
566
  const transport = new StdioServerTransport();
567
567
  // Enhanced graceful shutdown handling
568
568
  const shutdown = async (signal) => {
569
- console.log(`\nšŸ›‘ Received ${signal}, initiating graceful shutdown...`);
569
+ console.error(`\nShutting down (${signal})...`);
570
570
  try {
571
571
  if (this.pool) {
572
- console.log("šŸ”„ Closing database connection...");
572
+ console.error("Closing database connection...");
573
573
  await this.pool.close();
574
- console.log("āœ… Database connection closed");
574
+ console.error("Database connection closed");
575
575
  }
576
576
  }
577
577
  catch (error) {
578
- console.error("āŒ Error during shutdown:", error);
578
+ console.error("Shutdown error:", error);
579
579
  }
580
- console.log("šŸ‘‹ Server shutdown complete");
580
+ console.error("Server stopped");
581
581
  process.exit(0);
582
582
  };
583
583
  // Handle various shutdown signals
@@ -586,20 +586,16 @@ class MSSQLMCPServer {
586
586
  process.on('SIGUSR2', () => shutdown('SIGUSR2')); // For nodemon
587
587
  // Handle uncaught exceptions
588
588
  process.on('uncaughtException', (error) => {
589
- console.error('āŒ Uncaught Exception:', error);
589
+ console.error('Uncaught Exception:', error);
590
590
  shutdown('uncaughtException');
591
591
  });
592
592
  process.on('unhandledRejection', (reason, promise) => {
593
- console.error('āŒ Unhandled Rejection at:', promise, 'reason:', reason);
593
+ console.error('Unhandled Rejection:', reason);
594
594
  shutdown('unhandledRejection');
595
595
  });
596
- console.log("šŸš€ Starting MSSQL MCP Server v1.0.3...");
597
- console.log("šŸ”’ Security features enabled:");
598
- console.log(" - SQL injection protection: Enabled");
599
- console.log(" - Input validation: Enhanced");
600
- console.log(" - Parameterized queries: Enforced");
596
+ console.error("MSSQL MCP Server v2.0.3 starting...");
601
597
  await this.server.connect(transport);
602
- console.log("āœ… Server connected and ready to receive requests");
598
+ console.error("Server ready");
603
599
  }
604
600
  }
605
601
  // Start the server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mssql-mcp",
3
- "version": "1.0.3",
3
+ "version": "2.0.3",
4
4
  "description": "MCP Server for MS SQL Server integration with Claude Desktop, Cursor, Windsurf and VS Code",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",