Meridian
Provides read-only SQL execution and schema introspection over PostgreSQL, enabling agents to list tables, describe columns, sample rows, run validated SELECT queries, ask natural-language questions, and generate daily digests.
Posts the daily metric digest to Slack alert or routine channels, with anomalies flagged.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Meridian
An AI data analyst for PostgreSQL. Non-technical teammates ask questions about live operational data in plain English and get the answer, a chart and the SQL behind it, safely, with the database never at risk. Every morning it also sends leadership a short brief of the key metrics with anomalies highlighted.
Live demo: https://meridian-analyst.onrender.com (free tier: the first load after idle can take about a minute)
"Which region had the highest failed transaction rate last week?" → West Africa, at 15.9%, roughly five times the other regions. Bar chart, table, and the exact read-only SQL that produced it.
The problem
Operational questions ("why did failed payments jump?", "how many sign-ups yesterday, by channel?") usually wait in an analyst's queue, while giving everyone database access is unsafe. And the numbers leaders need every morning are assembled by hand, or not at all.
Related MCP server: pg-mcp
What it does
Ask | Natural language → validated, read-only SQL → answer, chart, table, CSV |
Daily digest | Revenue, transactions, failed-payment rate, sign-ups and churn vs their normal range; anomalies flagged; a short brief written from the computed facts |
Automation | An n8n workflow (included) runs the digest every weekday at 07:00 and posts to Slack: an alert channel if anything is anomalous, a routine channel otherwise |
MCP server + agent skill | Any AI coding agent (Claude Code, Cursor, Copilot, Windsurf, Claude Desktop) gets the same guarded tools on any PostgreSQL database: |
Sensitive data stays hidden | Mark columns such as emails or phone numbers as restricted: they disappear from the schema the model sees, and any query touching them is refused |
flowchart LR
Q[Question] --> P[LLM: query plan<br/>structured output]
P --> G{SQL guard}
G -- rejected --> P
G -- ok --> X[(Postgres<br/>read-only txn,<br/>SELECT-only role)]
X -- error --> P
X --> S[LLM: summary]
S --> V{Numbers found<br/>in results?}
V --> A[Answer + chart + SQL]
N[n8n 07:00] --> D[Digest API]
D --> M[Fixed metric SQL] --> Z[Robust z-score<br/>weekday-adjusted]
Z --> B[LLM brief<br/>from facts only] --> SL[Slack]Use it in your AI agent (MCP server + skill)
Meridian works with any PostgreSQL database, not only the demo. Your agent writes the SQL; Meridian makes sure it can only read, and only what you allow. No LLM key is needed for this.
claude mcp add meridian \
-e DATABASE_URL="postgresql://meridian_reader:PASSWORD@HOST/db?sslmode=require" \
-e MERIDIAN_HIDDEN_COLUMNS="customers.email,customers.phone" \
-- uvx --from git+https://github.com/Narcisse1/meridian meridian mcpThen add the skill: copy skill/meridian-postgres-analyst/
to ~/.claude/skills/. It tells the agent the workflow (map the schema → check real values →
one aggregated query → cite the SQL), how to recover from each kind of rejected query, and
proven query patterns (period comparisons, cohorts, funnels, anomaly checks). Setup for Cursor,
VS Code/Copilot, Windsurf and Claude Desktop is in
references/setup.md.
Setting | Meaning |
| Schema to expose (default |
| Allow-list of tables (default: every table and view in the schema) |
| Sensitive columns, never shown or queried ( |
| Your business definitions in Markdown (example) |
|
|
All tools are annotated read-only, so clients can approve them safely.
Safety: four independent layers
SQL guard (
meridian/sqlguard.py, sqlglot AST): one statement only; must be a query; no INSERT/UPDATE/DELETE/DDL anywhere in the tree (including data-modifying CTEs); noSELECT INTOor row locks; no dangerous functions (pg_sleep,pg_read_file,dblink,set_config, ...); only allow-listed tables in the configured schema (no system catalogs); a row limit is always applied. 38 tests cover these cases.Column-level privacy: restricted columns are removed from the schema the model sees, and any query that names them, or uses
SELECT *on their tables, is refused.COUNT(*)still works.Read-only execution: every query runs in
SET TRANSACTION READ ONLYwith a statement timeout.Least-privilege role: the app connects as
meridian_reader, which only has SELECT grants anddefault_transaction_read_only = on. An integration test proves writes fail even when the guard is bypassed.
Errors from the guard and the database are fed back to the model, which repairs its query (up to 3 attempts).
Reliability and honesty
Semantic layer: metric definitions (revenue, failed rate, churn, active MRR) are given to the model, so the same question always means the same calculation.
Number grounding: every figure in a generated answer or brief is checked against the result set / computed facts. Answers flag untraceable numbers; the digest refuses to publish a model brief containing them and falls back to a deterministic template.
The digest never depends on the model: metrics and anomalies are computed with fixed SQL and statistics (median/MAD robust z-score, weekday-adjusted so weekends are not "anomalies"). If the model is down, the template brief still goes out.
Provider-agnostic: Anthropic Claude or Google Gemini behind one interface (
LLM_PROVIDER), with refusal fallbacks, model auto-discovery, quota rotation and typed errors.
Demo data
db/seed.sql generates 120 days of data for Lumio Pay, a fictional African payments company
(6 regions, ~6,000 merchants, ~120,000 transactions) with trend, weekly seasonality and noise,
plus three planted incidents the digest should catch:
West Africa mobile-money payments fail far more often in the last 6 days (
issuer_unavailable)sign-ups jump ~70% on the latest day
growth-plan cancellations rise after a price change
Run it
uv venv && uv pip install -e ".[dev]"
cp .env.example .env # DATABASE_URL (read-only role) + GEMINI_API_KEY or ANTHROPIC_API_KEY
psql "$OWNER_URL" -f db/schema.sql -f db/seed.sql -f db/readonly_role.sql
meridian web # http://127.0.0.1:8000
meridian ask "Which region had the highest failed transaction rate last week?"
meridian digest # prints today's brief as Markdown
meridian mcp # MCP server over stdioMCP clients: see Use it in your AI agent.
n8n: import n8n/daily-digest.json, set the URL to your deployment, create a Header Auth
credential (X-Access-Token) and a Slack credential, then activate.
Deploy: the Dockerfile serves the app on $PORT (Render, Railway, Fly.io). Set
DATABASE_URL, an LLM key and MERIDIAN_ACCESS_TOKEN.
Tests and evaluation
pytest -q # unit + API tests; Postgres integration tests run when
# TEST_DATABASE_URL is set (CI starts a Postgres service)
python evals/run_eval.py # execution accuracy on evals/nl2sql_cases.yaml (real model calls)The eval runs the model's query and a reference query and compares results, reporting accuracy, how often the repair loop was needed, and cost.
Project layout
meridian/
sqlguard.py AST-based read-only validator
db.py read-only executor, schema introspection (column comments = data dictionary)
analyst.py NL→SQL with repair loop, semantic layer, grounded summaries
digest.py metrics, anomaly detection, grounded brief with template fallback
llm.py Claude / Gemini provider layer
web.py FastAPI app; static/index.html is the UI
mcp_server.py MCP tools (read-only annotated; MCP SDK 1.x and 2.x)
state.py question and digest history (SQLite)
skill/ installable agent skill: SKILL.md + setup and query-pattern references
docs/ example business-definitions file
db/ schema, seed, read-only role
n8n/ scheduled digest workflow
evals/ NL→SQL eval set and runner
tests/ unit, API and Postgres integration testsPhotography: Christina @ wocintechchat.com via Unsplash.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0
- AlicenseAqualityBmaintenanceGives agents read-only access to PostgreSQL databases, enabling them to inspect schemas, sample rows, compare stands, view query plans, and run read-only SQL through a single entry point.61MIT
- AlicenseNot gradedqualityCmaintenanceGives AI agents safe, read-only access to production Postgres, Sentry, and GitHub data, with SELECT-only SQL, PII redaction, and prompt-injection protections.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to securely inspect PostgreSQL schemas, understand table relationships, search schema metadata, and run bounded read-only queries without exposing database credentials. It also supports query plan inspection to help optimize slow SQL.MIT