SQL MCP Server

Enable seamless interaction with PostgreSQL databases through secure SSH tunnels. Query your databases effortlessly while ensuring data security and integrity. Perfect for local, containerized, or AI-driven applications.

Installation

Installing for Claude Desktop

Option 1: One-Command Installation

npx mcpbar@latest install t3ta/sql-mcp-server -c claude

This command will automatically install and configure the SQL MCP Server MCP server for your selected client.

Option 2: Manual Configuration

Run the command below to open your configuration file:

npx mcpbar@latest edit -c claude

After opening your configuration file, copy and paste this configuration:

View JSON configuration
{
  "mcpServers": {
    "SQL MCP Server": {
      "command": "npx",
      "args": [
        "-y",
        "sql-mcp-server"
      ],
      "env": {
        "DB_USER": "${input:db_user}",
        "DB_PASS": "${input:db_pass}",
        "DB_HOST": "${input:db_host}",
        "DB_PORT": "${input:db_port}",
        "SSH_BASTION_HOST": "${input:ssh_bastion_host}",
        "SSH_BASTION_USER": "${input:ssh_bastion_user}",
        "SSH_PRIVATE_KEY": "${input:ssh_private_key}"
      }
    }
  }
}

SQL MCP Server (TypeScript)

TypeScript Build License: MIT Platform

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 pg library
  • 📡 STDIO-based MCP protocol transport
  • 🧠 Compatible with memory-bank-mcp-server
  • ⚙️ Easily configurable via .env or environment variables
  • 🧪 Fully testable with Jest and mocks

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

Share:
Details:
  • Stars


    0
  • Forks


    1
  • Last commit


    3 months ago
  • Repository age


    4 months
View Repository

Auto-fetched from GitHub .

MCP servers similar to SQL MCP Server:

 

 
 
  • Stars


  • Forks


  • Last commit


 

 
 
  • Stars


  • Forks


  • Last commit


 

 
 
  • Stars


  • Forks


  • Last commit


SQL MCP Server: MCP Server – MCP.Bar