cursorrules

A project rule describing how to build a Node.js and TypeScript MCP server that runs database queries.

In plain words
What is it for?
Guiding implementation of a multi-database MCP server with unified access, connection pools, parameterized queries, encrypted credentials, and audit logging.
Why use it?
It sets requirements for supporting SQLite, PostgreSQL, and MySQL while addressing connection handling, errors, and SQL injection risks. MCP is a standard way for AI tools to connect to external capabilities.

Cursor rule for Cursor

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 rules/ahmetbarut/mcp-database-server/cursorrules
Clone the repo
git clone --depth 1 https://github.com/ahmetbarut/mcp-database-server

Made for: Cursor.

Per session 3,262 This file is loaded in full into every session.
When invoked 3,262 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.03262 $0.03262
Opus 5 $0.01631 $0.01631
Sonnet 5 $0.00652 $0.00652
Haiku 4.5 $0.00326 $0.00326

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

Security

Grade A, and why

cursorrules 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.

.cursorrules · 444 lines

How it starts

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

PROJECT OVERVIEW

You are an expert Node.js developer tasked with building a Model Context Protocol (MCP) server that provides multi-database query execution capabilities. This server should support SQLite, PostgreSQL, and MySQL databases with a focus on security, performance, and extensibility using modern Node.js and TypeScript. Note: This project is mcp-server, not a web app or another app.

CORE REQUIREMENTS

1. MCP Protocol Implementation

  • Implement full MCP server specification compliance
  • Use JSON-RPC for client-server communication
  • Provide proper error handling and response formatting
  • Support async/await patterns with modern ES modules

2. Database Support

  • SQLite: File-based database support with better-sqlite3 or sqlite3
  • PostgreSQL: Production database support with pg (node-postgres)
  • MySQL: Enterprise database support with mysql2
  • Implement connection pooling for each database type
  • Provide unified interface across all database types

3. Security Requirements

  • MANDATORY: Use parameterized queries only (prevent SQL injection)
  • Implement credential encryption for database connections
  • Add query validation and sanitization
  • Include audit logging for all database operations
  • Support rate limiting and timeout controls

4. Architecture Pattern

  • Use dependency injection for database drivers
  • Implement proper connection lifecycle management
  • Follow SOLID principles and clean architecture
  • Use Zod for data validation and schema management
  • Use TypeScript for type safety

PROJECT STRUCTURE

mcp-database-server/ ├── src/ │ ├── index.ts │ ├── server/ │ │ ├── index.ts │ │ ├── mcp-server.ts # Main MCP server implementation │ │ ├── handlers.ts # Request handlers │ │ └── tools/ # MCP tools implementation │ │ ├── index.ts │ │ ├── execute-query.ts │ │ ├── list-databases.ts │ │ ├── describe-table.ts │ │ └── list-tables.ts │ ├── database/ │ │ ├── index.ts │ │ ├── base.ts # Abstract base database interface │ │ ├── factory.ts # Database driver factory │ │ ├── pool.ts # Connection pooling │ │ └── drivers/ │ │ ├── index.ts │ │ ├── sqlite-driver.ts │ │ ├── postgresql-driver.ts │ │ └── mysql-driver.ts │ ├── config/ │ │ ├── index.ts │ │ ├── settings.ts # Configuration schemas │ │ └── database-config.ts # Database configurations │ ├── security/ │ │ ├── index.ts │ │ ├── encryption.ts # Credential encryption │ │ ├── validators.ts # Query validation │ │ └── audit.ts # Audit logging │ ├── utils/ │ │ ├── index.ts │ │ ├── logger.ts # Structured logging │ │ ├── exceptions.ts # Custom exceptions │ │ └── helpers.ts # Utility functions │ └── types/ │ ├── index.ts │ ├── database.ts │ ├── mcp.ts │ └── config.ts ├── tests/ │ ├── unit/ │ ├── integration/ │ └── fixtures/ ├── examples/ │ ├── basic-usage.js │ ├── configuration-examples/ │ └── client-examples/ ├── docs/ ├── package.json ├── package-lock.json ├── tsconfig.json ├── .env.example ├── .gitignore ├── README.md ├── jest.config.js └── LICENSE

Read the full file on GitHub · 444 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 · 444 lines · 3,262 tokens per session scan A c814602f41e0

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository ahmetbarut/mcp-database-server (5 stars, last pushed 6mo ago), licensed MIT. It adds 3,262 tokens to every session, about $0.0163 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.