database-mcp CLAUDE.md

Project instructions for a database MCP server that connects AI assistants to PostgreSQL, MySQL, and SQLite databases. They describe its tools, query-result formatting, architecture, and tests.

In plain words
What is it for?
Use them when developing or reviewing this database server, especially its query, mutation, explanation, history, schema, dump, and restore features.
Why use it?
They explain how to use smaller query results, recover full results when needed, and work consistently with the server's database and code conventions.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/cocaxcode/database-mcp/claude-md
Clone the repo
git clone --depth 1 https://github.com/cocaxcode/database-mcp
Per session 1,678 This file is loaded in full into every session.
When invoked 1,678 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01678 $0.01678
Opus 5 $0.00839 $0.00839
Sonnet 5 $0.00336 $0.00336
Haiku 4.5 $0.00168 $0.00168

Measured yesterday against content hash f4f61d8516cb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

database-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md — @cocaxcode/database-mcp

Project Overview

MCP server for database connectivity. Multi-DB (PostgreSQL, MySQL, SQLite), connection management, schema introspection, query execution with rollback and history, database dump/restore. 27 tools, 163 tests.

Token-optimized query results (v0.3+)

execute_query, execute_mutation, explain_query accept optional params that cut context tokens 60-95%:

  • verbosity: 'minimal' | 'normal' | 'full' (default 'normal')
  • only_columns: string[] — client-side column projection
  • max_cell_bytes: number (default 500) — per-cell byte cap for 'normal'
  • max_rows_in_response: number — row cap beyond SQL LIMIT
  • include_schema_context: boolean — skip schema trail when known

Every compressed result includes call_id. Use inspect_last_query({ call_id }) to recover the full result without re-executing the SQL (preserves DB load). Ring buffer 20 + ~/.database-mcp/last-queries/ with 1h TTL.

Cell truncation preserves table structure: truncated cells get a …(+NB) suffix. Much better than the old global 25KB truncation that cut trailing rows.

Stack

  • TypeScript 5.x (strict mode, ESM)
  • @modelcontextprotocol/sdk 1.27.x (unified package)
  • Zod 3.25+ for schema validation
  • Vitest for testing (InMemoryTransport + SQLite :memory:)
  • tsup for building (ESM output with shebang)
  • Drivers: postgres, mysql2, sql.js (optional peer deps, dynamic import)

Architecture

src/
├── index.ts              # Entry point (shebang + StdioServerTransport, --dsn flag)
├── server.ts             # createServer(storageDir?, projectDir?) factory
├── tools/                # MCP tool registration (one file per group)
│   ├── connection.ts     # conn_create/list/get/set/switch/rename/delete/duplicate/test/project_list/project_clear/export/import (13)
│   ├── schema.ts         # search_schema (1)
│   ├── query.ts          # execute_query/execute_mutation/explain_query (3)
│   ├── rollback.ts       # rollback_list/rollback_apply (2)
│   ├── history.ts        # history_list/history_clear (2)
│   ├── config.ts         # config_get/config_set (2)
│   └── dump.ts           # db_dump/db_restore/db_dump_list (3)
├── resources/
│   └── schema.ts         # MCP Resources: db://schema, db://tables/{tableName}/schema
├── services/             # Business logic with DB interaction
│   ├── connection-manager.ts  # Lazy connect, driver caching, getActiveDriver()
│   ├── schema-introspector.ts # Multi-dialect schema queries (3 detail levels)
│   ├── query-executor.ts      # Read (LIMIT injection), mutation (mode check), explain
│   ├── rollback-manager.ts    # Pre-mutation snapshots, reverse SQL generation
│   ├── history-logger.ts      # Per-project query history (5000 max)
│   └── dump-manager.ts        # Database dump/restore (SQL generation, multi-dialect)
├── drivers/              # Database adapters (dynamic import)
│   ├── interface.ts      # DatabaseDriver interface
│   ├── sqlite.ts         # sql.js adapter (:memory: + file)
│   ├── postgres.ts       # postgres.js adapter (DSN or config)
│   ├── mysql.ts          # mysql2/promise adapter (DSN or config)
│   └── registry.ts       # resolveDriver() factory
├── lib/                  # Pure logic (no DB dependency)
│   ├── types.ts          # All TypeScript interfaces
│   ├── sanitize.ts       # sanitizeName() for connection names
│   └── storage.ts        # JSON file storage in ~/.database-mcp/
├── utils/
│   ├── sql-classifier.ts     # classifySql() → read/write/ddl
│   ├── sql-parser-light.ts   # extractTableAndWhere() for rollback
│   ├── result-formatter.ts   # formatQueryResult() with 25KB truncation
│   ├── gitignore-checker.ts  # Add .database-mcp/ to .gitignore
│   └── project-storage.ts    # Lazy mkdir of {projectDir}/.database-mcp/ + gitignore
├── types/                # Module declarations for optional deps
│   ├── sql.js.d.ts
│   ├── postgres.d.ts
│   └── mysql2.d.ts
└── __tests__/
    ├── helpers.ts         # createTestClient() with InMemoryTransport
    └── *.test.ts          # 10 test files, 88 tests

Read the full file on GitHub · 126 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 126 lines · 1,678 tokens per session scan A f4f61d8516cb

Subscribe to this mod's changes

database-mcp CLAUDE.md is an instructions file published in the GitHub repository cocaxcode/database-mcp (2 stars, last pushed 6d ago), licensed MIT. It adds 1,678 tokens to every session, about $0.0084 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

buildNext

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

next.js AGENTS.md

Instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

spec-kit AGENTS.md

Instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,040 tokens

langchain AGENTS.md

Instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,345 tokens