SQL MCP Server
SQL MCP サーバー (TypeScript)
このプロジェクトは、言語モデルやその他の MCP 互換クライアントが必要に応じて SSH 要塞トンネル経由で PostgreSQL データベースをクエリできるようにする Model Context Protocol (MCP) サーバーのTypeScript 実装を提供します。
柔軟性と安全なデータベースアクセスを実現するように構築されており、読み取り専用トランザクションで AWS RDS をサポートし、stdin/stdout ベースの通信を使用するため、ローカル、コンテナ化、または AI 駆動型のユースケースに適しています。
特徴
🔒 SSH トンネル経由でプライベート RDS インスタンスに安全にアクセスするための SSH 要塞サポート
🐘
pgライブラリを使用した PostgreSQL 読み取り専用クエリエンジン📡 STDIOベースのMCPプロトコルトランスポート
🧠メモリバンクMCPサーバーと互換性があります
⚙️
.envまたは環境変数で簡単に設定可能🧪 Jestとモックで完全にテスト可能
Related MCP server: Enhanced PostgreSQL MCP Server
インストール
リポジトリをクローンし、依存関係をインストールします。
git clone https://github.com/your-org/sql-mcp-server.git
cd sql-mcp-server
npm install
npm run build
Configuration (Optional .env file)
Create a .env file in the project root:
DB_USER=postgres
DB_PASS=yourpassword
DB_HOST=localhost
DB_PORT=5432
DB_NAME=mydatabase
USE_SSH_TUNNEL=true
SSH_BASTION_HOST=bastion.example.com
SSH_BASTION_USER=ec2-user
SSH_PRIVATE_KEY_PATH=~/.ssh/id_rsa
Usage
Run the server using npx:
npx -y @modelcontextprotocol/server-postgres postgresql://<user>:<pass>@localhost:5433/<dbname>
For direct connection without SSH tunneling, set the appropriate environment variables:
DB_HOST=rds-host.amazonaws.com DB_PORT=5432 npx -y @modelcontextprotocol/server-postgres postgresql://<user>:<pass>@rds-host.amazonaws.com/<dbname>
Sample Input
{
"type": "call_tool",
"params": {
"name": "query",
"arguments": {
"sql": "SELECT * FROM users LIMIT 10"
}
}
}
Sample Output
{
"content": [
{
"type": "text",
"text": "[{\"id\":1,\"name\":\"Alice\"}]"
}
],
"isError": false
}
⸻
Related Docs
• Architecture
• Domain Models
• Glossary
• Coding Standards
• Tech Stack
• User Guide
⸻
License
MIT
⸻
Contribution Guide
We welcome community contributions! Please see CONTRIBUTING.md for details.
⸻
Compatibility
This implementation follows the Model Context Protocol (MCP) and has been tested for compatibility with:
• memory-bank-mcp-server
• Claude Desktop (via STDIO)
• Cursor IDE
• Supabase + MCP integration
This server cannot be deployed
Maintenance
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
A Model Context Protocol server for Wix AI tools
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.122,323 npm27MIT
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.305 npm10MIT
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol server providing dual transport (HTTP and Stdio) access to PostgreSQL databases, allowing AI assistants to query databases and fetch schema information through natural language.47 npm31MIT
- AlicenseBqualityDmaintenanceA TypeScript-based Model Context Protocol server that enables AI assistants to perform secure database operations on PostgreSQL databases through structured tool interfaces.816 npmMIT