mssql-agent-mcp 1.0.0__py3-none-any.whl
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.
- mssql_agent_mcp/__init__.py +9 -0
- mssql_agent_mcp/__main__.py +6 -0
- mssql_agent_mcp/config.py +25 -0
- mssql_agent_mcp/server.py +64 -0
- mssql_agent_mcp/tools/__init__.py +58 -0
- mssql_agent_mcp/tools/database.py +193 -0
- mssql_agent_mcp/tools/jobs.py +670 -0
- mssql_agent_mcp/tools/procedures.py +349 -0
- mssql_agent_mcp/utils.py +127 -0
- mssql_agent_mcp-1.0.0.dist-info/METADATA +591 -0
- mssql_agent_mcp-1.0.0.dist-info/RECORD +14 -0
- mssql_agent_mcp-1.0.0.dist-info/WHEEL +4 -0
- mssql_agent_mcp-1.0.0.dist-info/entry_points.txt +2 -0
- mssql_agent_mcp-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mssql-agent-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MCP server for Microsoft SQL Server with SQL Agent job management and stored procedure version control
|
|
5
|
+
Project-URL: Homepage, https://github.com/yyinhsu/mssql-agent-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/yyinhsu/mssql-agent-mcp
|
|
7
|
+
Project-URL: Documentation, https://github.com/yyinhsu/mssql-agent-mcp#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/yyinhsu/mssql-agent-mcp/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/yyinhsu/mssql-agent-mcp/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Ines Hsu <yyinhsu@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: agent-jobs,database,devops,fastmcp,mcp,model-context-protocol,mssql,sql-agent,sql-server,stored-procedures
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Database
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: fastmcp>=2.0.0
|
|
26
|
+
Requires-Dist: pyodbc>=5.0.0
|
|
27
|
+
Requires-Dist: sqlparse>=0.5.0
|
|
28
|
+
Provides-Extra: azure
|
|
29
|
+
Requires-Dist: azure-identity>=1.15.0; extra == 'azure'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
32
|
+
Provides-Extra: test
|
|
33
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
|
|
34
|
+
Requires-Dist: pytest-docker>=3.0.0; extra == 'test'
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# MSSQL Agent MCP
|
|
39
|
+
|
|
40
|
+
A Model Context Protocol (MCP) server that provides tools for interacting with Microsoft SQL Server databases and managing SQL Server Agent Jobs.
|
|
41
|
+
Beyond basic database query functionality, this server supports managing stored procedures and SQL Server Agent jobs as code. Users can easily export, edit, and update these objects, and integrate them into version control systems.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
This MCP server provides the following tools:
|
|
46
|
+
|
|
47
|
+
### Database Tools
|
|
48
|
+
|
|
49
|
+
| Tool | Description |
|
|
50
|
+
|------|-------------|
|
|
51
|
+
| `query` | Execute SELECT queries and return results |
|
|
52
|
+
| `execute` | Execute INSERT, UPDATE, DELETE, CREATE statements |
|
|
53
|
+
| `list_tables` | List all tables in the database |
|
|
54
|
+
| `describe_table` | Get table schema including columns, types, and constraints |
|
|
55
|
+
| `list_databases` | List all databases on the server |
|
|
56
|
+
| `get_table_sample` | Get sample rows from a table |
|
|
57
|
+
| `get_table_indexes` | Get indexes defined on a table |
|
|
58
|
+
| `get_foreign_keys` | Get foreign key relationships |
|
|
59
|
+
|
|
60
|
+
### Stored Procedure Tools
|
|
61
|
+
|
|
62
|
+
| Tool | Description |
|
|
63
|
+
|------|-------------|
|
|
64
|
+
| `list_procedures` | List all stored procedures in the current database (optionally include definitions) |
|
|
65
|
+
| `list_all_procedures` | List all stored procedures across all databases on the server |
|
|
66
|
+
| `get_procedure_details` | Get detailed info about a procedure including its full definition |
|
|
67
|
+
| `get_procedure_parameters` | Get parameters for a specific stored procedure |
|
|
68
|
+
| `export_procedures_to_files` | Export procedures to SQL files with directory structure: `{db}/{schema}/{procedure}.sql` |
|
|
69
|
+
| `update_procedure_from_file` | Update a stored procedure from an edited SQL file |
|
|
70
|
+
|
|
71
|
+
### SQL Server Agent Job Tools
|
|
72
|
+
|
|
73
|
+
| Tool | Description |
|
|
74
|
+
|------|-------------|
|
|
75
|
+
| `list_agent_jobs` | List all SQL Server Agent jobs with status and category |
|
|
76
|
+
| `get_job_steps` | Get all steps for a specific job including commands and flow control |
|
|
77
|
+
| `get_job_details` | Get detailed settings and last run info for a job |
|
|
78
|
+
| `get_job_schedules` | Get schedule configurations for a job |
|
|
79
|
+
| `get_job_history` | Get execution history for a job |
|
|
80
|
+
| `export_enabled_jobs_to_files` | Export all enabled jobs and steps to SQL files |
|
|
81
|
+
| `update_job_step_from_file` | Update an existing job step from an edited SQL file |
|
|
82
|
+
| `create_job_step_from_file` | Create a new job step from a SQL file (auto-renames incorrectly named files) |
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## 🌟 What Makes This Different?
|
|
86
|
+
|
|
87
|
+
While there are several MSSQL MCP servers available, this one offers **unique capabilities** not found in others:
|
|
88
|
+
|
|
89
|
+
| Feature | Description | Why It Matters |
|
|
90
|
+
|---------|-------------|----------------|
|
|
91
|
+
| **SQL Server Agent Job Management** | Full CRUD operations for Agent jobs, steps, and schedules | Most MCP servers only handle database queries - this one lets you manage your entire automation infrastructure |
|
|
92
|
+
| **Jobs-as-Code Workflow** | Export enabled jobs to files, edit locally, push changes back | Enable Git version control for your SQL Agent jobs - track changes, review PRs, rollback easily |
|
|
93
|
+
| **Stored Procedures-as-Code** | Export/import stored procedures with metadata preservation | Manage procedures like application code with proper directory structure |
|
|
94
|
+
| **Smart File Naming** | Auto-renames files to `{step_id}_{step_name}.sql` format | Prevents conflicts and maintains consistency when creating new job steps |
|
|
95
|
+
| **Syntax Validation** | Uses `SET PARSEONLY` before applying changes | Catch SQL errors before they break your production jobs |
|
|
96
|
+
| **Metadata Headers** | Preserves job/procedure metadata in file comments | Never lose context about when something was created or modified |
|
|
97
|
+
| **Built with FastMCP** | Modern, decorator-based tool definitions | Cleaner code, automatic schema generation, better maintainability |
|
|
98
|
+
|
|
99
|
+
### Comparison with Other MSSQL MCP Servers
|
|
100
|
+
|
|
101
|
+
| Capability | This Server | Others |
|
|
102
|
+
|------------|:-----------:|:------:|
|
|
103
|
+
| Basic queries (SELECT, INSERT, UPDATE) | ✅ | ✅ |
|
|
104
|
+
| Schema inspection | ✅ | ✅ |
|
|
105
|
+
| SQL Server Agent job listing | ✅ | ❌ |
|
|
106
|
+
| Job step management | ✅ | ❌ |
|
|
107
|
+
| Job schedule viewing | ✅ | ❌ |
|
|
108
|
+
| Export jobs to files | ✅ | ❌ |
|
|
109
|
+
| Update jobs from files | ✅ | ❌ |
|
|
110
|
+
| Stored procedure export/import | ✅ | ❌ |
|
|
111
|
+
| Syntax pre-validation | ✅ | ❌ |
|
|
112
|
+
| FastMCP framework | ✅ | ❌ |
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## Stored Procedure Management
|
|
116
|
+
|
|
117
|
+
This MCP server provides a complete workflow for managing stored procedures as code:
|
|
118
|
+
|
|
119
|
+
### 1. Export Procedures to Files
|
|
120
|
+
|
|
121
|
+
Export all stored procedures from specified databases to a directory structure:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Use export_procedures_to_files with output_dir: "/path/to/procedures"
|
|
125
|
+
Optionally specify databases: ["materialdb", "salesdb"]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This creates:
|
|
129
|
+
```
|
|
130
|
+
procedures/
|
|
131
|
+
├── materialdb/
|
|
132
|
+
│ ├── dbo/
|
|
133
|
+
│ │ ├── usp_get_facility_info_data.sql
|
|
134
|
+
│ │ ├── usp_update_inventory.sql
|
|
135
|
+
│ │ └── usp_process_orders.sql
|
|
136
|
+
│ └── reporting/
|
|
137
|
+
│ └── usp_generate_report.sql
|
|
138
|
+
├── salesdb/
|
|
139
|
+
│ └── dbo/
|
|
140
|
+
│ └── usp_calculate_totals.sql
|
|
141
|
+
└── ...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**SQL files** contain:
|
|
145
|
+
- Metadata header (database, schema, procedure name, create/modify dates)
|
|
146
|
+
- Full procedure definition (CREATE PROCEDURE statement)
|
|
147
|
+
|
|
148
|
+
### 2. Edit and Update Procedures
|
|
149
|
+
|
|
150
|
+
After editing a SQL file, push changes to SQL Server:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Use update_procedure_from_file with file_path: "/path/to/procedures/materialdb/dbo/usp_get_facility_info_data.sql"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This tool:
|
|
157
|
+
1. Parses the file path to extract database, schema, and procedure name
|
|
158
|
+
2. Also reads metadata from header comments if present
|
|
159
|
+
3. Automatically converts `CREATE PROCEDURE` to `ALTER PROCEDURE`
|
|
160
|
+
4. Validates the procedure exists before updating
|
|
161
|
+
5. Executes the ALTER statement to update the procedure
|
|
162
|
+
|
|
163
|
+
### Example Procedure File
|
|
164
|
+
|
|
165
|
+
```sql
|
|
166
|
+
-- Database: materialdb
|
|
167
|
+
-- Schema: dbo
|
|
168
|
+
-- Procedure: usp_get_facility_info_data
|
|
169
|
+
-- Created: 2026-01-05 10:30:00
|
|
170
|
+
-- Modified: 2026-01-26 14:22:00
|
|
171
|
+
-- ============================================
|
|
172
|
+
|
|
173
|
+
CREATE PROCEDURE [dbo].[usp_get_facility_info_data]
|
|
174
|
+
AS
|
|
175
|
+
BEGIN
|
|
176
|
+
-- Your procedure logic here
|
|
177
|
+
SELECT * FROM facility_info
|
|
178
|
+
END
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## SQL Server Agent Job Management
|
|
182
|
+
|
|
183
|
+
This MCP server provides a complete workflow for managing SQL Server Agent jobs as code:
|
|
184
|
+
|
|
185
|
+
### 1. Export Jobs to Files
|
|
186
|
+
|
|
187
|
+
Export all enabled (non-deprecated) jobs to a directory structure:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
Use export_enabled_jobs_to_files with output_dir: "/path/to/agent_server_jobs"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
This creates:
|
|
194
|
+
```
|
|
195
|
+
agent_server_jobs/
|
|
196
|
+
├── Job_Name_1/
|
|
197
|
+
│ ├── job_info.json # Job metadata (schedules, description, etc.)
|
|
198
|
+
│ ├── 01_first_step.sql # Step 1 SQL command
|
|
199
|
+
│ ├── 02_second_step.sql # Step 2 SQL command
|
|
200
|
+
│ └── 03_third_step.sql # Step 3 SQL command
|
|
201
|
+
├── Job_Name_2/
|
|
202
|
+
│ ├── job_info.json
|
|
203
|
+
│ ├── 01_step_one.sql
|
|
204
|
+
│ └── 02_step_two.sql
|
|
205
|
+
└── ...
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**job_info.json** contains:
|
|
209
|
+
- Job ID, name, and description
|
|
210
|
+
- Enabled status and category
|
|
211
|
+
- Owner and notification settings
|
|
212
|
+
- Schedule configurations (frequency, intervals, active times)
|
|
213
|
+
- Creation and modification dates
|
|
214
|
+
|
|
215
|
+
**SQL files** contain:
|
|
216
|
+
- Metadata header with job name, step ID, step name, subsystem, and database
|
|
217
|
+
- The actual SQL command
|
|
218
|
+
|
|
219
|
+
### 2. Edit Existing Job Steps
|
|
220
|
+
|
|
221
|
+
After editing a SQL file, push changes to SQL Server:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
Use update_job_step_from_file with file_path: "/path/to/agent_server_jobs/Job_Name/02_step_name.sql"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
This tool:
|
|
228
|
+
1. Parses the file path to extract job name and step ID
|
|
229
|
+
2. Reads the SQL content (skipping metadata header)
|
|
230
|
+
3. Validates SQL syntax using `SET PARSEONLY`
|
|
231
|
+
4. Updates the job step in SQL Server using `sp_update_jobstep`
|
|
232
|
+
|
|
233
|
+
### 3. Create New Job Steps
|
|
234
|
+
|
|
235
|
+
Create a new step by adding a SQL file to a job directory:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
Use create_job_step_from_file with file_path: "/path/to/agent_server_jobs/Job_Name/my_new_step.sql"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This tool automatically:
|
|
242
|
+
1. **Validates/renames the file** - If filename doesn't match `{step_id}_{step_name}.sql` format, it:
|
|
243
|
+
- Scans existing SQL files in the folder to find used step IDs
|
|
244
|
+
- Queries the database for existing step IDs
|
|
245
|
+
- Determines the next available step ID
|
|
246
|
+
- Renames the file (e.g., `my_new_step.sql` → `03_my_new_step.sql`)
|
|
247
|
+
|
|
248
|
+
2. **Validates SQL syntax** - Checks for syntax errors before creating the step
|
|
249
|
+
|
|
250
|
+
3. **Creates the step** - Uses `sp_add_jobstep` to create the step in SQL Server
|
|
251
|
+
|
|
252
|
+
4. **Updates the file** - Adds proper metadata header to the SQL file
|
|
253
|
+
|
|
254
|
+
**Parameters:**
|
|
255
|
+
- `file_path` (required): Path to the SQL file
|
|
256
|
+
- `database_name` (optional): Target database for the step (defaults to 'master')
|
|
257
|
+
- `auto_rename` (optional): Auto-rename incorrectly named files (defaults to true)
|
|
258
|
+
|
|
259
|
+
### Filename Format
|
|
260
|
+
|
|
261
|
+
SQL files must follow this naming convention:
|
|
262
|
+
```
|
|
263
|
+
{step_id}_{step_name}.sql
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Examples:
|
|
267
|
+
- `01_truncate_tables.sql`
|
|
268
|
+
- `02_load_data.sql`
|
|
269
|
+
- `03_update_statistics.sql`
|
|
270
|
+
- `10_cleanup.sql`
|
|
271
|
+
|
|
272
|
+
The step_id determines the execution order in the job.
|
|
273
|
+
|
|
274
|
+
## Prerequisites
|
|
275
|
+
|
|
276
|
+
### ODBC Driver Installation
|
|
277
|
+
|
|
278
|
+
This package requires the Microsoft ODBC Driver for SQL Server. Install it based on your operating system:
|
|
279
|
+
|
|
280
|
+
**macOS:**
|
|
281
|
+
```bash
|
|
282
|
+
brew install unixodbc
|
|
283
|
+
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
|
|
284
|
+
brew install msodbcsql18 mssql-tools18
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Ubuntu/Debian:**
|
|
288
|
+
```bash
|
|
289
|
+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
|
290
|
+
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
|
|
291
|
+
sudo apt-get update
|
|
292
|
+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Windows:**
|
|
296
|
+
Download and install from [Microsoft ODBC Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server)
|
|
297
|
+
|
|
298
|
+
## Requirements
|
|
299
|
+
|
|
300
|
+
### Python Version
|
|
301
|
+
|
|
302
|
+
- **Requires**: Python **>=3.10**
|
|
303
|
+
|
|
304
|
+
### Core Dependencies
|
|
305
|
+
|
|
306
|
+
| Package | Version | Purpose |
|
|
307
|
+
|---------|---------|---------|
|
|
308
|
+
| `fastmcp` | >=2.0.0 | High-level MCP framework with automatic schema generation |
|
|
309
|
+
| `pyodbc` | >=5.0.0 | ODBC database connectivity for SQL Server |
|
|
310
|
+
| `sqlparse` | >=0.5.0 | SQL parsing and formatting |
|
|
311
|
+
|
|
312
|
+
> **Note**: This project uses [FastMCP](https://github.com/jlowin/fastmcp) for cleaner, more maintainable code. FastMCP provides automatic JSON schema generation from Python type hints and decorator-based tool definitions.
|
|
313
|
+
|
|
314
|
+
### Optional Dependencies
|
|
315
|
+
|
|
316
|
+
#### Azure Integration (`[azure]`)
|
|
317
|
+
| Package | Version | Purpose |
|
|
318
|
+
|---------|---------|---------|
|
|
319
|
+
| `azure-identity` | >=1.15.0 | Azure Active Directory authentication |
|
|
320
|
+
|
|
321
|
+
#### Development (`[dev]`)
|
|
322
|
+
| Package | Version | Purpose |
|
|
323
|
+
|---------|---------|---------|
|
|
324
|
+
| `ruff` | >=0.4.0 | Linting and formatting |
|
|
325
|
+
|
|
326
|
+
### Build System
|
|
327
|
+
|
|
328
|
+
- Uses **hatchling** as the build backend
|
|
329
|
+
|
|
330
|
+
## Installation
|
|
331
|
+
|
|
332
|
+
### Using pip
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
pip install mssql-agent-mcp
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### With Azure AD Authentication Support
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
pip install mssql-agent-mcp[azure]
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Development Installation
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
cd mssql-agent-mcp
|
|
348
|
+
pip install -e .
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Security Configuration
|
|
352
|
+
|
|
353
|
+
### Read-Only Mode (Default)
|
|
354
|
+
|
|
355
|
+
By default, **write operations are disabled** for safety. The server runs in read-only mode to prevent accidental data modification.
|
|
356
|
+
|
|
357
|
+
```env
|
|
358
|
+
# Default: Read-only mode enabled (safe for exploration)
|
|
359
|
+
MSSQL_READONLY=true
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**To enable write operations** (required for `execute`, `update_procedure_from_file`, `create_job_step_from_file`, etc.):
|
|
363
|
+
|
|
364
|
+
```env
|
|
365
|
+
# Enable write operations (use with caution)
|
|
366
|
+
MSSQL_READONLY=false
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Environment Variables
|
|
370
|
+
|
|
371
|
+
| Variable | Default | Description |
|
|
372
|
+
|----------|---------|-------------|
|
|
373
|
+
| `MSSQL_SERVER` | `localhost` | SQL Server hostname or IP |
|
|
374
|
+
| `MSSQL_DATABASE` | `master` | Default database |
|
|
375
|
+
| `MSSQL_USER` | *(empty)* | SQL Server username (for SQL auth) |
|
|
376
|
+
| `MSSQL_PASSWORD` | *(empty)* | SQL Server password (for SQL auth) |
|
|
377
|
+
| `MSSQL_PORT` | `1433` | SQL Server port |
|
|
378
|
+
| `MSSQL_DRIVER` | `ODBC Driver 18 for SQL Server` | ODBC driver name |
|
|
379
|
+
| `MSSQL_ENCRYPT` | `yes` | Connection encryption (`yes`/`no`) |
|
|
380
|
+
| `MSSQL_TRUST_SERVER_CERTIFICATE` | `no` | Trust self-signed certificates (`yes`/`no`) |
|
|
381
|
+
| `MSSQL_AUTH_MODE` | `sql` | Authentication mode: `sql`, `windows`, or `azure` |
|
|
382
|
+
| `MSSQL_READONLY` | `true` | Block write operations (`true`/`false`) |
|
|
383
|
+
|
|
384
|
+
### Authentication Modes
|
|
385
|
+
|
|
386
|
+
**SQL Server Authentication (default):**
|
|
387
|
+
```env
|
|
388
|
+
MSSQL_AUTH_MODE=sql
|
|
389
|
+
MSSQL_USER=your_username
|
|
390
|
+
MSSQL_PASSWORD=your_password
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Windows Authentication (Integrated Security):**
|
|
394
|
+
```env
|
|
395
|
+
MSSQL_AUTH_MODE=windows
|
|
396
|
+
# No username/password needed - uses current Windows credentials
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Azure AD Authentication:**
|
|
400
|
+
```bash
|
|
401
|
+
# Install with Azure support
|
|
402
|
+
pip install mssql-agent-mcp[azure]
|
|
403
|
+
```
|
|
404
|
+
```env
|
|
405
|
+
MSSQL_AUTH_MODE=azure
|
|
406
|
+
# Uses DefaultAzureCredential - supports managed identity, Azure CLI, etc.
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Cloud Connections (Azure SQL)
|
|
410
|
+
|
|
411
|
+
For Azure SQL Database, encryption is required:
|
|
412
|
+
|
|
413
|
+
```env
|
|
414
|
+
MSSQL_SERVER=your-server.database.windows.net
|
|
415
|
+
MSSQL_ENCRYPT=yes
|
|
416
|
+
MSSQL_TRUST_SERVER_CERTIFICATE=no
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## Configuration
|
|
420
|
+
|
|
421
|
+
Configure your database connection:
|
|
422
|
+
|
|
423
|
+
```env
|
|
424
|
+
MSSQL_SERVER=localhost
|
|
425
|
+
MSSQL_DATABASE=your_database
|
|
426
|
+
MSSQL_USER=your_username
|
|
427
|
+
MSSQL_PASSWORD=your_password
|
|
428
|
+
MSSQL_PORT=1433
|
|
429
|
+
MSSQL_READONLY=false # Enable write operations if needed
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Usage with Claude Desktop
|
|
433
|
+
|
|
434
|
+
Add to your Claude Desktop configuration file:
|
|
435
|
+
|
|
436
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
437
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
438
|
+
|
|
439
|
+
```json
|
|
440
|
+
{
|
|
441
|
+
"mcpServers": {
|
|
442
|
+
"mssql": {
|
|
443
|
+
"command": "python",
|
|
444
|
+
"args": ["-m", "mssql_mcp.server"],
|
|
445
|
+
"cwd": "/path/to/eagle_eye_sql_agent_job/mssql_db_mcp/src",
|
|
446
|
+
"env": {
|
|
447
|
+
"MSSQL_SERVER": "localhost",
|
|
448
|
+
"MSSQL_DATABASE": "your_database",
|
|
449
|
+
"MSSQL_USER": "your_username",
|
|
450
|
+
"MSSQL_PASSWORD": "your_password",
|
|
451
|
+
"MSSQL_PORT": "1433"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Or if installed as a package:
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"mcpServers": {
|
|
463
|
+
"mssql": {
|
|
464
|
+
"command": "mssql-agent-mcp",
|
|
465
|
+
"env": {
|
|
466
|
+
"MSSQL_SERVER": "localhost",
|
|
467
|
+
"MSSQL_DATABASE": "your_database",
|
|
468
|
+
"MSSQL_USER": "your_username",
|
|
469
|
+
"MSSQL_PASSWORD": "your_password"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## Usage with VS Code
|
|
477
|
+
|
|
478
|
+
Add to your VS Code MCP configuration (`.vscode/mcp.json`):
|
|
479
|
+
|
|
480
|
+
```json
|
|
481
|
+
{
|
|
482
|
+
"servers": {
|
|
483
|
+
"mssql": {
|
|
484
|
+
"command": "python",
|
|
485
|
+
"args": ["-m", "mssql_mcp.server"],
|
|
486
|
+
"cwd": "${workspaceFolder}/mssql_db_mcp/src",
|
|
487
|
+
"env": {
|
|
488
|
+
"MSSQL_SERVER": "localhost",
|
|
489
|
+
"MSSQL_DATABASE": "your_database",
|
|
490
|
+
"MSSQL_USER": "your_username",
|
|
491
|
+
"MSSQL_PASSWORD": "your_password"
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Example Tool Usage
|
|
499
|
+
|
|
500
|
+
### Database Operations
|
|
501
|
+
|
|
502
|
+
#### Query data
|
|
503
|
+
```
|
|
504
|
+
Use the query tool with: SELECT TOP 10 * FROM Customers
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### List tables
|
|
508
|
+
```
|
|
509
|
+
Use the list_tables tool to see all tables in the database
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
#### Describe a table
|
|
513
|
+
```
|
|
514
|
+
Use the describe_table tool with table: "Customers" to see its structure
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
#### Execute statements
|
|
518
|
+
```
|
|
519
|
+
Use the execute tool with: INSERT INTO Customers (Name) VALUES ('John Doe')
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Stored Procedure Operations
|
|
523
|
+
|
|
524
|
+
#### List all procedures in current database
|
|
525
|
+
```
|
|
526
|
+
Use list_procedures to see all stored procedures
|
|
527
|
+
Optionally set include_definition: true to include the full procedure code
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
#### List procedures across all databases
|
|
531
|
+
```
|
|
532
|
+
Use list_all_procedures to see procedures from all databases
|
|
533
|
+
Optionally set database_filter: "material" to filter by database name
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
#### Export procedures to files
|
|
537
|
+
```
|
|
538
|
+
Use export_procedures_to_files with output_dir: "/home/user/procedures"
|
|
539
|
+
Optionally specify databases: ["materialdb", "salesdb"]
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### Update a procedure after editing
|
|
543
|
+
```
|
|
544
|
+
Use update_procedure_from_file with file_path: "/home/user/procedures/materialdb/dbo/usp_get_data.sql"
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### SQL Server Agent Job Operations
|
|
548
|
+
|
|
549
|
+
#### List all agent jobs
|
|
550
|
+
```
|
|
551
|
+
Use list_agent_jobs to see all jobs with their status
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
#### Export jobs to files
|
|
555
|
+
```
|
|
556
|
+
Use export_enabled_jobs_to_files with output_dir: "/home/user/agent_jobs"
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
#### Update an existing step after editing
|
|
560
|
+
```
|
|
561
|
+
Use update_job_step_from_file with file_path: "/home/user/agent_jobs/Daily_Backup/02_backup_database.sql"
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
#### Create a new step (file will be auto-renamed)
|
|
565
|
+
```
|
|
566
|
+
# Create a file: /home/user/agent_jobs/Daily_Backup/new_cleanup_step.sql
|
|
567
|
+
# With content: DELETE FROM TempTable WHERE CreatedDate < DATEADD(day, -7, GETDATE())
|
|
568
|
+
|
|
569
|
+
Use create_job_step_from_file with file_path: "/home/user/agent_jobs/Daily_Backup/new_cleanup_step.sql"
|
|
570
|
+
|
|
571
|
+
# Result: File renamed to "03_new_cleanup_step.sql" and step created in SQL Server
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
## Development
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
# Install in development mode
|
|
578
|
+
pip install -e .
|
|
579
|
+
|
|
580
|
+
# Run the server directly
|
|
581
|
+
python -m mssql_mcp.server
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
## Requirements
|
|
585
|
+
|
|
586
|
+
- Python 3.10+
|
|
587
|
+
- Microsoft SQL Server (any supported version)
|
|
588
|
+
|
|
589
|
+
## License
|
|
590
|
+
|
|
591
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
mssql_agent_mcp/__init__.py,sha256=MfmrU93VrH_hW9q2jUMDS2ZAVlWCNgtsFU7EYmNv2zg,238
|
|
2
|
+
mssql_agent_mcp/__main__.py,sha256=_Er170jrffogRV4UfASEsoITnb4yNZW3Z9pSkQaE7YY,129
|
|
3
|
+
mssql_agent_mcp/config.py,sha256=tIAKUwrF40R6lZWpgoDyP2ueHcBIdcTdF2yKOLusLKY,1001
|
|
4
|
+
mssql_agent_mcp/server.py,sha256=jneped9wQ0Awp1VAB9n5da6ppfnJXajSgUXHS-WzX18,1992
|
|
5
|
+
mssql_agent_mcp/utils.py,sha256=HnQnOy2XZWmf-Huw__cvUdFcB8LVmBl9Vjos-tCejAU,4406
|
|
6
|
+
mssql_agent_mcp/tools/__init__.py,sha256=2qVsw2nYKa0KnbVQxBhwJVQ_chWyqHxqA62fyo1wGZU,1272
|
|
7
|
+
mssql_agent_mcp/tools/database.py,sha256=Rj1ESc88UOguc_-AxyqUtjoIqFgiLW8uZG0UgcfvRy4,7349
|
|
8
|
+
mssql_agent_mcp/tools/jobs.py,sha256=f-WsuWX_LsNNSQ9oLzD8ay-OYCrop-uMypksIwS-_tk,26699
|
|
9
|
+
mssql_agent_mcp/tools/procedures.py,sha256=WAPg2BKMiOBso4_H8tAE1f7wI8IiOID3vdHf3dh2MAk,14410
|
|
10
|
+
mssql_agent_mcp-1.0.0.dist-info/METADATA,sha256=LklUZR_77LCi9SjcbIkyaLtcG_qCoQlVVaU8Id3_Ch8,18443
|
|
11
|
+
mssql_agent_mcp-1.0.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
12
|
+
mssql_agent_mcp-1.0.0.dist-info/entry_points.txt,sha256=u6w8znCIeZxC6bnBRGqtbE4JTVZ822eX0bW2uF38MuU,64
|
|
13
|
+
mssql_agent_mcp-1.0.0.dist-info/licenses/LICENSE,sha256=JD9Y1eaSlUIIYz8SZDUVAa6pe7wH6aNF87PlbavycNI,1063
|
|
14
|
+
mssql_agent_mcp-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yyinhsu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|