
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@tharanabopearachchi/sql-server-mcp
Advanced tools
MCP server for SQL Server database exploration and RAG capabilities (Windows with native ODBC support)
A Model Context Protocol (MCP) server for SQL Server that enables AI assistants like Claude to explore and query SQL Server databases. Designed specifically as a RAG (Retrieval-Augmented Generation) system for database knowledge, focusing on schema exploration and research queries.
NPM Package: @tharanabopearachchi/sql-server-mcp
MCP Registry: io.github.TharanaBope/sql-server-mcp
Zero Installation via npx:
npx @tharanabopearachchi/sql-server-mcp
Or install globally:
npm install -g @tharanabopearachchi/sql-server-mcp
For local development or modifications:
Prerequisites:
Steps:
Clone or download this repository
Install dependencies
cd sql-server-mcp
npm install
npm run build
.env.example to .env and customize:cp .env.example .env
Edit .env with your settings:
SQL_SERVER=localhost
SQL_DATABASE=master
SQL_PORT=1433
SQL_USE_WINDOWS_AUTH=true
QUERY_TIMEOUT=30
MAX_RESULT_ROWS=1000
Add to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"sql-server": {
"command": "node",
"args": ["D:\\path\\to\\sql-server-mcp\\dist\\index.js"],
"env": {
"SQL_SERVER": "localhost",
"SQL_DATABASE": "YourDatabase",
"SQL_USE_WINDOWS_AUTH": "true",
"SQL_PORT": "1433",
"QUERY_TIMEOUT": "30",
"MAX_RESULT_ROWS": "1000",
"ENABLE_SCHEMA_CACHE": "true",
"CACHE_TTL_MINUTES": "60"
}
}
}
}
{
"mcpServers": {
"sql-server": {
"command": "node",
"args": ["D:\\path\\to\\sql-server-mcp\\dist\\index.js"],
"env": {
"SQL_SERVER": "localhost",
"SQL_DATABASE": "YourDatabase",
"SQL_USE_WINDOWS_AUTH": "false",
"SQL_USERNAME": "your_username",
"SQL_PASSWORD": "your_password",
"SQL_PORT": "1433",
"QUERY_TIMEOUT": "30",
"MAX_RESULT_ROWS": "1000"
}
}
}
}
{
"mcpServers": {
"sql-server": {
"command": "node",
"args": ["D:\\path\\to\\sql-server-mcp\\dist\\index.js"],
"env": {
"SQL_SERVER": "localhost",
"SQL_DATABASE": "master",
"SQL_USE_WINDOWS_AUTH": "true",
"SQL_ALLOWED_DATABASES": "MyAppDB,MyTestDB,Analytics",
"QUERY_TIMEOUT": "30",
"MAX_RESULT_ROWS": "500"
}
}
}
}
| Variable | Description | Default | Required |
|---|---|---|---|
SQL_SERVER | SQL Server hostname or IP | localhost | Yes |
SQL_DATABASE | Default database to connect to | master | Yes |
SQL_PORT | SQL Server port | 1433 | No |
SQL_USE_WINDOWS_AUTH | Use Windows Authentication | true | Yes |
SQL_USERNAME | SQL Server username | - | If not using Windows Auth |
SQL_PASSWORD | SQL Server password | - | If not using Windows Auth |
SQL_ALLOWED_DATABASES | Comma-separated list of allowed databases | All | No |
QUERY_TIMEOUT | Query timeout in seconds | 30 | No |
MAX_RESULT_ROWS | Maximum rows to return | 1000 | No |
ENABLE_WRITE_OPERATIONS | Allow INSERT/UPDATE/DELETE | false | No |
ENABLE_SCHEMA_CACHE | Enable schema caching | true | No |
CACHE_TTL_MINUTES | Cache expiration time | 60 | No |
List all databases on the SQL Server instance.
Parameters:
includeSystem (boolean, optional) - Include system databasesExample:
List all databases on the server
List all tables in a specific database.
Parameters:
database (string, required) - Database nameExample:
List all tables in the MyAppDB database
Get detailed schema information about a table.
Parameters:
database (string, required) - Database nametableName (string, required) - Table name (can include schema, e.g., "dbo.Users")Example:
Describe the Users table in MyAppDB
Get foreign key relationships for a table.
Parameters:
database (string, required) - Database nametableName (string, required) - Table nameExample:
Show me the relationships for the Orders table
Search across tables, columns, views, and procedures.
Parameters:
database (string, required) - Database namesearchTerm (string, required) - Search keywordExample:
Search for "customer" in the database schema
Find all tables containing a specific column.
Parameters:
database (string, required) - Database namecolumnName (string, required) - Exact column nameExample:
Where is the CustomerID column used?
List all stored procedures in a database.
Parameters:
database (string, required) - Database nameGet the SQL definition of a stored procedure.
Parameters:
database (string, required) - Database nameprocedureName (string, required) - Procedure nameList all views in a database.
Parameters:
database (string, required) - Database nameGet high-level statistics about a database.
Parameters:
database (string, required) - Database nameExecute a read-only SELECT query.
Parameters:
database (string, required) - Database namequery (string, required) - SQL SELECT queryExample:
Execute: SELECT TOP 10 * FROM Users WHERE Active = 1
Get all tables directly related through foreign keys.
Parameters:
database (string, required) - Database nametableName (string, required) - Table name1. Understanding Database Structure
"What databases are available on this server?"
"Show me all tables in the SalesDB database"
"What's the structure of the Customers table?"
2. Finding Implementations
"Where is the OrderStatus field used across the database?"
"Search for any tables or columns related to 'invoice'"
"Find all stored procedures that mention 'payment'"
3. Analyzing Relationships
"How are the Orders and OrderDetails tables related?"
"Show me all tables that reference the Customers table"
"What tables are connected to the Products table?"
4. Data Exploration
"Execute: SELECT TOP 10 ProductName, UnitPrice FROM Products ORDER BY UnitPrice DESC"
"Get a summary of the database structure"
"Show me recent orders from the Orders table"
Problem: Cannot connect to SQL Server
Solutions:
Problem: Windows Authentication not working
Solutions:
SQL_USE_WINDOWS_AUTH=trueProblem: SQL Server Authentication not working
Solutions:
SQL_USE_WINDOWS_AUTH=falseSQL_USERNAME and SQL_PASSWORDProblem: Claude cannot see the MCP server tools
Solutions:
claude_desktop_config.json syntaxdist/index.js is correct (absolute path)npm run buildProblem: "Only SELECT queries are allowed"
Solution: This is intentional. The server is read-only by default. To enable write operations (not recommended), set ENABLE_WRITE_OPERATIONS=true
Problem: Query timeout
Solution: Increase QUERY_TIMEOUT or optimize the query
npm run build
npm run watch
sql-server-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── database/
│ │ ├── connection.ts # SQL Server connection pool
│ │ ├── queries.ts # SQL query templates
│ │ └── cache.ts # Schema caching layer
│ ├── tools/
│ │ ├── schema.ts # Schema exploration tools
│ │ ├── relationships.ts # Relationship mapping tools
│ │ ├── search.ts # Search & discovery tools
│ │ └── query.ts # Safe query execution
│ └── types/
│ └── index.ts # TypeScript interfaces
├── package.json
├── tsconfig.json
└── README.md
This implementation focuses on:
MIT
Contributions are welcome! Please feel free to submit issues or pull requests.
For issues or questions:
Built using:
FAQs
MCP server for SQL Server database exploration and RAG capabilities (Windows with native ODBC support)
We found that @tharanabopearachchi/sql-server-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.