Skip to main content
Glama

SQL MCP Server

by t3ta

SQL MCP 服务器 (TypeScript)

该项目提供了模型上下文协议 (MCP) 服务器的TypeScript 实现,使语言模型和其他与 MCP 兼容的客户端能够在需要时通过 SSH 堡垒隧道查询 PostgreSQL 数据库。

它专为灵活性和安全的数据库访问而构建,支持具有只读事务的 AWS RDS,并使用基于 stdin/stdout 的通信,使其适用于本地、容器化或 AI 驱动的用例。

特征

  • 🔒 SSH 堡垒支持通过 SSH 隧道安全访问私有 RDS 实例
  • 🐘 使用pg库的 PostgreSQL 只读查询引擎
  • 📡 基于 STDIO 的 MCP 协议传输
  • 🧠 与memory-bank-mcp-server兼容
  • ⚙️ 可通过.env或环境变量轻松配置
  • 🧪 完全可以使用 Jest 和 mocks 进行测试

安装

克隆存储库并安装依赖项:

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
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

模型上下文协议服务器的 TypeScript 实现,使语言模型能够安全地查询 PostgreSQL 数据库,包括 SSH 堡垒隧道后面的数据库。

  1. 特征
    1. 安装

      Related MCP Servers

      • -
        security
        A
        license
        -
        quality
        A Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.
        Last updated -
        16,948
        17
        JavaScript
        MIT License
        • Apple
      • -
        security
        A
        license
        -
        quality
        A Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.
        Last updated -
        355
        46
        TypeScript
        AGPL 3.0
        • Linux
        • Apple
      • -
        security
        F
        license
        -
        quality
        A Model Context Protocol server that provides tools for interacting with databases, including PostgreSQL, DuckDB, and Google Cloud Storage Parquet files.
        Last updated -
        2
        TypeScript
        • Linux
        • Apple
      • -
        security
        F
        license
        -
        quality
        A secure Model Context Protocol server that allows Claude to execute read-only SQL queries against a PostgreSQL database, enabling natural language interaction with database data.
        Last updated -
        TypeScript
        • Apple

      View all related MCP servers

      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/t3ta/sql-mcp-server'

      If you have feedback or need assistance with the MCP directory API, please join our Discord server