SQL-Server-MCP

by ranjithr99

1 stars
333 downloads
Not rated
GitHub

Description

## SQL Server MCP (Model Context Protocol) Server A lightweight MCP stdio server that connects to Microsoft SQL Server using provided credentials and exposes tools to query and discover schema. ### Features - **connect**: Connect by `server`, `port`, `user`, `password`, optional…

About

## SQL Server MCP (Model Context Protocol) Server A lightweight MCP stdio server that connects to Microsoft SQL Server using provided credentials and exposes tools to query and discover schema. ### Features - **connect**: Connect by `server`, `port`, `user`, `password`, optional `database`, `encrypt`. -…

Details

Author
ranjithr99
GitHub stars
1
Downloads
333
Categories
Database

- Connects to Microsoft SQL Server via MCP stdio.
- Exposes tools: connect, disconnect, query, info.
- Lists databases, schemas, and tables.
- Executes arbitrary SQL queries securely.
- Credentials provided at call-time, not stored.
- Built with TypeScript, MIT licensed.

Install Node.js >= 18, then run npm install and npm run build to build the server. Start it with npm start. The server communicates over stdio and must be driven by an MCP client. Use the connect tool first with SQL Server credentials, then use other tools like query, info, or list_* tools.

SQL Server MCP (Model Context Protocol) Server

A lightweight MCP stdio server that connects to Microsoft SQL Server using provided credentials and exposes tools to query and discover schema.

Features

- connect: Connect by server, port, user, password, optional database, encrypt. - disconnect: Close the pool. - info: Return @@VERSION. - query: Execute arbitrary SQL and return recordset. - list_databases: List databases. - list_schemas: List schemas. - list_tables: List tables, with optional schema filter.

Quickstart

- Node.js >= 18 - Install deps and build:
  npm install
  npm run build
  
- Run as an MCP stdio server (for MCP-compatible clients):
  npm start
  

The server starts over stdio and waits to be driven by an MCP client (e.g., Claude Desktop or other MCP-aware tooling). Use the tools in this order:
1) connect with your SQL Server credentials
2) info, list_, or query

MCP Tools and Schemas

- connect args:
  {
    "server": "host or host\\\u005Cinstance",
    "port": 1433,
    "user": "sa",
    "password": "<secret>",
    "database": "master",
    "encrypt": true
  }
  
- query args:
  { "sql": "SELECT TOP 1  FROM sys.databases" }
  { "sql": "SELECT  FROM INFORMATION_SCHEMA.TABLES" }
  
- Other tools take no args or optional schema.

Security

- Credentials are provided at call-time and are not stored. Prefer secure MCP clients and environments. TLS encrypt defaults to true.

Development

- Scripts: - npm run dev to run with ts-node - npm run build to emit JS to dist/ - npm start to run built server (dist/server.js)

Commits

- chore: init project scaffolding with TypeScript, tsconfig, and deps - feat: implement MCP stdio server with SQL Server tools (connect, query, info, list_
) - docs: add execution plan outline and usage notes

License

MIT
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.