# Connect an AI agent to your database

> How do I let Claude Code, Cursor or another AI agent query my database safely?

An MCP server is the standard way to let an agent inspect schemas and run queries against a real database. The choice is mostly about which databases you run and how much the server should do beyond querying.

A hand-picked shortlist from the Agent Search Engine index. Every pick is a real listing; the adoption, pricing, and activity figures are the index's live numbers. Browse on the web: https://agentsearchengine.app/use/connect-agent-to-database

## Recommended picks

### Best overall: DBHub
- Open source · MCP server · 3.6k★ · TypeScript · MIT · active 2 days ago
- **Setup:** Config entry — npx
- **Why:** One small server for Postgres, MySQL, MariaDB, SQL Server, Oracle and SQLite, with only two tools by default to keep context lean, and read-only mode, row limits and query timeouts built in.
- [listing](https://agentsearchengine.app/agents/dbhub) · [official](https://dbhub.ai)

### Postgres tuning: Postgres MCP Pro
- Open source · MCP server · 3.3k★ · Python · MIT · active 1 month ago
- **Setup:** Self-host — pipx or Docker
- **Why:** For Postgres it goes beyond queries: database health checks, index tuning across candidate indexes and EXPLAIN plans with hypothetical indexes, with restricted and unrestricted access modes.
- [listing](https://agentsearchengine.app/agents/postgres-mcp-pro) · [official](https://github.com/crystaldba/postgres-mcp)

### Many databases, production tools: MCP Toolbox for Databases
- Open source · MCP server · 16k★ · Go · Apache-2.0 · active today
- **Setup:** Config entry — npx
- **Why:** Google's open-source server covers a long list of databases, from Postgres and BigQuery to Spanner, with prebuilt tools for exploration and a framework for governed custom tools once agents move to production.
- [listing](https://agentsearchengine.app/agents/mcp-toolbox-for-databases) · [official](https://mcp-toolbox.dev/documentation/introduction/)

## What to watch for
Start read-only and against a copy. A model with write access will eventually run a statement you did not intend, so use DBHub's read-only mode or Postgres MCP Pro's restricted mode, point the server at a replica or development database, and never hand it credentials that can drop tables. If your data lives in Supabase or MongoDB, both vendors publish their own MCP servers, listed in the index.

---
Source: [Agent Search Engine](https://agentsearchengine.app) — more task-first guides: https://agentsearchengine.app/use
