> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querybear.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cursor

> Connect Cursor to your PostgreSQL, MySQL, or SQLite database using QueryBear's secure MCP server. Drop into .cursor/mcp.json.

**[Cursor](https://cursor.com)** is the AI-first code editor. It has first-class MCP support — define an MCP server in `.cursor/mcp.json` and Cursor's agent can use it across all chat, composer, and inline modes.

## Connect

Choose **project-scoped** or **global** install:

### Project-scoped (recommended for client work)

Create `.cursor/mcp.json` in your project root:

```json theme={null}
{
  "mcpServers": {
    "querybear": {
      "url": "https://mcp.querybear.com/mcp"
    }
  }
}
```

Commit this file if your team should all use the same connection. Add it to `.gitignore` if not.

### Global

Same JSON, but at `~/.cursor/mcp.json`. Applies to all Cursor projects.

### Authorize

The first time Cursor uses the QueryBear MCP server, it opens a browser tab for OAuth. Approve, and Cursor is linked to your QueryBear account.

## Verify

In Cursor chat or composer, ask:

> *"What QueryBear tools do you have?"*

You should see `list_connections`, `get_schema`, and `run_query`. If you don't see them after restarting Cursor, check **Settings → MCP** for any error messages.

## Why QueryBear + Cursor

When you're pair-programming with Cursor, the database is often the thing you most need it to see. Without QueryBear, you copy-paste schemas into the chat or describe the data structure in prose. With QueryBear, Cursor can:

* Pull the actual schema when generating queries — no more hallucinated column names.
* Verify migrations against real data before you run them.
* Answer "does this row exist?" / "how many users have field X set?" while you're writing code.
* Generate seed data based on real production distributions (without ever leaking the rows themselves — QueryBear's row limit + column blocks see to that).

## Per-database setup guides

<CardGroup cols={2}>
  <Card title="PostgreSQL + Cursor" href="/guides/postgres-cursor">
    Step-by-step Postgres setup, including read-only role SQL.
  </Card>

  <Card title="MySQL + Cursor" href="/guides/mysql-cursor">
    Step-by-step MySQL setup, including read-only user SQL.
  </Card>

  <Card title="SQLite + Cursor" href="/guides/sqlite-cursor">
    Local SQLite file setup.
  </Card>
</CardGroup>

## Tips for using QueryBear in Cursor

* **Per-project connections.** If different projects target different databases, keep `.cursor/mcp.json` project-scoped and connect a different database per project in QueryBear.
* **In Composer mode, ask for the query before running it.** Cursor's composer can string together multiple tool calls; for production reads, "show me the SQL you'd run" is a good intermediate step.
* **Use `@` to reference QueryBear.** In some Cursor versions you can `@querybear` to scope the agent's tool selection.
* **Pin your default connection** in the QueryBear dashboard. Cursor uses it without needing `list_connections`.

## Common workflows

* *"Add a migration that backfills `users.timezone` from `users.locale`. First, check how many users have a `locale` set."*
* *"Generate a TypeScript type for the `orders` table based on its current schema."*
* *"I changed the `subscriptions` query. Run it against production and tell me if any rows return unexpected fields."*

## Related

* [Quickstart](/quickstart) — full QueryBear setup
* [Security model](/features/security) — what the gateway enforces
* [Windsurf](/clients/windsurf) — the other AI-first code editor
