---
ref: tool:metabase/query-metrics
name: Query tables and metrics
company: company:metabase
workflows: []
access: [mcp, api]
tags: [capability:track-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.

The API returns at most 200 rows per request, with a `continuation_token` to pass 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://{your-metabase-url}/api/metabase-mcp" } } }
```

Call the MCP tool `query`.

Server URL: https://{your-metabase-url}/api/metabase-mcp

### API (official)

- Base URL: https://{your-metabase-url}
- 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

Before doing anything else, make one read-only call to confirm access.

## Rules

- Ask the user before anything that sends messages, costs money, or changes data.
- Never print API keys.
