Prototype · Preview: every server in the official registry, synced every 30 minutes. Sign in with Google to write reviews.Prototype · updated every 30 min
PopNx MCPMCP servers for people who use AI · explained in plain words Sign in

querydig

by milankatiraversion 0.8.0i★ 0iRuns on your computerOfficial site ↗

How to install

What it does

Find, fix and verify N+1 and slow MongoDB/SQL queries in JS/TS, Python, Go, Java, Ruby and PHP.

  • Connects Runs on your computer
  • Account or key No key needed
  • Category Databases & datasets

Use together with

Skills that teach the AI this kind of work; they work alongside this one

last30days-skill

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

by mvanhorn★ 75,1131 skills

Skill · How-to guide

timesfm

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

by google-research★ 35,6991 skills

Skill · How-to guide

Shadowbroker

Open-source intelligence for the global theater. Track everything from the corporate/private jets of the wealthy, and spy satellites, to seismic events in one unified interface. Hook an AI agent up to have it parse through data and find previously unseen correlations. The knowledge is available to…

by BigBodyCobain★ 11,6311 skills

Skill · How-to guide

Why it ranks here

Lists are ordered by a usage score (out of 100) built from these parts

Popularity12/80GitHub stars or weekly downloads: the larger counts 60, the smaller 20
Freshness12/12Full marks for a release or code change within 30 days
Still answering0/8The cloud endpoint answered at the last check
Usage score24/100

Quality: Passed 3/3 basic checks (shown, not used for ordering) · Momentum: No data yet (Used only on the Trending tab)

Install

Pick the AI app you use, then copy the settings.

Let your AI install it with one sentence

Please install querydig. Follow https://mcp.popnx.com/i/milankatira-querydig.md, show me the commands and wait for my OK before running them.

Paste it into an AI that can work on your computer (such as Claude Code or Cursor). It reads our steps, shows you the commands and waits for your OK. No key, no sign-up. · See the full text your AI reads

Passed 3/3 checks · Runs on your computer · ✓ Commands checked Nov 26, 2026

First: which AI do you use?

Pick your app and the steps appear below.

Works with Claude, with some setup first

Install Node.js on your computer first (one time) · Only the Claude desktop app (Windows or Mac), not the web or phone

Let AI install it

Copy this message into a Claude chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.

Please install the MCP server querydig for Claude on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "mcpServers": { "querydig": { "command": "npx", "args": [ "-y", "querydig", "mcp" ] } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) No key is needed. 5) Do what we agreed, then check that the querydig tools really show up.

This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.

  1. Install Node.js (if you don’t have it)

    Already installed? Check first · Open Terminal, type this command and press Enter

    node -v
    • A version number such as v26.13.1 = installed, skip this step
    • "command not found" (on Windows: "is not recognized") = not installed yet, or installed but Terminal needs to be closed and reopened
    How to open Terminal

    Mac: press ⌘ + Space, type Terminal, press Enter

    Windows: open Start, type Windows PowerShell, then Open

    Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed

    Open the Node.js download page ↗

    When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v

    Install once; it works for everything that needs Node.js

  2. Open the Claude desktop app’s settings file

    SettingsDeveloperEdit Config

  3. Paste these settings and save the file

    {
      "mcpServers": {
        "querydig": {
          "command": "npx",
          "args": [
            "-y",
            "querydig",
            "mcp"
          ]
        }
      }
    }
  4. Quit Claude and open it again

  5. Try it

    Use querydig and tell me what you can do for me, then show me one thing

    ✓ If Claude says it is using querydig or shows a querydig tool in the answer, you are connected

1 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • QUERYDIG_DB_URI Optional read-only MongoDB or Postgres URI for live evidence (query plans, row counts, slow queries, missing indexes).

Descriptions are as written by the maker.

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

ChatGPT cannot connect querydig yet

querydig runs on your computer, but ChatGPT can only connect servers that run on the web

What you can do instead

A · Use an app that can connect querydig

  • Install Node.js on your computer first (one time) · Only the Claude desktop app (Windows or Mac), not the web or phone
  • Install Node.js on your computer first (one time)
  • Install Node.js on your computer first (one time)
  • Install Node.js on your computer first (one time)

B · Others in Databases & datasets that work with ChatGPT

Picked from the most used in the same category, only ones that connect by address with no key

