SQL MCP Server (TypeScript)

by t3ta

1 stars
194 downloads
Not rated
GitHub

Description

# SQL MCP Server (TypeScript) [![TypeScript](https://img.shields.io/badge/TypeScript-4.x-blue?logo=typescript)](https://www.typescriptlang.org/) [![Build](https://github.com/your-org/sql-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/your-org/sql-mcp-server/ac…

About

# SQL MCP Server (TypeScript) [![TypeScript](https://img.shields.io/badge/TypeScript-4.x-blue?logo=typescript)](https://www.typescriptlang.org/) [![Build](https://github.com/your-org/sql-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/your-org/sql-mcp-server/actions/workflows/ci.yml) [![License…

Details

Author
t3ta
GitHub stars
1
Downloads
194
Categories
Database

- 🔒 SSH bastion support for secure access to private RDS instances
- 🐘 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

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name SQL MCP Server (TypeScript)
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install by cloning the repository and running npm install && npm run build. Configure via .env file or environment variables (e.g., DB_USER, DB_HOST, USE_SSH_TUNNEL). Run the server with npx -y @modelcontextprotocol/server-postgres postgresql://<user>:<pass>@<host>:<port>/<dbname>.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "sql mcp server (typescript)": {
            "sql-mcp-server": {
                "command": "npx",
                "args": [
                    "-y",
                    "@modelcontextprotocol/server-postgres",
                    "postgresql://<user>:<pass>@localhost:5433/<dbname>"
                ]
            }
        }
    }
}

McpServers

{
    "sql-mcp-server": {
        "command": "npx",
        "args": [
            "-y",
            "@modelcontextprotocol/server-postgres",
            "postgresql://<user>:<pass>@localhost:5433/<dbname>"
        ]
    }
}

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

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.