---
ref: tool:metabase/run-sql-query
name: Run a SQL query
company: company:metabase
workflows: []
access: [mcp]
tags: [capability:analyze-product-usage, category:product-analytics, has:mcp]
docs: https://www.metabase.com/docs/latest/ai/mcp
updated: 2026-09-27
---

# Run a SQL query

Runs a native SQL query against a connected database and returns the rows.

Note: Needs native-query permission on the target database.

## Set up

Use the first option your agent supports.

### MCP (official, remote)

Add this server to your agent's MCP settings, then sign in when asked.

```json
{ "mcpServers": { "metabase": { "url": "https://{metabase_host}/api/metabase-mcp" } } }
```

Call the MCP tool `execute_sql`.

Server URL: https://{metabase_host}/api/metabase-mcp

Note: `{metabase_host}` is your Metabase's address without `https://`. An admin turns the MCP server on under Admin > AI > MCP.

Before anything else, confirm access with the cheapest read-only call, like a list or a search. Never send or change anything to test access.

## Rules

- Ask the user before anything that sends messages, costs money, or changes data, and say how many records it touches. One approval covers a batch the user has seen.
- Never print API keys.
