SQL Query Tools MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SQL Query Tools MCP Servershow me the schema of the Orders table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SQL Query Tools β MCP Server
MCP (Model Context Protocol) server for connecting to SQL Server in readonly mode. Allows any MCP client (Claude Desktop, GEAI, Cursor, etc.) to explore the schema and run SELECT queries against a SQL Server database.
π VersiΓ³n en espaΓ±ol
Installation
1. Install dependencies
Open a terminal inside the project folder and run:
npm install2. Configure the connection
The .env file is already included with the variables ready. Fill it in with your server details:
# Connection
SQL_SERVER=my_server
SQL_DATABASE=MyDatabase
SQL_USER=my_user
SQL_PASSWORD=my_password
SQL_INSTANCE= # leave empty if not using a named instance
SQL_ENCRYPT=false # set to true for Azure SQL or cloud servers
SQL_TRUST_SERVER_CERT=true
# Security / filters
ALLOWED_TABLES= # leave empty to expose all tables (supports wildcards: dbo.prefix_*)
MAX_ROWS=200 # maximum rows returned per query
# Performance
SQL_QUERY_TIMEOUT=30000 # query timeout in milliseconds (default: 30s)
SCHEMA_CACHE_TTL_MINUTES=5 # how long to cache schema results in memory (default: 5 min)
# Audit log
AUDIT_LOG=false # set to true to enable audit logging
AUDIT_LOG_DIR=./logs # folder where daily log files are writtenIf
SQL_ENCRYPTistrue(cloud servers), make sure to also setSQL_TRUST_SERVER_CERT=true.
3. Verify the connection
npm run test-connectionYou should see β
Connection successful! along with the SQL Server version and available tables.
4. Verify the MCP server starts
node mcp-server.jsYou should see β
MCP server connected and ready. Close it with Ctrl+C β the MCP client starts it automatically when needed.
Related MCP server: sql-explorer-mcp
Connect from your MCP client
Claude Desktop
Open the Claude Desktop configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonMac:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the
sql-query-toolsblock insidemcpServers(replace the path):
{
"mcpServers": {
"sql-query-tools": {
"command": "node",
"args": ["ABSOLUTE_PATH/SQLQueryTools/mcp-server.js"]
}
}
}Restart Claude Desktop from the system tray (right-click β Quit, then reopen).
Verify the tools icon (π§) appears in the chat β clicking it should show the
db_*tools.
GEAI or other clients
Point the client to the mcp-sql-config.json file included in this folder, or configure it manually with the absolute path to mcp-server.js. Credentials are read from .env automatically.
Cursor
Open Settings β MCP.
Add the same JSON block from above.
Restart Cursor.
Available tools
Tool | Description |
| Tests the connection and returns server version and current datetime |
| Lists all tables and views with their column count (result is cached) |
| Returns column details (name, type, nullable) for a specific table or view |
| Returns 5 sample rows from a table β useful for the agent to understand the data |
| Executes a SELECT query (auto-injects TOP if no row limit is present) |
| Returns info about the currently connected database |
Configuration reference
Security β ALLOWED_TABLES
Controls which tables and views are accessible. Leave empty to expose everything.
ALLOWED_TABLES=dbo.Orders,dbo.Customers,dbo.Invoice_*Wildcards are supported at the end of the name (dbo.prefix_*). The filter applies to db_describe_schema, db_describe_table, and db_run_readonly.
Row limit β MAX_ROWS
Maximum number of rows returned by any SELECT query. The server automatically injects TOP N if the query doesn't include a limit.
MAX_ROWS=200Query timeout β SQL_QUERY_TIMEOUT
If a query takes longer than this value (in milliseconds), it is automatically cancelled. Prevents slow or heavy queries from blocking the server.
SQL_QUERY_TIMEOUT=30000 # 30 secondsSchema cache β SCHEMA_CACHE_TTL_MINUTES
db_describe_schema results are cached in memory to avoid repeated database roundtrips. After the TTL expires, the next call refreshes the cache.
SCHEMA_CACHE_TTL_MINUTES=5 # cache lasts 5 minutesSet to 0 to disable caching (always queries the database).
Audit log β AUDIT_LOG
When enabled, every tool call is recorded in a daily log file inside AUDIT_LOG_DIR. Each entry includes the timestamp, tool name, query or table, result, and execution time.
AUDIT_LOG=true
AUDIT_LOG_DIR=./logsLog format:
[2026-03-27T14:32:11Z] db_run_readonly | SELECT TOP 10 * FROM dbo.Orders | rows:10 | 45ms
[2026-03-27T14:32:20Z] db_run_readonly | SELECT * FROM dbo.Users | BLOCKED: table not allowed | 0msA new file is created each day: logs/audit-YYYY-MM-DD.log. Blocked queries are also logged.
Usage
Once the MCP is active, you can ask questions in natural language about your database. The agent will use the tools automatically to explore the schema and respond.
Test scripts
npm run test-connection # verify connectivity and list available tables
npm run test-schema # list all tables and views with column counts
node tests/test-table.js dbo.Employees # describe columns of a specific tableSecurity
Only
SELECTqueries are allowed. Blocked keywords:DROP,DELETE,UPDATE,INSERT,ALTER,TRUNCATE,CREATE,EXEC,EXECUTE,WAITFOR,XP_,SP_.SQL comments (
--and/* */) are stripped before validation.Tabs and newlines are normalized to prevent whitespace bypass attempts.
Multiple statements (
;) are not allowed.SELECT TOP Nis automatically injected if no row limit is present.ALLOWED_TABLESacts as a table whitelist (supports*wildcards), enforced indb_describe_schema,db_describe_tableanddb_run_readonly.
Tested attack vectors
Category | Examples | Result |
Direct writes |
| β Blocked |
Multiple statements |
| β Blocked |
System procedures |
| β Blocked |
DoS |
| β Blocked |
Whitespace bypass | tabs and newlines between keywords | β Blocked |
Comment bypass |
| β Blocked |
Valid queries |
| β Allowed |
Project structure
SQLQueryTools/
βββ mcp-server.js # Main MCP server
βββ mcp-sql-config.json # Reference MCP config for the client
βββ .env # Environment variables (do not version)
βββ env.example # Environment variables template
βββ package.json
βββ package-lock.json
βββ README.md # English documentation
βββ README.es.md # Spanish documentation
βββ tests/
βββ test-connection.js
βββ test-schema.js
βββ test-table.js # Usage: node tests/test-table.js dbo.Employees
βββ test-examples.jsTroubleshooting
Connection error:
Check that
SQL_SERVER,SQL_USERandSQL_PASSWORDin.envare correct.For cloud servers, try setting
SQL_ENCRYPT=true.If using a named instance, set
SQL_INSTANCE(e.g.SQLEXPRESS).Confirm that port 1433 is accessible from your network.
No tables shown in db_describe_schema:
Check
ALLOWED_TABLESin.env. If empty, all tables are shown; if set, verify the names/prefixes match.
MCP not appearing in Claude:
Verify the path in the config points correctly to
mcp-server.js.Restart Claude Desktop after any config change.
Check logs: Claude Desktop β Help β Open Logs Folder.
Author
--Pablon-- β github.com/negrip
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/negrip/mcp-sqlserver-readonly'
If you have feedback or need assistance with the MCP directory API, please join our Discord server