Skip to main content
Glama
thhart

database-mcp

by thhart

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
DATABASE_URLNoAlternative database connection string
DATABASE_MCP_DSNNoDatabase connection string, e.g., postgresql://user@host:5432/db
DATABASE_MCP_PROFILESNoPath to profiles JSON file

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
queryA

Execute SQL on a profile (default profile when omitted). Returns the first page as compact {"columns":[...],"rows":[[...],...],"page":{"returned","has_more","estimated_rows","cursor"}}. When has_more is true, pass page.cursor to the fetch tool — the query is NOT re-executed; a server-side cursor is held open (stable snapshot). Placeholders: %s positional with the params array.

fetchA

Fetch the next page from an open cursor returned by query. No re-execution: rows continue exactly where the last page ended. The cursor auto-closes when exhausted (has_more=false).

closeA

Close an open cursor (or all cursors when no token is given) to free its connection early.

tablesA

List tables/views/matviews with estimated row counts and sizes (system schemas excluded). Optional name filter.

describeA

Describe one table: columns with types/nullability/defaults, constraints (PK/FK/unique/check), and indexes.

explainA

Show the query plan (EXPLAIN). Set analyze=true to actually run the statement and get real timings.

overviewA

Orientation card for an unknown database: every table with row estimate and its column names in ONE compact call — use this before tables/describe round-trips. Optional table-name filter.

search_objectsB

Find tables, columns, and functions by name OR by comment (pg_description — often the only documentation a schema has). Answers 'where is the customer email?' in one call.

profileA

Column statistics from pg_stats WITHOUT touching the table: null fraction, distinct count (negative = fraction of rows, -1 = unique), most common values with frequencies, histogram bounds, physical correlation. Replaces exploratory SELECT DISTINCT / GROUP BY scans.

relationsA

Foreign keys of one table, both directions: what it references and what references it.

join_pathB

Shortest foreign-key path between two tables, rendered as a ready-to-use JOIN chain (up to 3 equally short paths). Use this instead of guessing joins on unfamiliar schemas.

countA

Row count, estimate-first: instant planner estimate (no scan), optionally with a WHERE clause; exact=true runs a real count(*) under the statement timeout. Prefer the estimate.

sampleA

A few genuinely random rows from a table (TABLESAMPLE on big tables — no scan, no physically-adjacent LIMIT bias).

profilesA

List all connection profiles (DSNs password-redacted) and which one is the default.

profile_addA

Add or update a named connection profile at runtime and persist it. Tests the connection first (set test=false to skip). Profiles are read-only unless allow_writes=true. make_default=true switches the default profile. For a database only reachable via SSH, set ssh_host (an ssh destination or ~/.ssh/config alias; BatchMode, so keys/agent must work non-interactively) — a tunnel is opened automatically and kept alive; ssh_remote_host/ssh_remote_port default to the DSN's host/port as seen FROM the ssh host (usually 127.0.0.1:5432).

profile_removeB

Remove a connection profile (open cursors on it are closed).

profile_testA

Test connectivity of a profile (default profile when omitted): server version and connect latency.

statusA

Server status: profiles with pool statistics, open cursors, configured limits, profiles file location.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Latest Blog Posts

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/thhart/database-mcp'

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