SQL MCP Server
Supports configuration via .env files for database credentials and connection settings
Includes CI/CD integration through GitHub Actions workflows
Provides testability with Jest for ensuring server reliability and performance
Provides a read-only query interface to PostgreSQL databases, supporting secure connections via SSH bastion tunnels
Compatible with Supabase + MCP integration, allowing models to query Supabase-managed PostgreSQL databases
Built with TypeScript for type safety and modern JavaScript features
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SQL MCP Servershow me the top 10 customers by total orders"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SQL MCP Server (TypeScript)
This project provides a TypeScript implementation of a Model Context Protocol (MCP) server that enables language models and other MCP-compatible clients to query PostgreSQL databases—via SSH bastion tunnels when required.
Built for flexibility and secure database access, it supports AWS RDS with read-only transactions and uses stdin/stdout-based communication, making it suitable for local, containerized, or AI-driven use cases.
Features
🔒 SSH bastion support for secure access to private RDS instances via SSH tunnels
🐘 PostgreSQL read-only query engine using the
pglibrary📡 STDIO-based MCP protocol transport
🧠 Compatible with memory-bank-mcp-server
⚙️ Easily configurable via
.envor environment variables🧪 Fully testable with Jest and mocks
Related MCP server: Enhanced PostgreSQL MCP Server
Installation
Clone the repository and install dependencies:
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 installed
Maintenance
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
- Alicense-qualityDmaintenanceA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.Last updated126,03627MIT
- Alicense-qualityFmaintenanceA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.Last updated41711MIT
- Alicense-qualityFmaintenanceA 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.Last updated9031MIT
- AlicenseBqualityDmaintenanceA TypeScript-based Model Context Protocol server that enables AI assistants to perform secure database operations on PostgreSQL databases through structured tool interfaces.Last updated838MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
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/t3ta/sql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server