Skip to content

Commit 2bf291d

Browse files
authored
Merge pull request #48 from Azure-Samples/dev/akma/mssql-mcp-address-pr-comments
This is a follow up addressing comments from: #44 - Rename Azure SQL DB to MSSQL DB - Remove QueryTableTool since it is a duplicate for ReadData - Update folder structure for separate dotnet and Node MCP Servers - Extend UpdateDataTool to allow for where clauses and different columns to be updated - Update ReadDataTool to allow any select to be Passed and added checks - Added sample for VS Code Agent MCP Server
2 parents 12dfb33 + 40b51d9 commit 2bf291d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+369
-478
lines changed

MssqlMcp/Node/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

MssqlMcp/Node/README.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# MSSQL Database MCP Server
2+
3+
<div align="center">
4+
<img src="./src/img/logo.png" alt="MSSQL Database MCP server logo" width="400"/>
5+
</div>
6+
7+
## What is this? 🤔
8+
9+
This is a server that lets your LLMs (like Claude) talk directly to your MSSQL Database data! Think of it as a friendly translator that sits between your AI assistant and your database, making sure they can chat securely and efficiently.
10+
11+
### Quick Example
12+
```text
13+
You: "Show me all customers from New York"
14+
Claude: *queries your MSSQL Database database and gives you the answer in plain English*
15+
```
16+
17+
## How Does It Work? 🛠️
18+
19+
This server leverages the Model Context Protocol (MCP), a versatile framework that acts as a universal translator between AI models and databases. It supports multiple AI assistants including Claude Desktop and VS Code Agent.
20+
21+
### What Can It Do? 📊
22+
23+
- Run MSSQL Database queries by just asking questions in plain English
24+
- Create, read, update, and delete data
25+
- Manage database schema (tables, indexes)
26+
- Secure connection handling
27+
- Real-time data interaction
28+
29+
## Quick Start 🚀
30+
31+
### Prerequisites
32+
- Node.js 14 or higher
33+
- Claude Desktop or VS Code with Agent extension
34+
35+
### Set up project
36+
37+
1. **Install Dependencies**
38+
Run the following command in the root folder to install all necessary dependencies:
39+
```bash
40+
npm install
41+
```
42+
43+
2. **Build the Project**
44+
Compile the project by running:
45+
```bash
46+
npm run build
47+
```
48+
49+
3. **Start the Server**
50+
Navigate to the `dist` folder and start the server:
51+
```bash
52+
npm start
53+
```
54+
55+
4. **Confirmation Message**
56+
You should see the following message:
57+
```
58+
MSSQL Database Server running on stdio
59+
```
60+
61+
## Configuration Setup
62+
63+
### Option 1: VS Code Agent Setup
64+
65+
1. **Install VS Code Agent Extension**
66+
- Open VS Code
67+
- Go to Extensions (Ctrl+Shift+X)
68+
- Search for "Agent" and install the official Agent extension
69+
70+
2. **Create MCP Configuration File**
71+
- Create a `.vscode/mcp.json` file in your workspace
72+
- Add the following configuration:
73+
74+
```json
75+
{
76+
"servers": {
77+
"mssql-nodejs": {
78+
"type": "stdio",
79+
"command": "node",
80+
"args": ["q:\\Repos\\SQL-AI-samples\\MssqlMcp\\NodejsMcpServer\\dist\\index.js"],
81+
"env": {
82+
"SERVER_NAME": "your-server-name.database.windows.net",
83+
"DATABASE_NAME": "your-database-name",
84+
"READONLY": "false"
85+
}
86+
}
87+
}
88+
}
89+
```
90+
91+
3. **Alternative: User Settings Configuration**
92+
- Open VS Code Settings (Ctrl+,)
93+
- Search for "mcp"
94+
- Click "Edit in settings.json"
95+
- Add the following configuration:
96+
97+
```json
98+
{
99+
"mcp": {
100+
"servers": {
101+
"mssql": {
102+
"command": "node",
103+
"args": ["C:/path/to/your/NodejsMcpServer/dist/index.js"],
104+
"env": {
105+
"SERVER_NAME": "your-server-name.database.windows.net",
106+
"DATABASE_NAME": "your-database-name",
107+
"READONLY": "false"
108+
}
109+
}
110+
}
111+
}
112+
}
113+
```
114+
115+
4. **Restart VS Code**
116+
- Close and reopen VS Code for the changes to take effect
117+
118+
5. **Verify MCP Server**
119+
- Open Command Palette (Ctrl+Shift+P)
120+
- Run "MCP: List Servers" to verify your server is configured
121+
- You should see "mssql" in the list of available servers
122+
123+
### Option 2: Claude Desktop Setup
124+
125+
1. **Open Claude Desktop Settings**
126+
- Navigate to File → Settings → Developer → Edit Config
127+
- Open the `claude_desktop_config` file
128+
129+
2. **Add MCP Server Configuration**
130+
Replace the content with the configuration below, updating the path and credentials:
131+
132+
```json
133+
{
134+
"mcpServers": {
135+
"mssql": {
136+
"command": "node",
137+
"args": ["C:/path/to/your/NodejsMcpServer/dist/index.js"],
138+
"env": {
139+
"SERVER_NAME": "your-server-name.database.windows.net",
140+
"DATABASE_NAME": "your-database-name",
141+
"READONLY": "false"
142+
}
143+
}
144+
}
145+
}
146+
```
147+
148+
3. **Restart Claude Desktop**
149+
- Close and reopen Claude Desktop for the changes to take effect
150+
151+
### Configuration Parameters
152+
153+
- **SERVER_NAME**: Your MSSQL Database server name (e.g., `my-server.database.windows.net`)
154+
- **DATABASE_NAME**: Your database name
155+
- **READONLY**: Set to `"true"` to restrict to read-only operations, `"false"` for full access
156+
- **Path**: Update the path in `args` to point to your actual project location
157+
158+
## Sample Configurations
159+
160+
You can find sample configuration files in the `src/samples/` folder:
161+
- `claude_desktop_config.json` - For Claude Desktop
162+
- `vscode_agent_config.json` - For VS Code Agent
163+
164+
## Usage Examples
165+
166+
Once configured, you can interact with your database using natural language:
167+
168+
- "Show me all users from New York"
169+
- "Create a new table called products with columns for id, name, and price"
170+
- "Update all pending orders to completed status"
171+
- "List all tables in the database"
172+
173+
## Security Notes
174+
175+
- The server requires a WHERE clause for read operations to prevent accidental full table scans
176+
- Update operations require explicit WHERE clauses for security
177+
- Set `READONLY: "true"` in production environments if you only need read access
178+
179+
You should now have successfully configured the MCP server for MSSQL Database with your preferred AI assistant. This setup allows you to seamlessly interact with MSSQL Database through natural language queries!

0 commit comments

Comments
 (0)