Works with Claude Code, with some setup first

Install Node.js on your computer first (one time)

Let AI install it

Copy this message into a Claude Code chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.

Please install the MCP server querydig for Claude Code on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): claude mcp add --scope user querydig -- npx -y querydig mcp 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) No key is needed. 5) Do what we agreed, then check that the querydig tools really show up.

This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.

  1. Install Node.js (if you don’t have it)

    Already installed? Check first · Open Terminal, type this command and press Enter

    node -v
    • A version number such as v26.13.1 = installed, skip this step
    • "command not found" (on Windows: "is not recognized") = not installed yet, or installed but Terminal needs to be closed and reopened
    How to open Terminal

    Mac: press ⌘ + Space, type Terminal, press Enter

    Windows: open Start, type Windows PowerShell, then Open

    Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed

    Open the Node.js download page ↗

    When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v

    Install once; it works for everything that needs Node.js

  2. Open Terminal

    Mac: press Command+Space and type Terminal · Windows: open PowerShell

  3. Paste this command and press Enter

    claude mcp add --scope user querydig -- npx -y querydig mcp
  4. Type /mcp in Claude Code

    You should see querydig listed as connected

  5. Try it

    Use querydig and tell me what you can do for me, then show me one thing

    ✓ If Claude Code says it is using querydig or shows a querydig tool in the answer, you are connected

1 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • QUERYDIG_DB_URI Optional read-only MongoDB or Postgres URI for live evidence (query plans, row counts, slow queries, missing indexes).

Descriptions are as written by the maker.

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with Cursor, with some setup first

Install Node.js on your computer first (one time)

Let AI install it

Copy this message into a Cursor chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.

Please install the MCP server querydig for Cursor on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "mcpServers": { "querydig": { "command": "npx", "args": [ "-y", "querydig", "mcp" ] } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) No key is needed. 5) Do what we agreed, then check that the querydig tools really show up.

This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.

  1. Install Node.js (if you don’t have it)

    Already installed? Check first · Open Terminal, type this command and press Enter

    node -v
    • A version number such as v26.13.1 = installed, skip this step
    • "command not found" (on Windows: "is not recognized") = not installed yet, or installed but Terminal needs to be closed and reopened
    How to open Terminal

    Mac: press ⌘ + Space, type Terminal, press Enter

    Windows: open Start, type Windows PowerShell, then Open

    Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed

    Open the Node.js download page ↗

    When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v

    Install once; it works for everything that needs Node.js

  2. Click this button to open Cursor

    Open in Cursor

    Cursor asks you to confirm; click Install

  3. Open the AI chat in Cursor in Agent mode

  4. Try it

    Use querydig and tell me what you can do for me, then show me one thing

    ✓ If Cursor says it is using querydig or shows a querydig tool in the answer, you are connected

1 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • QUERYDIG_DB_URI Optional read-only MongoDB or Postgres URI for live evidence (query plans, row counts, slow queries, missing indexes).

Descriptions are as written by the maker.

Menu names checked against Cursor’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with VS Code, with some setup first

Install Node.js on your computer first (one time)

Let AI install it

Copy this message into a VS Code chat. The AI checks your computer, tells you which file it will change, and waits for your OK every time.

Please install the MCP server querydig for VS Code on this computer, in this order: 1) Check Node.js with node -v. If it is missing, tell me to install it from https://nodejs.org/en/download; do not install it yourself. 2) Use only this config (already checked by PopNx MCP): { "servers": { "querydig": { "type": "stdio", "command": "npx", "args": [ "-y", "querydig", "mcp" ] } } } 3) Tell me the full path of the file you will change, or the command you will run, and wait for my OK. 4) No key is needed. 5) Do what we agreed, then check that the querydig tools really show up.

