• QUERY
  • BATCH
  • BRANCH
  • HUMAN

How to run SQL queries with your AI client

Connect Xata to your AI client once. From then on, you can query any database branch directly from your chat or editor.

Ask AI about this page

Short answer

Can I run SQL queries using my AI?

Yes. You can send single or batched SQL commands to specific Xata branches. Your AI handles the execution and shows you the results immediately.

Where your data goes

The outcomes of your queries

Your AI translates your intent into database actions.

QUERY

Single query results

The AI runs a single SQL statement and returns the specific rows or values you asked for.

BATCH

Bulk operation results

When you request multiple changes, the AI executes them as a batch and reports the outcome.

BRANCH

Environment isolation

The AI targets specific database branches so you can query staging or dev without touching production.

HUMAN

Manual verification

You review the data or error messages the AI provides to ensure the query did exactly what you wanted.

The workflow

What your AI does when the query arrives.

The AI manages the connection between your prompt and the Xata database.

  1. Locate the branch

    The AI identifies which Xata branch you want to interact with based on your instructions.

    get_branch
  2. Execute single SQL

    The AI sends a single SQL command to the database and waits for the data to return.

    execute_sql
  3. Run batch commands

    If you need to run several statements at once, the AI bundles them into a single execution.

    execute_sql_batch
  4. Deliver the data

    The AI presents the query results or any error logs directly in your current workspace.

    execute_sql

Try it

Copy these to start.

Use these prompts to start querying your Xata database.

Starting points

Replace the branch names and table names with your actual Xata identifiers.

Xata Connector

You're all set. Choose your MCP client and follow the setup instructions.

Connector linkhttps://edge.vinkius.com/vk_preview_hdabIw4ur1U2XtmSNjFRPY6OBAAuVwxziC0Rvp3T/mcp

Claude Desktop

Follow the steps below to connect in seconds.

  1. 1In Claude Desktop, open Settings → Connectors.
  2. 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
  3. 3Click Add and start a new chat — Xata capabilities are ready to use.
Configuration · claude_desktop_config.jsonCopy
{
  "mcpServers": {
    "xata-serverless-db-mcp": {
      "url": "https://edge.vinkius.com/vk_preview_hdabIw4ur1U2XtmSNjFRPY6OBAAuVwxziC0Rvp3T/mcp"
    }
  }
}
Copy into chat04
  • Run a SQL query on the 'dev' branch to find all users in the 'customers' table.

  • Execute a batch of SQL queries on the 'staging' branch to update the 'inventory' table.

  • Use the 'production' branch to count all entries in the 'orders' table.

  • Check the 'test' branch and show me the first five rows from the 'logs' table.

  • Claude
  • ChatGPT
  • Cursor
  • VS Code
  • Windsurf
  • Claude Code
  • JetBrains
  • Cline

Start here

Connect Xata once, then ask.

Follow the link to connect your account. Your credentials stay encrypted on our side, and you can start working immediately.

Connect Xata to your AI

FAQ

How this task behaves

  • 01

    Can the AI run queries on any branch?

    Yes. You can specify any branch you have access to when you give your prompt.

  • 02

    Can the AI delete my entire database?

    No. The AI can only execute the specific SQL commands you tell it to run. It has no power to perform actions outside of your direct instructions.

  • 03

    Does the AI handle multiple queries at once?

    Yes. It can use batch execution to run several SQL statements in one go.

  • 04

    Can the AI create new tables?

    Yes. If you provide a SQL command to create a table, the AI will execute it.

  • 05

    Will the AI automatically commit my changes?

    The AI executes the commands you provide. It does not manage transactions or commits independently of the SQL you write.

  • More questions about Xata? See everything the Xata Connector can do

Connect Xata to Claude, Cursor, ChatGPT & more