---
ref: tool:metabase/query-metrics
name: Query tables and metrics
company: company:metabase
workflows: []
access: [mcp, api]
tags: [capability:analyze-product-usage, category:product-analytics, has:api, has:mcp]
docs: https://www.metabase.com/docs/latest/ai/agent-api
updated: 2026-09-27
---

# Query tables and metrics

Runs a query against a table or saved metric through the semantic layer and returns the results.

Note: Returns at most 200 rows per request: pass the returned `continuation_token` back for the next page.

## 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 `query`.

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.

### API (official)

- Base URL: https://{metabase_host}
- Endpoint: `POST /api/agent/v1/query`
- Auth: send the header `X-API-Key: $METABASE_API_KEY`
- Docs: https://www.metabase.com/docs/latest/ai/agent-api

Note: `{metabase_host}` is your Metabase's address without `https://`; the key's group decides what it can read.

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.
