database-mcp: Instructions file for Claude Code

CLAUDE.md

database-mcp CLAUDE.md is an instructions file for Claude Code from cocaxcode/database-mcp. It costs 1,678 tokens per session, scanned A, original, MIT.

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 for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md.

This is cocaxcode/database-mcp's own configuration. It tells Claude Code how to work on database-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything database-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cocaxcode/database-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cocaxcode/database-mcp/master/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/cocaxcode/database-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for database-mcp CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/cocaxcode/database-mcp/claude-md/github.svg)](https://agentmods.dev/instructions/cocaxcode/database-mcp/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/cocaxcode/database-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/cocaxcode/database-mcp/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for database-mcp CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/cocaxcode/database-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/cocaxcode/database-mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.01678 $0.01678
Opus 5.5 $0.00671 $0.00671
Sonnet 5.5 $0.00336 $0.00336
Haiku 4.5 $0.00168 $0.00168

Measured 2mo ago against content hash f4f61d8516cb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2mo ago.

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. 2mo ago 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 (4 stars, last pushed 2mo ago), licensed MIT. It adds 1,678 tokens to every session, about $0.0067 per session on Opus 5.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

database-mcp CLAUDE.md compared with instructions from other repositories

database-mcp CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
database-mcp CLAUDE.mdcocaxcode/database-mcpInstructions file42mo agoMITA1,678Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,685GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,086GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file281ktodayMITA4,335Codex, OpenCode