home / mcp / pymssql-mcp mcp server
Provides an MCP server that enables AI assistants to query and manage SQL Server data with safety controls.
Configuration
View docs{
"mcpServers": {
"bpamiri-pymssql-mcp": {
"command": "pymssql-mcp",
"args": [
"--http",
"--host",
"0.0.0.0",
"--port",
"8080"
],
"env": {
"MSSQL_HOST": "your-server.example.com",
"MSSQL_USER": "your-username",
"MSSQL_DATABASE": "your-database",
"MSSQL_PASSWORD": "your-password",
"MSSQL_READ_ONLY": "true"
}
}
}
}You run an MCP server that lets an AI assistant interact with your Microsoft SQL Server databases through a standardized, safe interface. This enables natural language queries, schema discovery, CRUD operations, stored procedures, and more, all while giving you control over safety and access.
You will run the MCP server locally or as a shared HTTP service, then connect your AI assistant client to it. Start by configuring the MCP server with your SQL Server connection details, including host, user, password, and database. You can run the server in HTTP mode to serve multiple users or use the standard local mode for development and Claude integration.
pip install pymssql-mcpNext, start the MCP server. For a local/development setup, run the MCP process directly. For HTTP access, expose the server on your network.
Configure your client (Claude Desktop or your MCP client) to point to the MCP server. Provide the SQL Server connection details as environment variables in the client configuration so the MCP server can connect on your behalf.
MSSQL_HOST=your-server.example.com
MSSQL_USER=your-username
MSSQL_PASSWORD=your-password
MSSQL_DATABASE=your-database
MSSQL_READ_ONLY=trueLocal development mode runs the MCP server as a local process. To enable an HTTP server that can handle multiple users, start the server with HTTP options. To enable a streamable HTTP endpoint suitable for Claude.ai integration with SSO, use the streamable HTTP option.
pymssql-mcp --http --host 0.0.0.0 --port 8080
```
```
pymssql-mcp --streamable-http --host 0.0.0.0 --port 8080The MCP server uses a set of environment variables to control connectivity, safety, and behavior. You typically provide these in the environment where the MCP server runs or in the client configuration that connects to it.
Safety features help prevent accidental data exposure or modification. Use read-only mode, block unsafe commands, and apply schema or database restrictions as needed. Always validate queries before execution and prefer parameterized queries to defend against injection.
If the server cannot reach SQL Server, verify network access, credentials, and that the target database is reachable from the MCP host. Check that the MCP server process is running and listening on the expected port. Review environment variables for correctness.
This MCP server provides a comprehensive interface to SQL Server, including schema discovery, CRUD operations, and transaction management, with safety controls and knowledge persistence to help Claude remember learned insights about your data.
Establish a connection to the SQL Server database.
Close all active connections to the database.
List available databases on the server.
Switch the active database context.
Run a SELECT query and return results.
Check if a query is safe to execute.
List tables and views in the current database.
Retrieve column information for a table.
Read rows by ID or filter criteria.
Insert a new row into a table.
Update an existing row.
Delete a row from a table.
List available stored procedures.
Get parameters for a stored procedure.
Execute a stored procedure with parameters.
Export query results to JSON.
Export query results to CSV.
Start a database transaction.
Commit the current transaction.
Rollback the current transaction.
Persist learned knowledge about the database.
Retrieve all persisted knowledge.
Search saved database knowledge.