This message has no key in it. If a key is needed, the AI will ask you to paste it yourself into the file or the app’s field.

  1. Install Node.js (if you don’t have it)

    Already installed? Check first · Open Terminal, type this command and press Enter

    node -v
    • A version number such as v26.13.1 = installed, skip this step
    • "command not found" (on Windows: "is not recognized") = not installed yet, or installed but Terminal needs to be closed and reopened
    How to open Terminal

    Mac: press ⌘ + Space, type Terminal, press Enter

    Windows: open Start, type Windows PowerShell, then Open

    Not installed: Open the official download page, pick the LTS version and the click-through installer: .pkg on Mac · .msi on Windows. Double-click and follow it to the end. No curl command needed

    Open the Node.js download page ↗

    When it’s done, close Terminal, open it again and run the same command. You should see a version number: node -v

    Install once; it works for everything that needs Node.js

  2. Click this button to open VS Code

    Open in VS Code

    VS Code asks you to confirm; click Install

  3. Open the AI chat in VS Code in Agent mode

  4. Try it

    Use querydig and tell me what you can do for me, then show me one thing

    ✓ If VS Code says it is using querydig or shows a querydig tool in the answer, you are connected

1 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • QUERYDIG_DB_URI Optional read-only MongoDB or Postgres URI for live evidence (query plans, row counts, slow queries, missing indexes).

Descriptions are as written by the maker.

Menu names checked against VS Code’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Other apps that use MCP, such as Windsurf, Zed or Gemini CLI, each add servers differently. See how in the app list.

See every app that uses MCP →

JSON settings are under “For developers” below

Stuck? Ask people who use querydig💬 Discussion →
For developers: Terminal commands and JSON settings

Installed on your computer

Claude Code

claude mcp add --scope user querydig -- npx -y querydig mcp

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "querydig": {
      "command": "npx",
      "args": [
        "-y",
        "querydig",
        "mcp"
      ]
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "querydig": {
      "command": "npx",
      "args": [
        "-y",
        "querydig",
        "mcp"
      ]
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "querydig": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "querydig",
        "mcp"
      ]
    }
  }
}

Values you fill in

  • QUERYDIG_DB_URI secret env
    Optional read-only MongoDB or Postgres URI for live evidence (query plans, row counts, slow queries, missing indexes).

Descriptions are as written by the maker.

These settings are generated from the maker’s registry entry. If the README says otherwise, follow the README.

At a glance

Registry name
io.github.milankatira/querydig
Downloads per weeki
390/wk
Connection
Runs on your computer
Latest versioni
0.8.0
Published to registryi
Nov 26, 2026
Code last changedi
Nov 25, 2026
Maker
milankatira
Packages
npm: querydig
Registry status
Active

Which apps can use it

Based on how this server connects and on each app’s own docs, checked Nov 10, 2026.

Run on your computer in

ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast

All apps, with pros and cons →

Related guides

What it can do

Runs on your computer; the tool list appears in your AI app after you install it.

Basic checksi

We check information anyone can see; we have not read the code. Checks that do not apply are left out of the count. · Checked Nov 26, 2026

  • ✓ Pass

    Maker matches the repo

    The registry name was verified with the GitHub account milankatira, which owns the repo

  • ✓ Pass

    Still maintained

    Code last changed yesterday

  • ✓ Pass

    Has a licence

    Uses MIT

  • – Not applicable

    Endpoint responds

    This one runs on your computer; there is no internet endpoint

  • – Not applicable

    Sign-in with OAuth

    Runs on your computer and uses local settings instead

  • … Not checked yet

    No hidden instructions in tool descriptions

    Runs on your computer; we can only read tool lists from internet endpoints

Published vulnerabilities (OSV.dev)

Not checked yet

What we check → · JSON

Makers: ask for a re-check or report wrong info
For makers: add a badge to your README

If you made this, paste this code into your README. The badge links back to this page.

