# Metabase

> Query Metabase databases, run saved questions and dashboards, and manage collections via API key.

Lets an agent explore your Metabase, run saved questions (cards), ad-hoc SQL and dashboards, and manage cards, dashboards and collections. Authenticates with a Metabase API key against your own Metabase site URL.

## What it can do

| Method | What it does |
| --- | --- |
| `metabase_current_user` | Get the authenticated user - confirms the API key works. |
| `metabase_list_users` | List users (admin); filter by status/query, paginate. |
| `metabase_get_user` | Get one user by id. |
| `metabase_list_databases` | List databases; optionally include tables. |
| `metabase_get_database` | Get one database, optionally with tables/fields. |
| `metabase_get_database_metadata` | Get a database's schemas, tables and fields. |
| `metabase_get_database_schemas` | List a database's schemas. |
| `metabase_get_database_schema_tables` | List tables in one schema of a database. |
| `metabase_list_tables` | List all tables visible to the user. |
| `metabase_get_table` | Get one table by id. |
| `metabase_get_table_query_metadata` | Get a table's fields, types and foreign keys. |
| `metabase_get_field` | Get one field's metadata. |
| `metabase_get_field_values` | List a field's distinct values (to build filters). |
| `metabase_search_field_values` | Search a field's values by prefix for autocomplete. |
| `metabase_get_field_remapping` | Get the human-readable remapped value for a raw value. |
| `metabase_list_cards` | List cards (saved questions); filter by f and model_id. |
| `metabase_get_card` | Get one card (question) by id. |
| `metabase_run_card_query` | Run a saved card and return its result rows. |
| `metabase_run_card_query_export` | Run a saved card and export as csv/json/xlsx/api. |
| `metabase_create_card` | Create a card (saved question). WRITE - confirm first. |
| `metabase_update_card` | Update or archive a card. WRITE - confirm first. |
| `metabase_delete_card` | Delete a card permanently. WRITE - confirm first. |
| `metabase_run_dataset_query` | Run an ad-hoc SQL or MBQL query and return rows. |
| `metabase_run_dataset_export` | Run an ad-hoc query and export as csv/json/xlsx. |
| `metabase_list_dashboards` | List dashboards; filter by f. |
| `metabase_get_dashboard` | Get one dashboard with its cards (dashcards). |
| `metabase_run_dashcard_query` | Run one card on a dashboard and return its data. |
| `metabase_create_dashboard` | Create a dashboard. WRITE - confirm first. |
| `metabase_update_dashboard` | Update or archive a dashboard. WRITE - confirm first. |
| `metabase_delete_dashboard` | Delete a dashboard. WRITE - confirm first. |
| `metabase_set_dashboard_cards` | Place/move/remove cards on a dashboard via the dashcards array. WRITE - confirm first. |
| `metabase_list_pulses` | List pulses (dashboard/question subscriptions). |
| `metabase_get_pulse` | Get one pulse with its channels and schedule. |
| `metabase_list_alerts` | List alerts (question result notifications). |
| `metabase_get_alert` | Get one alert with its channels and condition. |
| `metabase_list_collections` | List collections; optional archived/namespace. |
| `metabase_get_collection` | Get one collection (or 'root'). |
| `metabase_get_collection_items` | List items in a collection. |
| `metabase_create_collection` | Create a collection. WRITE - confirm first. |
| `metabase_update_collection` | Update or archive a collection. WRITE - confirm first. |
| `metabase_search` | Search across cards, dashboards, collections and tables. |

## How to get credentials

You need a Metabase **API key** and your Metabase **site URL**.

1. Sign in to Metabase as an admin.
2. Open **Settings** (gear icon) -> **Admin settings** -> **Settings** -> **API keys**.
3. Click **Create API key**, give it a name (e.g. *FlyMyAI Agent*) and assign it to a group whose permissions match what the agent should do.
4. Copy the generated key - it is shown only once.
5. Note your Metabase base URL (e.g. `https://metabase.example.com`) - the agent appends `/api` automatically.

See the official guide: [Metabase API keys](https://www.metabase.com/docs/latest/people-and-groups/api-keys).

## Fields to fill in FlyMyAI

| FlyMyAI field | Where it comes from |
| --- | --- |
| `METABASE_API_KEY` | Admin settings -> Settings -> API keys -> Create API key |
| `METABASE_SITE_URL` | Your Metabase base URL, e.g. `https://metabase.example.com` |
