{"_id":"@atom8n/mcp-mssql","_rev":"2-9ec2f3e7315a24f391250b104510f46e","name":"@atom8n/mcp-mssql","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@atom8n/mcp-mssql","version":"1.0.0","license":"MIT","_id":"@atom8n/mcp-mssql@1.0.0","maintainers":[{"name":"atom8n","email":"atom8n@gmail.com"}],"bin":{"mcp-mssql-atom":"lib/index.mjs"},"dist":{"shasum":"6897f3436e33fdb34c2a5e048fb9b9c82bfdbaf2","tarball":"https://registry.npmjs.org/@atom8n/mcp-mssql/-/mcp-mssql-1.0.0.tgz","fileCount":20,"integrity":"sha512-F/kcFRAZLv2y3pLFVD7jaUt0unh8Nb1sVO4sVBFH4mfB7rAF4l+ZHivgGqs7ksNzrpvNlidZQSE/cQ6uzD+TTA==","signatures":[{"sig":"MEYCIQC5dl+1XdGURnmC9WNXiKZdjBvsCvYRIYBa3Gh/Vj8pugIhAOBP/+ysVE1tzAUoMZovxKqUvIx7E6B1fKJsUpl+Pgc7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37662},"main":"index.js","volta":{"npm":"10.9.2","node":"20.19.5","yarn":"1.19.2"},"gitHead":"a15b457bfcb4cf8cfab4f36eafc0ec5b5f8c7f11","scripts":{"inspect":"tsc && npx -y @modelcontextprotocol/inspector node ./lib/index.mjs","prepare":"tsc && shx chmod +x ./lib/index.mjs","test:sql":"tsc && node --loader ts-node/esm src/execute_sql.test.mts"},"_npmUser":{"name":"atom8n","email":"atom8n@gmail.com"},"_npmVersion":"10.9.2","description":"An MCP server for executing queries against Microsoft SQL Server","directories":{},"_nodeVersion":"20.19.5","dependencies":{"dotenv":"^16.4.5","rimraf":"^6.0.1","spawn-rx":"^4.0.0","msnodesqlv8":"^3.1.0","@modelcontextprotocol/sdk":"^1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","ts-node":"^10.9.2","typescript":"^5.6.3","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mcp-mssql_1.0.0_1763398344886_0.1990940563254815","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-11-17T16:52:24.821Z","modified":"2026-01-12T18:06:45.661Z","1.0.0":"2025-11-17T16:52:25.067Z"},"license":"MIT","description":"An MCP server for executing queries against Microsoft SQL Server","maintainers":[{"email":"atom8n@gmail.com","name":"atom8n-user"}],"readme":"# MCP Mssql Server\r\n\r\nAn MCP server that exposes a single `execute_sql` tool for running parameterless SQL statements against Microsoft SQL Server using the native `msnodesqlv8` driver. It is intended for MCP-compatible clients that need direct database access over stdio without exposing credentials in logs.\r\n\r\n## Features\r\n\r\n- **SQL Server Native Driver**: Uses `msnodesqlv8` and ensures an explicit driver prefix on every connection string.\r\n- **Secure Logging**: Masks password fields when echoing the effective connection string to stderr.\r\n- **Flexible Connection Sources**: Pulls the connection string from `MSSQL_CONNECTION_STRING` or an override supplied with each request.\r\n- **Structured Results**: Returns `rowsAffected` counts and all recordsets from the query for easy downstream parsing.\r\n- **Stdio Transport**: Ships as an MCP stdio server so it can be dropped into any MCP client configuration.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @atom8n/mcp-mssql\r\n```\r\n\r\n## MCP Configuration\r\n\r\nAdd the following configuration to your MCP client:\r\n\r\n```json\r\n{\r\n  \"mcp-mssql\": {\r\n    \"command\": \"npx\",\r\n    \"args\": [\r\n      \"@atom8n/mcp-mssql\"\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\n## Available Tools\r\n\r\n### execute_sql\r\nExecute a SQL statement against Microsoft SQL Server.\r\n\r\n**Parameters:**\r\n- `query` (required): T-SQL command text to execute.\r\n- `connectionString` (optional): Overrides the `MSSQL_CONNECTION_STRING` environment variable for this call.\r\n\r\nThe tool automatically injects `Driver={SQL Server Native Client 11.0}` when the provided connection string omits a driver segment, so both DSN-style and bare connection strings work out of the box.\r\n\r\n## Usage Examples\r\n\r\n### Run a query with the default connection string\r\n```json\r\n{\r\n  \"tool\": \"execute_sql\",\r\n  \"arguments\": {\r\n    \"query\": \"SELECT TOP (5) name FROM sys.databases ORDER BY name\"\r\n  }\r\n}\r\n```\r\n\r\n### Override the connection string per call\r\n```json\r\n{\r\n  \"tool\": \"execute_sql\",\r\n  \"arguments\": {\r\n    \"query\": \"EXEC dbo.RefreshMaterializedView @name = 'daily_snapshot'\",\r\n    \"connectionString\": \"Server=sql.internal;Database=Ops;Trusted_Connection=yes;\"\r\n  }\r\n}\r\n```\r\n\r\n## Response Format\r\n\r\nRequests return JSON text via MCP content with the following shape:\r\n\r\n```\r\n{\r\n  \"rowsAffected\": [123],\r\n  \"recordsets\": [\r\n    [\r\n      { \"name\": \"master\" },\r\n      { \"name\": \"model\" }\r\n    ]\r\n  ]\r\n}\r\n```\r\n\r\n## Development\r\n\r\n### Prerequisites\r\n- Node.js 18+\r\n- TypeScript 5.6+\r\n- npm\r\n\r\n### Setup\r\n```bash\r\n# Clone the repository\r\ngit clone <repository-url>\r\ncd mcp-mssql\r\n\r\n# Install dependencies\r\nnpm install\r\n\r\n# Build the project\r\nnpm run prepare\r\n```\r\n\r\n### Project Structure\r\n```\r\n├── src/\r\n│   ├── index.mts          # MCP server implementation\r\n│   └── execute_sql.test.mts # Ad-hoc SQL runner for local verification\r\n├── lib/\r\n│   ├── index.mjs          # Compiled JavaScript\r\n│   ├── index.mjs.map      # Source map\r\n│   └── index.d.mts        # TypeScript declarations\r\n├── package.json           # Package configuration\r\n├── tsconfig.json          # TypeScript configuration\r\n└── eslint.config.mjs      # ESLint configuration\r\n```\r\n\r\n### Build Process\r\nThe project uses TypeScript with the following build configuration:\r\n- **Target**: ES2015\r\n- **Module**: CommonJS\r\n- **Output**: `lib/` directory\r\n- **Source Maps**: Enabled\r\n- **Declarations**: Generated\r\n\r\n### Scripts\r\n- `prepare`: Compiles TypeScript and makes the binary executable\r\n- `inspect`: Launches the MCP inspector against the compiled server\r\n- `test:sql`: Runs `src/execute_sql.test.mts` with ts-node for manual checks\r\n\r\n## Dependencies\r\n\r\n### Runtime Dependencies\r\n- `@modelcontextprotocol/sdk`: MCP server framework\r\n- `dotenv`: Environment variable loader\r\n- `msnodesqlv8`: Native SQL Server driver\r\n- `rimraf`: File system utilities\r\n- `spawn-rx`: Process spawning utilities\r\n\r\n### Development Dependencies\r\n- `@types/node`: Node.js type definitions\r\n- `shx`: Shell utilities for cross-platform compatibility\r\n- `ts-node`: TypeScript execution\r\n- `typescript`: TypeScript compiler\r\n\r\n## License\r\n\r\nMIT License - see [COPYING](COPYING) file for details.\r\n\r\n## Contributing\r\n\r\nPlease read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for our code of conduct and contribution guidelines.\r\n\r\n## Version\r\n\r\nCurrent version: 1.0.0\r\n\r\n## Support\r\n\r\nFor issues and feature requests, please use the project's issue tracker.\r\n","readmeFilename":"README.md"}