[![Featured on PopNx MCP](https://mcp.popnx.com/badge/milankatira-querydig.svg)](https://mcp.popnx.com/en/servers/milankatira-querydig)

Discussion

Ask, share a tip or report that it does not work. Sorted by what people marked helpful.

No posts yet. Be the first to ask or share.

Posts here are written by users, not the PopNx team.

Sign in to post

User reviews

No reviews yet

Sign in to write a review

Compared with others in Databases & datasetsi

  • More stars than 0% of the other 1316 servers in this category
  • Published to the registry more recently than 98% of the other 1316 servers in this category
  • Basic checks equal to or better than 99% of the other 1316 servers in this category

Compared with every active server in this category in the registry. Stars count only when the publisher owns the repo.

Common questions

Is querydig safe?

It passed 3 of 3 applicable basic checks. We have not read the code. Before adding a key or token, see what access the server asks for and use a key with only the permissions you need.

What keys or codes does it need?

The registry does not list a required key, though some servers ask you to sign in on first use.

Does it run on my computer or in the cloud?

It runs on your computer. Your AI app starts it when needed, and data does not pass through the maker’s servers (unless it calls an online service itself).

Is it still maintained?

The GitHub repo last changed yesterday, and the latest version (0.8.0) reached the registry today.

Which apps can use it?

Apps that support MCP, such as Claude Desktop, Claude Code, Cursor and VS Code. You also need Node.js on your computer.

What can I use instead?

In the same category: Supabase, Neon, DBCode, Keboola MCP, WaveHouse Cloud

Similar alternatives

Same category, other makers, commands already checked. Official ones first, then by stars.

Reading a card:↓ Downloads per weeki★ GitHub starsiThree pillars: reviews · checks · usageiUpdated = latest version published to the registryi

Supabase

Supabase’s official server lets AI create tables, query data and review project settings in your Supabase database.

by supabaseWidely used↓ 245.5K/wk★ 3K Stars for the whole repoUpdated 6 days ago

Connect now (has URL) · sign-in✓ service owner · supabase.com

Neon

Official Neon MCP server for managing Neon projects and Lakebase Postgres databases.

by neondatabaseGrowing★ 667Updated 20 days ago

Connect now (has URL) · sign-in✓ service owner · neon.com

DBCode

Query and explore 100+ databases through your DBCode connections.

by dbcodeioEarly↓ 118/wk★ 369 Stars for the whole repoUpdated 2 months ago

Runs on your computer✓ service owner · dbcode.io

Keboola MCP

Connect your AI assistants to Keboola and expose your data, transformations, SQL queries, ...

by keboolaGrowing↓ 1.4K/wk★ 84Updated 7 days ago

Connect now (has URL) · sign-in✓ service owner · keboola.com

WaveHouse Cloud

Browse, query, and administer your managed WaveHouse + ClickHouse projects (schema, pipes, policy).

by Wave-RFEarly★ 41Updated 5 days ago

Connect now (has URL) · sign-in✓ service owner · wavehouse.cloud
Compared with similar ones
This one
querydig
SupabaseNeonDBCodeKeboola MCPWaveHouse Cloud
Runs whereInstalls on your computerCloud or install on your computerRuns in the cloud, nothing to installInstalls on your computerCloud or install on your computerRuns in the cloud, nothing to install
Needs a keyNoYesNoNoNoNo
Add with + in ClaudeNoYesYesNoNoNo
Basic checks3/35/55/52/35/54/4
LicenseMITApache-2.0MITNOASSERTIONMITApache-2.0
PriceNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registry

README from the maker

Open the README

Copied from the maker’s repo as written. PopNx MCP has not reviewed or endorsed it. HTML, images and scripts are removed. Links lead off this site.

querydig

Find slow, N+1 and unoptimized database queries before they reach production.

querydig is a zero-config CLI that statically scans your code for MongoDB and SQL query anti-patterns: N+1 queries, nested queries over results (N²), writes in loops, unbounded reads, unanchored regexes, skip()/OFFSET pagination, non-sargable SQL and more. Each finding gets a severity (critical / high / medium / low), the exact location, why it's slow and how to fix it.

npx querydig            # scan the current directory
  • Runs locally. No account, no server, your code never leaves the machine.
  • Fast. Tree-sitter (WASM) parsing in a worker pool: about 2,000 files in under 1 second.
  • Multi-language. JavaScript, TypeScript, Python, Go, Java, Ruby and PHP.
  • Multi-database. MongoDB (Mongoose, native driver, PyMongo/Motor, mongo-go-driver) and SQL (Prisma, TypeORM, Sequelize, pg/mysql2/knex raw, Django ORM, SQLAlchemy, DB-API cursors, GORM/xorm, database/sql, Spring Data JPA, Hibernate, JDBC/JdbcTemplate, jOOQ, ActiveRecord, Sequel, Laravel Eloquent/Query Builder, Doctrine, PDO/mysqli). MongoDB also via the Java driver, Spring Data MongoDB, Mongoid and the MongoDB PHP library.
  • Live evidence (optional). Point --uri at a MongoDB or Postgres replica to confirm full scans, missing and unused indexes, and slow queries.
  • CI-ready. GitHub Action with PR comments, --fail-on, baselines, --diff, SARIF for GitHub code scanning, HTML report.
  • In your editor. ESLint plugin for JS/TS, and an MCP server so AI assistants can fix and verify queries.

Requires Node.js 22.12+.

Example

 CRITICAL  QD002 Nested query over another query's results (N² risk) [mongodb]

src/orders.service.ts:7:20 │ o.user = await User.findById(o.userId); User.findById() is executed for every row of orders, which itself came from the database (loop at line 6). fix: Collect the _id values first and run a single User.find({ _id: { $in: values } }), then match results in memory with a Map.

MEDIUM MQ005 sort() without limit() [mongodb] src/search.ts:25:10 │ return User.find({ status }).sort({ createdAt: -1 }).lean(); fix: Add .limit(n) and an index matching filter + sort (ESR order), e.g. createIndex({ status: 1, createdAt: -1 }).

Summary CRITICAL 6 HIGH 16 MEDIUM 7 LOW 12 Query health: F (0/100)

Usage

npx querydig [path]                         # terminal report

npx querydig --format html # writes querydig-report.html (filterable, self-contained) npx querydig --format json -o report.json npx querydig --format sarif -o querydig.sarif npx querydig --format md > querydig.md # for PR comments

npx querydig --fail-on high # exit 1 if any high/critical issue (CI gate) npx querydig --min-severity medium # hide low findings npx querydig --diff origin/main # only files changed vs a branch npx querydig --update-baseline # record existing issues in .querydig-baseline.json npx querydig --baseline .querydig-baseline.json --fail-on high # only NEW issues fail

npx querydig rules # list rules npx querydig explain QD001 # why + before/after example npx querydig init # create querydig.config.json npx querydig --fix # apply safe automatic fixes (see Auto-fix) npx querydig --uri … --emit-indexes # write missing indexes to a script

Add it to a project:

npm i -D querydig

package.json → "scripts": { "querydig": "querydig --fail-on high" }

Rules

IDSeverityDBDetects
QD001high (critical when nested)anyQuery inside a loop / .map / comprehension (N+1)
QD002criticalanyQuery per row of another query's results (N²)
QD003highanyinsert/update/delete inside a loop. Use bulk APIs
QD004highSQLLazy-loaded relation in a loop (b.author.name without select_related / includes / with() / JOIN FETCH): Django, SQLAlchemy, Rails, Laravel, JPA
QD005highanynew PrismaClient() / MongoClient / Pool / Sequelize / DataSource created inside a handler: a new connection pool per call
MQ001highMongoDBfind({}) with no limit (full collection scan)
MQ002highMongoDBUnanchored or case-insensitive $regex
MQ003highMongoDB$where, $function, mapReduce
MQ004mediumMongoDBskip() pagination
MQ005mediumMongoDBsort() without limit() (suggests an ESR index)
MQ006mediumMongoDB$lookup/$unwind/$group before $match
MQ007mediumMongoDBNested or many populate() calls
MQ008lowMongoDBcountDocuments() used only as an existence check
MQ009lowMongoDB$ne / $nin / $not filters
MQ010lowMongoDBfind() without projection
MQ011lowMongoDBMongoose read without .lean()
SQ001highSQLfindMany() / findAll() / objects.all() / db.Find() with no where/limit
SQ002lowSQLSELECT *
SQ003highSQLLIKE '%term'
SQ004high/mediumSQLUPDATE/DELETE without WHERE, SELECT without WHERE/LIMIT
SQ005mediumSQLOFFSET pagination
SQ006mediumSQLWHERE LOWER(col) = … (non-sargable)
SQ007highSQLORDER BY RAND()
SQ008mediumSQLNOT IN (SELECT …)
SQ009lowSQLcount() used only as an existence check (use exists() / exists? / existsBy…)
SQ010mediumSQLWhole table loaded to iterate (User.all.each, foreach (User::all() …), for (… : repo.findAll()))

Built-in noise control: while/for {} polling loops, batching loops (skip/offset in the loop), loops over collections or model classes, and array helpers like arr.find(x => …) or Python str.find() are not flagged.

ESLint plugin

See findings in your editor as you type, and in any eslint CI run (JS/TS only; the CLI covers every language).

npm i -D querydig
// eslint.config.js (ESLint 9+)

import querydig from 'querydig/eslint';

export default [ querydig.configs.recommended, // optional: { rules: { 'querydig/no-slow-queries': ['error', { minSeverity: 'high', disable: ['MQ010'] }] } }, ];

Options: minSeverity, disable (rule ids), includeTests (tests, fixtures, migrations and seeds are skipped by default) and useConfigFile (default true: rule overrides and ignore from querydig.config.json apply). eslint --fix applies the same safe fixes as querydig --fix.

AI assistants (MCP server)

querydig mcp starts a Model Context Protocol server, so Claude Code, Claude Desktop, Cursor, VS Code and other MCP clients can find slow queries, rewrite them and check their own fixes. querydig does the detection and verification; the assistant does the rewrite. No API key is needed and your code stays local.

claude mcp add querydig -- npx -y querydig mcp

querydig is also listed in the MCP Registry as io.github.milankatira/querydig.

Or in any client's MCP config:

{

"mcpServers": { "querydig": { "command": "npx", "args": ["-y", "querydig", "mcp"], "env": { "QUERYDIG_DB_URI": "postgres://reader:***@replica-host/shop" } } } }

QUERYDIG_DB_URI is optional. Set it to give the assistant live evidence (row counts, query plans, slow queries, missing indexes) without putting the secret in the chat.

ToolWhat it does
scan_queriesScan a project (or just files, to verify an edit) and return findings by severity
get_finding_contextCode around a finding with line numbers, nearby findings and the rule's before/after example
analyze_snippetCheck a proposed rewrite before it is written to disk
apply_safe_fixesMechanical fixes like --fix; dry run unless dryRun: false
suggest_indexesRead-only index plan from live query plans (needs a database)
explain_rule, list_rulesRule docs

The optimize_queries prompt runs the whole loop: scan → safe fixes → rewrite the worst findings one by one → verify each with querydig → summary table. In Claude Code, type /mcp__querydig__optimize_queries.

Live mode: evidence from your database

Static analysis finds the patterns. Live mode connects read-only to MongoDB or Postgres and checks them against reality: how big each collection is, which indexes exist, and what the query planner actually does.

npx querydig --uri "mongodb://reader:***@replica-host/shop"

QUERYDIG_DB_URI="postgres://reader:***@replica-host/shop" npx querydig # keeps the secret out of shell history

What changes:

  • Promotes an N+1 whose inner query is a full scan of a large table to critical ("N × full scan of 4.2M docs") and adds the missing index.
  • Demotes unbounded reads on tiny lookup tables to low.
  • Adds live-only findings:
IDSeverityFinds
LV001high / criticalQueries in your code that do a COLLSCAN / Seq Scan on 10k+ rows, with the exact index to create
LV002mediumQueries that sort in memory
LV003high / criticalSlow queries from the MongoDB profiler or pg_stat_statements, traced back to the line of code when possible
LV004lowIndexes that are never used
LV005mediumPostgres foreign keys without an index that your code filters on

Every live finding shows its evidence:

 CRITICAL  QD002 Nested query over another query's results (N² risk) [mongodb]

src/reports.ts:15:25 live: Each iteration does a full scan of orders (300k docs): N × 300k docs read. (high → critical) fix: … Until then, at least add an index: db.orders.createIndex({ userId: 1 })

Safety model

  • Only metadata and query plans are read by default: collection stats, index lists, explain('queryPlanner'), and EXPLAIN (GENERIC_PLAN) (PostgreSQL 16+). Queries are planned, never executed.
  • --explain-execute opts into execution stats (executionStats / EXPLAIN ANALYZE, SELECTs only), which do run the query. Use it on a replica.
  • Postgres: every statement runs in a read-only transaction (default_transaction_read_only = on) with a 5s statement timeout. MongoDB: secondaryPreferred reads with maxTimeMS: 5000.
  • Passwords are redacted from all output. If the database can't be reached, querydig warns and still reports static findings (--live-required makes that an error).

Recommended read-only users

// MongoDB

db.createUser({ user: 'querydig', pwd: '…', roles: [{ role: 'read', db: 'shop' }, { role: 'clusterMonitor', db: 'admin' }] })

-- Postgres

CREATE ROLE querydig LOGIN PASSWORD '…'; GRANT pg_read_all_stats TO queryd

Only the beginning is shown; read the rest in the repo