tusk-mcp
A read-only PostgreSQL MCP server that enables AI agents to perform schema introspection and execute SELECT-only queries. It supports secure database connections through SSL and SSH tunnels while offering a structure-only mode to restrict query access.
README
tusk-mcp
Read-only PostgreSQL MCP server for AI agents. Exposes schema introspection and SELECT-only query execution over the Model Context Protocol.
Install
# npx (no install needed)
npx tusk-mcp --host db.example.com --database mydb
# or clone + run
bun install
bun run src/index.ts --host localhost --database mydb
Setup UI
Interactive browser-based setup that generates config for Claude Desktop, Claude Code, Cursor, Windsurf, and OpenAI Codex.
npx tusk-mcp setup
Build standalone binary
bun run build # Windows
bun run build:linux # Linux
bun run build:macos # macOS ARM
Connection
Individual flags (recommended)
tusk-mcp --host db.example.com --port 5432 --user admin --password 'p@ss' --database mydb
Connection string
tusk-mcp --connection-string "postgres://admin:p%40ss@db.example.com:5432/mydb"
Unencoded special characters in passwords (@, #) are handled automatically.
Environment variables
PGHOST=db.example.com PGDATABASE=mydb tusk-mcp
Priority: flags > --connection-string > DATABASE_URL > PG* env vars
Password security
# From file (Docker/K8s secrets)
tusk-mcp --host db --database mydb --password-file /run/secrets/db_pass
# From command (any secrets manager)
tusk-mcp --host db --database mydb --password-cmd 'vault kv get -field=password secret/db'
tusk-mcp --host db --database mydb --password-cmd 'op read op://vault/db/password'
SSL
Providing any certificate file automatically enables SSL.
tusk-mcp --host db --database mydb --ssl-ca /path/to/ca.crt # CA verification
tusk-mcp --host db --database mydb \ # mutual TLS
--ssl-ca ca.crt --ssl-cert client.crt --ssl-key client.key
SSH tunnel
tusk-mcp --host db-internal --database mydb \
--ssh-host bastion.example.com --ssh-user deploy --ssh-key ~/.ssh/id_rsa
Structure-only mode
Disables execute-query tool. Agents can see schema but not run queries.
tusk-mcp --host db --database mydb --structure-only
Tools
| Tool | Description |
|---|---|
list-schemas |
List non-system schemas |
list-tables |
Tables and views with estimated row counts (partitions filtered out) |
describe-table |
Columns, types, PKs, FKs, and enum values inline |
execute-query |
Read-only SQL with limit (disabled in structure-only mode) |
MCP config
{
"mcpServers": {
"tusk": {
"command": "npx",
"args": ["-y", "tusk-mcp", "--host", "localhost", "--database", "mydb"]
}
}
}
Claude Code
claude mcp add --transport stdio tusk -- npx -y tusk-mcp --host localhost --database mydb
OpenAI Codex (~/.codex/config.toml)
[mcp_servers.tusk]
command = "npx"
args = ["-y", "tusk-mcp", "--host", "localhost", "--database", "mydb"]
All flags
| Flag | Type | Default | Description |
|---|---|---|---|
--host |
string | localhost | PostgreSQL host |
--port |
number | 5432 | PostgreSQL port |
--user |
string | — | Database user |
--password |
string | — | Database password |
--password-file |
string | — | Read password from file |
--password-cmd |
string | — | Run command for password |
--database |
string | — | Database name |
--connection-string |
string | — | Full connection URL |
--ssl-ca |
string | — | CA certificate path (enables SSL) |
--ssl-cert |
string | — | Client certificate path (enables SSL) |
--ssl-key |
string | — | Client key path (enables SSL) |
--ssh-host |
string | — | SSH tunnel host |
--ssh-port |
number | 22 | SSH tunnel port |
--ssh-user |
string | — | SSH username |
--ssh-key |
string | — | SSH private key path |
--ssh-password |
string | — | SSH password |
--structure-only |
boolean | false | Disable execute-query |
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.