SQL Server MCP Server
SQL Server MCP サーバー (Python)
Microsoft SQL Server データベースと統合するための Python 製 Model Context Protocol (MCP) サーバーです。
このサーバーは、スキーマ検査と CRUD (Create, Read, Update, Delete) 操作のための完全なツールに加え、データとスキーマをすばやく照会するための MCP リソースを提供します。
利用可能なツール
スキーマと検査
list_schemas(): データベース内のすべてのユーザースキーマを一覧表示します。list_tables(schema_name=None): データベース内のテーブルとビューを一覧表示し、スキーマでフィルタリングするオプションがあります。get_table_schema(table_name, schema_name="dbo"): テーブルの構造の詳細 (列、データ型、主キー、外部キー、ID) を返します。get_database_schema(schema_name=None, table_name=None): データベース全体またはフィルタリングされたスキーマを返します。
CRUD 操作
read_records(table_name, schema_name="dbo", columns=None, where_clause=None, params=None, order_by=None, limit=100, offset=0): カスタム列、パラメーター化されたWHEREフィルター、並べ替え、ページネーションを使用して、テーブルからレコードを照会します。read_query(sql_query, params=None): 位置パラメーター (?) をサポートするカスタム T-SQLSELECTクエリを実行します。insert_record(table_name, data, schema_name="dbo"): テーブルに単一のレコード (キーと値の辞書) を挿入します。bulk_insert_records(table_name, records, schema_name="dbo"): トランザクション内で複数のレコードを一括挿入します。update_records(table_name, data, where_clause, where_params=None, schema_name="dbo"): パラメーター化されたWHERE句に一致するレコードを更新します。delete_records(table_name, where_clause, params=None, schema_name="dbo"):WHERE句に一致するレコードを安全に削除します。execute_sql(sql_statement, params=None): 任意の DDL/DML コマンド (CREATE、ALTER、DROP、INSERT、UPDATE、DELETE) を実行します。
Related MCP server: SQL Server MCP
MCP リソース
sqlserver://schema: データベース全体のスキーマを JSON 形式で返します。sqlserver://tables: 利用可能なテーブルとビューの一覧を返します。
インストールと設定
1. 要件
Python >= 3.10
SQL Server ドライバー (
pyodbcと SQL Server 用 ODBC ドライバー、および純粋な Python 接続用のpymssqlをサポート)。
2. 環境設定 (.env)
プロジェクトのルートに .env ファイルを作成するか、環境変数を設定します:
SQLSERVER_HOST=localhost
SQLSERVER_PORT=1433
SQLSERVER_DATABASE=MeuBanco
SQLSERVER_USER=sa
SQLSERVER_PASSWORD=SuaSenha123!
SQLSERVER_DRIVER_TYPE=auto
SQLSERVER_TRUST_SERVER_CERTIFICATE=true3. インストール
python -m venv .venv
# Windows
.\.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate
pip install -e .MCP クライアントでの設定
mcp.json / クライアント設定の例
{
"mcpServers": {
"sql-server": {
"command": "python",
"args": [
"-m",
"sql_server_mcp.server"
],
"env": {
"SQLSERVER_HOST": "localhost",
"SQLSERVER_PORT": "1433",
"SQLSERVER_DATABASE": "MeuBanco",
"SQLSERVER_USER": "sa",
"SQLSERVER_PASSWORD": "SuaSenha123!",
"SQLSERVER_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}🐳 Docker と Makefile
Makefile を使用して、Docker でのビルドと実行を簡単に行うことができます:
# Compilar a imagem Docker
make build
# Executar o servidor MCP em container utilizando as variáveis do .env
make run
# Rodar os testes unitários dentro do container Docker
make docker-test
# Exibir ajuda dos comandos Makefile
make help🧪 テスト
アプリケーションの単体テストを実行するには:
pytestMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with Microsoft SQL Server instances using Windows or SQL Server authentication via native ODBC drivers. It allows users to execute SQL queries, list tables, and inspect schemas across multiple configured database environments through natural language.746MIT
- AlicenseBqualityDmaintenanceAn MCP server that connects AI assistants to Microsoft SQL Server databases, enabling schema exploration and read-only queries safely.49234MIT
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for SQL Server database operations, enabling CRUD operations, schema exploration, and stored procedure execution through natural language.8MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for Microsoft SQL Server enabling safe read-only queries, schema discovery, and natural-language query via LangChain.MIT
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Official Microsoft MCP Server to query Microsoft Entra data using natural language
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/Thiago-Fernandes-Dias/sql_server_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server