{"_id":"@akrym1582/sqldb-mcp-server","_rev":"6-e623da0559007194bfb812e0472f5e15","name":"@akrym1582/sqldb-mcp-server","dist-tags":{"latest":"0.3.0"},"versions":{"0.0.3":{"name":"@akrym1582/sqldb-mcp-server","version":"0.0.3","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"author":{"name":"akrym1582"},"license":"MIT","_id":"@akrym1582/sqldb-mcp-server@0.0.3","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"homepage":"https://github.com/akryk7316/sqldb-mcp-server#readme","bugs":{"url":"https://github.com/akryk7316/sqldb-mcp-server/issues"},"bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"dist":{"shasum":"6782e00b3b40d55f8a56fc632667a1896710512f","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.0.3.tgz","fileCount":52,"integrity":"sha512-hHhaU//VcWhWhPU1/R5Bt1Yd4pkjKnIbQQql6gR6faUcyEU5lO7qlWeORWX4vor1XSGUcTZYE722MIIGKe60kw==","signatures":[{"sig":"MEUCIF9+jVeVU99agZUyeVTEctDwg3nd1RgyIrMr7vpPU8NlAiEA+oYr6HJ+92bRqJGQR2eFrO2KE66fxWN9dCORPOfkyGM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":118450},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","type":"commonjs","types":"./dist/mcp/server.d.ts","engines":{"node":">=18"},"gitHead":"4c6c6c0b89d4de6da5f61c91fd8a0681989d5132","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"},"repository":{"url":"git+https://github.com/akryk7316/sqldb-mcp-server.git","type":"git"},"_npmVersion":"10.8.2","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.3.0","ts-jest":"^29.4.6","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqldb-mcp-server_0.0.3_1774004964771_0.13787951047112057","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@akrym1582/sqldb-mcp-server","version":"0.0.4","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"author":{"name":"akrym1582"},"license":"MIT","_id":"@akrym1582/sqldb-mcp-server@0.0.4","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"dist":{"shasum":"ef49d15f85b0552e878b85ed8d7f6bfc87c64f08","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.0.4.tgz","fileCount":52,"integrity":"sha512-9AwYnw0HBxlLUhwB3uOJEqTk+2v5wsH6q4f9kzIo8pLVb211Mgq3BCwMgMdvwM06quVNF/wW4o6VYWr8eFmp+A==","signatures":[{"sig":"MEQCIHtubtxYJRr2kmhoeuaPT1wFBYewxIa8cWlDa7qicum3AiAiLFxiG86oKeanoMbYIU3muBccN34reM2aH0y5TgcJGg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":118450},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","type":"commonjs","types":"./dist/mcp/server.d.ts","engines":{"node":">=18"},"gitHead":"c5836bc2901b26a1f9c666be74c2ded1fb35b798","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"},"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"_npmVersion":"10.8.2","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.3.0","ts-jest":"^29.4.6","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqldb-mcp-server_0.0.4_1774008314092_0.7408261070728517","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@akrym1582/sqldb-mcp-server","version":"0.0.5","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"author":{"name":"akrym1582"},"license":"MIT","_id":"@akrym1582/sqldb-mcp-server@0.0.5","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"dist":{"shasum":"718e7e49b95c6741777cb8815d7f89d53d07dd66","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.0.5.tgz","fileCount":55,"integrity":"sha512-u3mjXz0OKq9aF2ewnl++lvMq8cihDoZvBKVHktC99PXHK3/oPjhq8KYLBEezEqhUBk4MfHNuAPtbvaDtmVJXDg==","signatures":[{"sig":"MEQCICdnR5rfXJxpEmMyoGEsFs21hp3k/+rzd7VYoM21vnK9AiATh+a/kjMjdUJ3OpGqKfupadDWKO3wTjiR9uyTHzDCeQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.0.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":127127},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","type":"commonjs","types":"./dist/mcp/server.d.ts","engines":{"node":">=18"},"gitHead":"700e7817def8055ddde38121cca578319ada181b","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"},"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"_npmVersion":"10.8.2","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"_nodeVersion":"20.20.1","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.3.0","ts-jest":"^29.4.6","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqldb-mcp-server_0.0.5_1774255920857_0.7951752611341343","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@akrym1582/sqldb-mcp-server","version":"0.1.0","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"author":{"name":"akrym1582"},"license":"MIT","_id":"@akrym1582/sqldb-mcp-server@0.1.0","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"dist":{"shasum":"ce4e20870cc72b190a52044ecca3e1058124e500","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.1.0.tgz","fileCount":58,"integrity":"sha512-5v/huaUev7vQhSwriA2AoPx5EQqlfBouYJhkQkEHUemT9IJxYFgu5xlQTIMJNPNDYIeetnjODnZkQCV8SXo4rg==","signatures":[{"sig":"MEUCIQDIbfueKFeg9xUBTdbn5Xq+0u79ecva6vISF1B5YsVOAAIgVq74waWjWlRVvCaTpMvZSBg2WmTIElqlPsyrJDFySP4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":140867},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","type":"commonjs","types":"./dist/mcp/server.d.ts","engines":{"node":">=18"},"gitHead":"39cd0dba92493ba8e543263e225d8aabd98d5095","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:20ca36e3-fa2c-4a13-b2c0-98cda3bc1d0d"}},"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"_npmVersion":"11.13.0","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"_nodeVersion":"24.17.0","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqldb-mcp-server_0.1.0_1782564944986_0.3146602599491264","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@akrym1582/sqldb-mcp-server","version":"0.1.1","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"author":{"name":"akrym1582"},"license":"MIT","_id":"@akrym1582/sqldb-mcp-server@0.1.1","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"dist":{"shasum":"d7a5e2391a0ab673752c60e3034be09450c334d5","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.1.1.tgz","fileCount":58,"integrity":"sha512-+guOJqMbBRXfjDgioUfrJ5gL1xcDXJv/74njcyyFjsOaxdAl4HYxpk+GHb5N1jug58sPwdIqq3umV0pr7DFK9g==","signatures":[{"sig":"MEUCIQDEvHkaCQJ0tyr/0GBqXA1ZzYgpRIIL9fjcoR0fYq3O7AIgf+SdRCIIStr+Bw3O23aYb3IL0bhMp0SNyhy5Mup62Lc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":140867},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","type":"commonjs","types":"./dist/mcp/server.d.ts","engines":{"node":">=18"},"gitHead":"cf4fb6c0c91cda06572b97704816930df01f29d2","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:20ca36e3-fa2c-4a13-b2c0-98cda3bc1d0d"}},"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"_npmVersion":"11.13.0","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"_nodeVersion":"24.17.0","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sqldb-mcp-server_0.1.1_1782565314773_0.5923023929716669","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"_id":"@akrym1582/sqldb-mcp-server@0.3.0","bin":{"sqldb-mcp-server":"dist/mcp/server.js"},"bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"dist":{"shasum":"717d32d37ed02c7395dc0899c1b0fa7d179c9c30","tarball":"https://registry.npmjs.org/@akrym1582/sqldb-mcp-server/-/sqldb-mcp-server-0.3.0.tgz","fileCount":64,"integrity":"sha512-pke/wZjqhgTa5GFeY6cI+OPGca3IKptnqMFpKqgRKd9lZ1d95jiHlVS5VENEvfG5jXQaq4UGtTMXdh0chSebcg==","signatures":[{"sig":"MEUCIF1BCK84gaGtcpMc/tvHN04vJW8F6WLBcM1hYZpaq+jWAiEA9LbK6EOvm5xnJF7S6zEREkSig4ohcgUNTBItGakvznA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHAvvc21d6OcudR19LWDig+8RhXJUs/cfLFjhCDuqOv8AiEAtIAdk8dUx8tWuDuGVsAiUO0bgbcXaZk+5KSRVGbHg+c="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@akrym1582%2fsqldb-mcp-server@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":162971},"jest":{"preset":"ts-jest","testMatch":["**/__tests__/**/*.test.ts"],"testEnvironment":"node","coverageDirectory":"coverage"},"main":"dist/mcp/server.js","name":"@akrym1582/sqldb-mcp-server","type":"commonjs","types":"./dist/mcp/server.d.ts","author":{"name":"akrym1582"},"engines":{"node":">=18"},"gitHead":"2fd6dadc346a291db184a833699b7dbb2b06ac0c","license":"MIT","scripts":{"dev":"ts-node src/mcp/server.ts","test":"jest --forceExit","build":"tsc","start":"node dist/mcp/server.js","prepublishOnly":"npm run build"},"version":"0.3.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:20ca36e3-fa2c-4a13-b2c0-98cda3bc1d0d"}},"homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"_npmVersion":"11.19.0","description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","directories":{},"maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"_nodeVersion":"24.21.0","dependencies":{"pg":"^8.20.0","zod":"^4.3.6","mssql":"^12.2.1","dotenv":"^17.3.1","mysql2":"^3.20.0","pg-cursor":"^2.19.0","node-sql-parser":"^5.4.0","@modelcontextprotocol/sdk":"^1.27.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","ts-node":"^10.9.2","@types/pg":"^8.18.0","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^25.5.0","@types/mssql":"^9.1.9","@types/pg-cursor":"^2.7.2","@types/node-sql-parser":"^1.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sqldb-mcp-server_0.3.0_1790330261569_0.4256211330565829"}}},"time":{"created":"2026-03-20T11:09:24.650Z","modified":"2026-09-25T09:57:42.068Z","0.0.3":"2026-03-20T11:09:24.914Z","0.0.4":"2026-03-20T12:05:14.223Z","0.0.5":"2026-03-23T08:52:01.013Z","0.1.0":"2026-06-27T12:55:45.119Z","0.1.1":"2026-06-27T13:01:54.906Z","0.3.0":"2026-09-25T09:57:41.654Z"},"bugs":{"url":"https://github.com/akrym1582/sqldb-mcp-server/issues"},"author":{"name":"akrym1582"},"license":"MIT","homepage":"https://github.com/akrym1582/sqldb-mcp-server#readme","keywords":["mcp","model-context-protocol","sql","mssql","postgresql","mysql","database","llm","ai"],"repository":{"url":"git+https://github.com/akrym1582/sqldb-mcp-server.git","type":"git"},"description":"MCP server for SQL database access (MSSQL, PostgreSQL, MySQL)","maintainers":[{"name":"akrym1582","email":"aki.ymnk+n1582@gmail.com"}],"readme":"# @akrym1582/sqldb-mcp-server\n\nA **read-only** [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that exposes SQL database access to LLMs.\n\n## Features\n\n- **Multi-database** – supports **MSSQL**, **PostgreSQL**, and **MySQL**\n- **Read-only** – only `SELECT` statements are allowed (enforced via AST-level SQL parsing with the correct dialect per DB type)\n- **LLM-optimised** – results use a compact columnar format (column list + value rows) to reduce token usage\n- **Pagination** – `skip` / `take` parameters with automatic cap at 100 rows\n- **Total-count aware** – every query result includes `meta.totalCount` so the LLM knows how many rows exist\n- **Caching** – query / schema results are cached with a configurable TTL\n- **File export** – stream query results to CSV or JSON files without a row-count limit\n- **Markdown evidence export** – save SQL and query results as a Markdown report file for test evidence\n- **Database selection** – allow exact database names and regular-expression matches, then select a database per tool call\n- **Seven MCP tools**: `listDatabases`, `query`, `listTables`, `describeTable`, `explainQuery`, `exportQuery`, `saveQueryEvidence`\n\n## Installation\n\n### From npm (recommended)\n\n```bash\n# Install globally\nnpm install -g @akrym1582/sqldb-mcp-server\n\n# Or run directly with npx (no install needed)\nnpx @akrym1582/sqldb-mcp-server\n```\n\n### From source\n\n```bash\ngit clone https://github.com/akrym1582/sqldb-mcp-server.git\ncd sqldb-mcp-server\nnpm install\nnpm run build\n```\n\n## Quick Start\n\n```bash\n# 1. Install globally\nnpm install -g @akrym1582/sqldb-mcp-server\n\n# 2. Configure environment variables (see below)\nexport DB_TYPE=postgresql\nexport DB_HOST=localhost\nexport DB_USER=myuser\nexport DB_PASSWORD=mypassword\nexport DB_NAME=mydb\n\n# 3. Run\nsqldb-mcp-server\n```\n\nOr use in your MCP client configuration (e.g. Claude Desktop `claude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"sqldb\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@akrym1582/sqldb-mcp-server\"],\n      \"env\": {\n        \"DB_TYPE\": \"postgresql\",\n        \"DB_HOST\": \"localhost\",\n        \"DB_PORT\": \"5432\",\n        \"DB_USER\": \"myuser\",\n        \"DB_PASSWORD\": \"mypassword\",\n        \"DB_NAME\": \"mydb\"\n      }\n    }\n  }\n}\n```\n\n## Environment Variables\n\n| Variable | Default | Description |\n|---|---|---|\n| `DB_TYPE` | `mssql` | Database type: `mssql`, `postgresql`, or `mysql` |\n| `DB_HOST` | – | Database server hostname |\n| `DB_PORT` | `1433` / `5432` / `3306` | Database server port (default depends on `DB_TYPE`) |\n| `DB_USER` | – | Database username |\n| `DB_PASSWORD` | – | Database password |\n| `DB_NAME` | – | Allowed databases: comma-separated exact names and/or JavaScript regex literals (for example `app,analytics,/^tenant_[0-9]+$/`) |\n| `DB_DEFAULT` | first allowed database | Default database when a tool call omits `database`; it must be allowed by `DB_NAME` |\n| `DB_ENCRYPT` | `true` for MSSQL/PostgreSQL, `false` for MySQL | Enables encrypted DB connections. MSSQL trusts the server certificate. PostgreSQL tries SSL first and falls back to plain if SSL is unavailable. MySQL uses TLS with certificate verification disabled when enabled. |\n| `DB_QUERY_TIMEOUT` | `30000` | Query timeout in milliseconds (used by `query` / `explainQuery`) |\n| `EXPORT_QUERY_TIMEOUT` | `300000` | Export query timeout in milliseconds (used by `exportQuery`; default 5 min) |\n| `CACHE_TTL` | `60` | Cache TTL in seconds |\n\n### Default ports by DB type\n\n| `DB_TYPE` | Default `DB_PORT` |\n|---|---|\n| `mssql` | `1433` |\n| `postgresql` | `5432` |\n| `mysql` | `3306` |\n\n## MCP Tools\n\nEvery database-aware tool accepts an optional `database` string. If omitted, `DB_DEFAULT` is used, or otherwise the first exact/matched database in `DB_NAME`. A requested database must match the configured allow-list; arbitrary database access is rejected.\n\nRegular-expression entries are resolved against databases visible to the configured user. When using regex-only PostgreSQL configuration, ensure the user has a connectable maintenance database (normally the database with the same name as the user); MSSQL and MySQL can enumerate databases without selecting one.\n\n### `listDatabases`\n\nList the databases available to the MCP tools and identify the current default:\n\n```json\n[\n  { \"name\": \"app\", \"isDefault\": true },\n  { \"name\": \"tenant_42\", \"isDefault\": false }\n]\n```\n\n### `query`\n\nExecute a `SELECT` SQL statement.\n\n```json\n{\n  \"sql\": \"SELECT id, name FROM users WHERE active = 1\",\n  \"database\": \"app\",\n  \"skip\": 0,\n  \"take\": 10\n}\n```\n\nResponse format (compact / token-efficient):\n```json\n{\n  \"meta\": { \"totalCount\": 42, \"returnedCount\": 10, \"skip\": 0, \"take\": 10 },\n  \"columns\": [\"id\", \"name\"],\n  \"rows\": [[1, \"Alice\"], [2, \"Bob\"], ...]\n}\n```\n\n### `listTables`\n\nList all base tables in a selected database. Pass `{ \"database\": \"app\" }`, or omit it to use the default.\n\n```json\n[{ \"schema\": \"dbo\", \"name\": \"users\" }, ...]\n```\n\n### `describeTable`\n\nDescribe a table's columns, indexes, foreign keys, check constraints, and size statistics.\n\n```json\n{ \"database\": \"app\", \"table\": \"dbo.users\" }\n```\n\n### `explainQuery`\n\nReturn the estimated execution plan for a SELECT query without executing it.\n\n```json\n{ \"database\": \"app\", \"sql\": \"SELECT * FROM orders WHERE status = 'open'\" }\n```\n\n### `exportQuery`\n\nStream a SELECT query result to a file.  Designed for large datasets – there is no row-count limit and results are written directly to disk using Node.js streams.\n\n```json\n{\n  \"sql\": \"SELECT * FROM large_table\",\n  \"database\": \"analytics\",\n  \"filepath\": \"/tmp/export.csv\",\n  \"format\": \"csv\",\n  \"options\": { \"delimiter\": \",\", \"bom\": false }\n}\n```\n\n`format` defaults to `\"csv\"` if omitted.  `\"json\"` is also supported.\n\n**CSV options** (all optional):\n\n| Option | Default | Description |\n|---|---|---|\n| `delimiter` | `\",\"` | Column separator |\n| `nullValue` | `\"\"` | String to write for `NULL` / `undefined` cells |\n| `bom` | `false` | Prepend UTF-8 BOM (useful for Excel) |\n\n**JSON options** (all optional):\n\n| Option | Default | Description |\n|---|---|---|\n| `pretty` | `false` | Indent the output JSON |\n\nResponse format:\n```json\n{\n  \"filepath\": \"/tmp/export.csv\",\n  \"format\": \"csv\",\n  \"rowCount\": 50000\n}\n```\n\nThe tool uses a separate, longer-lived connection pool whose `requestTimeout` is controlled by `EXPORT_QUERY_TIMEOUT` (default 300 000 ms = 5 min).  Increase this value for very large exports.\n \n### `saveQueryEvidence`\n \nExecute a SELECT query and save the SQL plus the returned rows as a Markdown report file for test evidence.\n \n```json\n{\n  \"sql\": \"SELECT id, name FROM users LIMIT 10\",\n  \"database\": \"app\",\n  \"filepath\": \"/tmp/query-evidence.md\"\n}\n```\n \nResponse format:\n```json\n{\n  \"filepath\": \"/tmp/query-evidence.md\",\n  \"rowCount\": 10,\n  \"previewRows\": [\n    { \"id\": 1, \"name\": \"Alice\" },\n    { \"id\": 2, \"name\": \"Bob\" }\n  ]\n}\n```\n \nIf an error occurs, the tool returns the error message text instead of a success payload.\n \n## Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/akrym1582/sqldb-mcp-server.git\ncd sqldb-mcp-server\n\n# Install dependencies\nnpm install\n\n# Configure environment\ncp .env.example .env\n# Edit .env with your DB credentials\n\n# Run in dev mode (no compile step)\nnpm run dev\n\n# Or build and run\nnpm run build\nnpm start\n\n# Run unit tests\nnpm test\n```\n\n## Project Structure\n\n```\nsrc/\n  mcp/\n    server.ts           # MCP server entry point\n    tools/\n      query.ts          # query tool\n      listTables.ts     # listTables tool\n      describeTable.ts  # describeTable tool\n      explainQuery.ts   # explainQuery tool\n      exportQuery.ts    # exportQuery tool (streaming file export)\n  db/\n    index.ts            # DB adapter factory (selects adapter from DB_TYPE)\n    types.ts            # DB interfaces (including queryStream)\n    adapters/\n      mssql.ts          # Microsoft SQL Server implementation\n      postgresql.ts     # PostgreSQL implementation (pg + pg-cursor)\n      mysql.ts          # MySQL implementation (mysql2)\n  utils/\n    row-result.ts       # Compact columnar result format\n    sanitize.ts         # AST-based SQL read-only validation (dialect-aware)\n    pagination.ts       # skip/take normalisation\n    cache.ts            # TTL in-memory cache\n    export-writer.ts    # Streaming CSV / JSON file writer\n  __tests__/            # Unit tests\n```\n","readmeFilename":"README.md"}