# Flights

> Create, schedule, run, and monitor Flights — scheduled Python jobs on MotherDuck compute — through the MotherDuck MCP server.

## Included pages

- [get_flight_guide](https://motherduck.com/docs/sql-reference/mcp/flights/get-flight-guide): Load the canonical instructions for authoring, scheduling, running, and troubleshooting MotherDuck Flights.
- [list_flights](https://motherduck.com/docs/sql-reference/mcp/flights/list-flights): List the Flights you own with summary metadata, optionally filtered by keywords.
- [get_flight](https://motherduck.com/docs/sql-reference/mcp/flights/get-flight): Fetch a Flight's metadata and version snapshot by UUID, optionally at a specific historical version.
- [list_flight_versions](https://motherduck.com/docs/sql-reference/mcp/flights/list-flight-versions): List the version history of a Flight, newest first.
- [create_flight](https://motherduck.com/docs/sql-reference/mcp/flights/create-flight): Create a new Flight from Python source code, requirements, and an optional schedule.
- [update_flight](https://motherduck.com/docs/sql-reference/mcp/flights/update-flight): Update a Flight's source, requirements, config, token, secrets, name, or schedule.
- [edit_flight_source](https://motherduck.com/docs/sql-reference/mcp/flights/edit-flight-source): Edit a Flight's source code with one or more find-and-replace operations, producing a new version.
- [delete_flight](https://motherduck.com/docs/sql-reference/mcp/flights/delete-flight): Permanently delete a Flight, its versions, schedule, and run history.
- [run_flight](https://motherduck.com/docs/sql-reference/mcp/flights/run-flight): Trigger an on-demand execution of a Flight using its current version.
- [list_flight_runs](https://motherduck.com/docs/sql-reference/mcp/flights/list-flight-runs): List the execution history of a Flight, newest first.
- [get_flight_run_logs](https://motherduck.com/docs/sql-reference/mcp/flights/get-flight-run-logs): Fetch the logs and run record for a single Flight run.
- [cancel_flight_run](https://motherduck.com/docs/sql-reference/mcp/flights/cancel-flight-run): Cancel an in-progress Flight run.

Source: https://motherduck.com/docs/category/flights

---

## get_flight_guide

Source: https://motherduck.com/docs/sql-reference/mcp/flights/get-flight-guide

> Load the canonical instructions for authoring, scheduling, running, and troubleshooting MotherDuck Flights.

Loads the authoritative guide for working with [Flights](/concepts/flights). Call this tool first whenever the conversation turns to creating, updating, or operating a Flight, before reaching for any other `*_flight*` MCP tool.

## Description

`get_flight_guide` returns a single guide document covering: the anatomy of a Flight, the difference between config and secrets, scheduling, run lifecycle, and common failure patterns. It does not take any arguments.

The human-readable equivalent of this guide lives at the [Flights concept page](/concepts/flights). The guide returned by this tool is what AI agents should consult inside an agent session.

## Input parameters

This tool takes no arguments.

## Output schema

```json
{
  "success": boolean,
  "guide": string  // Markdown content of the guide
}
```

## Example usage

When the user asks for anything Flight-related, the assistant should call this tool before calling [`create_flight`](../create-flight) or other flight tools:

```text
Create a Flight that ingests Postgres data into MotherDuck hourly.
```

The assistant first calls `get_flight_guide`, reads the guide, and then proceeds to author the Flight.

## Related

- [`create_flight`](../create-flight) — Create a new Flight.
- [`list_flights`](../list-flights) — List Flights you own.
- [Flights concept](/concepts/flights) — The human-readable overview.

---

## list_flights

Source: https://motherduck.com/docs/sql-reference/mcp/flights/list-flights

> List the Flights you own with summary metadata, optionally filtered by keywords.

List all [Flights](/concepts/flights) owned by the caller. Each Flight in the response includes its UUID, name, schedule, status, and current version. Optionally filter by keywords matching the Flight name.

## Description

The `list_flights` tool returns Flight summary metadata, not version-specific content. Use [`get_flight`](../get-flight) with the returned `id` to fetch source code, requirements, and config.

The corresponding SQL function is [`MD_LIST_FLIGHTS`](/sql-reference/motherduck-sql-reference/flights/md-list-flights).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `keywords` | string | No | Keywords to filter Flights by name (case-insensitive, all words must match). |
| `limit` | integer | No | Max results to return (default: 100, max: 500). |

## Output schema

```json
{
  "success": boolean,
  "flights": [
    {
      "id": string,                 // Flight UUID
      "name": string,
      "schedule_cron": string|null, // Cron expression or null for on-demand
      "status": string,             // Schedule status (e.g. JOB_STATUS_ACTIVE)
      "current_version": number,
      "created_at": string,         // ISO 8601
      "updated_at": string          // ISO 8601
    }
  ],
  "count": number,
  "error": string                   // On failure
}
```

## Example usage

```text
What Flights do I have?
```

The assistant calls the tool with no arguments. To filter:

```json
{ "keywords": "metrics" }
```

## Related

- [`get_flight`](../get-flight) — Fetch a single Flight's content.
- [`MD_LIST_FLIGHTS`](/sql-reference/motherduck-sql-reference/flights/md-list-flights) — SQL equivalent.

---

## get_flight

Source: https://motherduck.com/docs/sql-reference/mcp/flights/get-flight

> Fetch a Flight's metadata and version snapshot by UUID, optionally at a specific historical version.

Fetch a single [Flight](/concepts/flights). Returns Flight metadata plus the content of a specific version (source code, requirements, config, secret names, token name). Omit `version` for the current version; pass a 1-indexed `version` to inspect history.

## Description

The `get_flight` tool combines metadata and version content into one response, so the assistant does not need separate calls for "find the Flight" and "read its source." Use it to inspect a Flight before editing, or to read the source that ran for a specific past run.

The SQL equivalent is [`MD_GET_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-get-flight) plus [`MD_GET_FLIGHT_VERSION`](/sql-reference/motherduck-sql-reference/flights/md-get-flight-version).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `version` | integer | No | 1-indexed version number. Omit for the current version. |

## Output schema

```json
{
  "success": boolean,
  "flight": {
    "id": string,
    "name": string,
    "schedule_cron": string|null,
    "status": string,
    "current_version": number,
    "version": {
      "version": number,
      "source_code": string,
      "requirements_txt": string,
      "config": { "<key>": "<value>" },
      "md_token_name": string,
      "md_secret_names": string[]
    },
    "created_at": string,
    "updated_at": string
  },
  "error": string
}
```

## Example usage

Inspect the current Flight:

```json
{ "id": "80000000-0000-0000-0000-000000000001" }
```

Inspect version 2:

```json
{ "id": "80000000-0000-0000-0000-000000000001", "version": 2 }
```

## Related

- [`list_flight_versions`](../list-flight-versions) — Find available version numbers.
- [`list_flight_runs`](../list-flight-runs) — Each run includes the version it ran against.
- [`MD_GET_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-get-flight) — SQL equivalent for current summary.

---

## list_flight_versions

Source: https://motherduck.com/docs/sql-reference/mcp/flights/list-flight-versions

> List the version history of a Flight, newest first.

List every immutable version of a [Flight](/concepts/flights), newest first. Each update to `source_code`, `requirements_txt`, `config`, `md_token_name`, or `md_secret_names` produces a fresh version. Updates to `name` or `schedule_cron` are metadata-only and do not appear here.

## Description

Use `list_flight_versions` to browse what changed between versions, or to find the version a specific run executed. The corresponding SQL function is [`MD_LIST_FLIGHT_VERSIONS`](/sql-reference/motherduck-sql-reference/flights/md-list-flight-versions).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `limit` | integer | No | Max results to return (default: 100, max: 500). |

## Output schema

```json
{
  "success": boolean,
  "versions": [
    {
      "version": number,
      "source_code": string,
      "requirements_txt": string,
      "md_token_name": string,
      "md_secret_names": string[],
      "config": { "<key>": "<value>" },
      "created_at": string
    }
  ],
  "count": number,
  "error": string
}
```

## Example usage

```json
{ "id": "80000000-0000-0000-0000-000000000001" }
```

## Related

- [`get_flight`](../get-flight) — Fetch one version's full content.
- [`list_flight_runs`](../list-flight-runs) — Runs reference the version they used.
- [`MD_LIST_FLIGHT_VERSIONS`](/sql-reference/motherduck-sql-reference/flights/md-list-flight-versions) — SQL equivalent.

---

## create_flight

Source: https://motherduck.com/docs/sql-reference/mcp/flights/create-flight

> Create a new Flight from Python source code, requirements, and an optional schedule.

Create a new [Flight](/concepts/flights). A Flight is a Python entrypoint plus an optional `requirements.txt` that runs on MotherDuck compute. Optionally provide `md_token_name` to run the Flight as a specific access token; omit it to use the default `MotherDuck Flights` access token. Optionally provide a 5-field cron expression to run on a schedule.

You are responsible for the code you run and the packages it installs. Flights does not scan customer code or dependencies. Avoid untrusted packages, pin dependency versions, and treat dependency installs as a supply-chain risk.

Call [`get_flight_guide`](../get-flight-guide) first if you need the authoring reference.

## Description

`create_flight` is the marquee entry point for the MCP Flights surface. The SQL equivalent is [`MD_CREATE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-create-flight).

The parameter names on the MCP tool keep the `md_*` prefix (for example, `md_token_name`, `md_secret_names`); the equivalent SQL function uses unprefixed names (`access_token_name`, `flight_secret_names`).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | Yes | Flight name (used in logs and listings). |
| `source_code` | string | Yes | Python source for the Flight. A single-file program, executed as a plain script; end it with `if __name__ == "__main__": main()` to invoke your entrypoint. |
| `md_token_name` | string | No | Label of a MotherDuck access token to run the Flight as. Injected as `MOTHERDUCK_TOKEN` at runtime. Omit it to use the default `MotherDuck Flights` access token. List labels with `SELECT * FROM md_access_tokens();`. |
| `schedule_cron` | string | No | 5-field cron expression in UTC. Omit for on-demand only. |
| `requirements_txt` | string | No | `requirements.txt` contents, one pinned package per line. |
| `config` | object | No | Non-secret key/value pairs surfaced as environment variables. |
| `md_secret_names` | string[] | No | Names of [Flight secrets](/sql-reference/motherduck-sql-reference/create-secret#flight-secrets) whose key-value pairs are surfaced as environment variables. |

## Output schema

```json
{
  "success": boolean,
  "flight": {
    "id": string,
    "name": string,
    "schedule_cron": string|null,
    "current_version": number
  },
  "error": string
}
```

## Example usage

Minimal Flight:

```json
{
  "name": "heartbeat",
  "source_code": "import duckdb\n\ndef main():\n    duckdb.connect('md:').execute('SELECT 1').fetchall()\n    print('ok')\n\nif __name__ == \"__main__\":\n    main()\n",
  "requirements_txt": "duckdb==1.5.3"
}
```

Scheduled Flight with config, running as a specific access token:

```json
{
  "name": "hourly_metrics",
  "source_code": "...",
  "md_token_name": "analytics_token",
  "requirements_txt": "duckdb==1.5.3\nrequests==2.32.4",
  "schedule_cron": "0 * * * *",
  "config": { "REGION": "eu-central-1" }
}
```

## Related

- [`update_flight`](../update-flight) — Modify an existing Flight.
- [`edit_flight_source`](../edit-flight-source) — Surgical source edit.
- [`run_flight`](../run-flight) — Trigger a manual run after creation.
- [`MD_CREATE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-create-flight) — SQL equivalent.

---

## update_flight

Source: https://motherduck.com/docs/sql-reference/mcp/flights/update-flight

> Update a Flight's source, requirements, config, token, secrets, name, or schedule.

Update a [Flight](/concepts/flights). Any subset of `name`, `source_code`, `requirements_txt`, `schedule_cron`, `config`, `md_token_name`, or `md_secret_names` may be provided.

Updates to `source_code`, `requirements_txt`, `config`, `md_secret_names`, or `md_token_name` produce a new `FlightVersion`. Updates to `name` or `schedule_cron` are metadata-only.

You are responsible for the code you run and the packages it installs. Flights does not scan customer code or dependencies. Avoid untrusted packages, pin dependency versions, and treat dependency installs as a supply-chain risk.

## Description

`update_flight` is a PATCH operation: omitted fields are left unchanged. To clear the schedule, pass `schedule_cron` as an empty string; omitting it leaves the schedule unchanged.

`config` and `md_secret_names` are **full replacements** — to change one entry, send the full map or list with the change applied.

The SQL equivalent is [`MD_UPDATE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-update-flight).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `name` | string | No | Updated Flight name. Metadata-only. |
| `schedule_cron` | string | No | Updated 5-field cron expression (UTC). Pass `""` to clear the schedule. Metadata-only. |
| `source_code` | string | No | Updated Python entrypoint source. Bumps the version. |
| `requirements_txt` | string | No | Updated `requirements.txt` contents. Bumps the version. |
| `config` | object | No | Replacement config map (full replace). Bumps the version. |
| `md_token_name` | string | No | Updated MotherDuck access token label. Bumps the version. |
| `md_secret_names` | string[] | No | Replacement list of secret names (full replace). Bumps the version. |

## Output schema

```json
{
  "success": boolean,
  "flight": {
    "id": string,
    "name": string,
    "schedule_cron": string|null,
    "current_version": number
  },
  "error": string
}
```

## Example usage

Rename only:

```json
{ "id": "80000000-...", "name": "analytics_hourly_sync" }
```

Update source (bumps version):

```json
{
  "id": "80000000-...",
  "source_code": "def main():\n    print('v2')\n\nif __name__ == \"__main__\":\n    main()\n"
}
```

Clear the schedule:

```json
{ "id": "80000000-...", "schedule_cron": "" }
```

## Related

- [`edit_flight_source`](../edit-flight-source) — Edit source without resending the whole file.
- [`get_flight`](../get-flight) — Read current state before editing.
- [`MD_UPDATE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-update-flight) — SQL equivalent.

---

## edit_flight_source

Source: https://motherduck.com/docs/sql-reference/mcp/flights/edit-flight-source

> Edit a Flight's source code with one or more find-and-replace operations, producing a new version.

Edit a [Flight](/concepts/flights)'s `source_code` by applying one or more text replacements, then save as a new `FlightVersion`. The tool reads the current source, applies the edits in sequence, validates the result, and persists.

You are responsible for the code you run. Flights does not scan customer code. Avoid untrusted code and treat source edits as a security-sensitive change.

Use this when you want to change a small part of a Flight without resending the entire file through [`update_flight`](../update-flight).

## Description

Each edit is a `{old_string, new_string, replace_all?}` object. `old_string` must occur exactly once in the source unless `replace_all` is true. Edits apply sequentially: edit N sees the source after edits 1 through N-1.

No prior `get_flight` call is required — the tool reads the current source itself.

This tool is MCP-only; there is no direct SQL equivalent. To achieve the same outcome in SQL, read the source through [`MD_GET_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-get-flight), modify it client-side, and call [`MD_UPDATE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-update-flight) with the full updated source.

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `edits` | array | Yes | List of edit objects (see below). Must contain at least one. |

Each entry in `edits`:

| Field | Type | Required | Description |
|---|---|---|---|
| `old_string` | string | Yes | Exact text to find and replace. Must be unique in the source unless `replace_all` is true. |
| `new_string` | string | Yes | The replacement text. Must differ from `old_string`. |
| `replace_all` | boolean | No | If true, replace every occurrence. Default `false`. |

## Output schema

```json
{
  "success": boolean,
  "flight": {
    "id": string,
    "name": string,
    "current_version": number
  },
  "error": string
}
```

## Example usage

Change one line:

```json
{
  "id": "80000000-...",
  "edits": [
    {
      "old_string": "duckdb==1.5.2",
      "new_string": "duckdb==1.5.3"
    }
  ]
}
```

Rename every occurrence of a variable:

```json
{
  "id": "80000000-...",
  "edits": [
    {
      "old_string": "raw_table",
      "new_string": "raw_events",
      "replace_all": true
    }
  ]
}
```

## Related

- [`update_flight`](../update-flight) — Send a full replacement source.
- [`get_flight`](../get-flight) — Inspect the source before editing.
- [`list_flight_versions`](../list-flight-versions) — See the versions created by edits.

---

## delete_flight

Source: https://motherduck.com/docs/sql-reference/mcp/flights/delete-flight

> Permanently delete a Flight, its versions, schedule, and run history.

Permanently delete a [Flight](/concepts/flights), including all versions, schedule, and run history. This action cannot be undone.

The SQL equivalent is [`MD_DELETE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-delete-flight).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |

## Output schema

```json
{
  "success": boolean,
  "error": string
}
```

## Example usage

```json
{ "id": "80000000-0000-0000-0000-000000000001" }
```

After deletion, calls to other `*_flight*` tools with the same `id` return `does not exist`.

## Related

- [`list_flights`](../list-flights) — Verify the Flight is gone.
- [`MD_DELETE_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-delete-flight) — SQL equivalent.

---

## run_flight

Source: https://motherduck.com/docs/sql-reference/mcp/flights/run-flight

> Trigger an on-demand execution of a Flight using its current version.

Trigger an on-demand execution of a [Flight](/concepts/flights). Returns a Run record immediately; the run is asynchronous and starts in `PENDING` or `RUNNING`. Use [`list_flight_runs`](../list-flight-runs) to poll for completion and [`get_flight_run_logs`](../get-flight-run-logs) to read the output.

The SQL equivalent is [`MD_RUN_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-run-flight).

## Description

`run_flight` locks the new run to the Flight's current version. Subsequent updates to the Flight do not affect this run; only the next run picks up the updated source.

Pass `config` to override stored config values for a single run. You can override only keys the Flight already defines; the override applies to that run alone and leaves the stored config and version untouched.

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `config` | object | No | Per-run config overrides as a JSON object of string key-value pairs. Only keys already defined on the Flight can be set. |

## Output schema

```json
{
  "success": boolean,
  "run": {
    "run_id": string,
    "flight_id": string,
    "flight_name": string,
    "flight_version": number,
    "config": object,         // effective config for this run, including per-run overrides
    "run_number": number,
    "is_scheduled": boolean,  // false for on-demand
    "status": string,         // PENDING | RUNNING
    "created_at": string,
    "started_at": null,       // timing fields are still null when run_flight returns
    "ended_at": null,
    "scheduled_at": string,
    "cancelled_at": null,
    "exit_code": null
  },
  "error": string
}
```

## Example usage

```json
{ "id": "80000000-0000-0000-0000-000000000001" }
```

With a per-run config override:

```json
{ "id": "80000000-0000-0000-0000-000000000001", "config": { "REGION": "eu-central-1" } }
```

## Related

- [`list_flight_runs`](../list-flight-runs) — Watch for completion.
- [`get_flight_run_logs`](../get-flight-run-logs) — Read stdout/stderr.
- [`cancel_flight_run`](../cancel-flight-run) — Cancel an in-progress run.
- [`MD_RUN_FLIGHT`](/sql-reference/motherduck-sql-reference/flights/md-run-flight) — SQL equivalent.

---

## list_flight_runs

Source: https://motherduck.com/docs/sql-reference/mcp/flights/list-flight-runs

> List the execution history of a Flight, newest first.

List the runs of a [Flight](/concepts/flights), newest first. Each run has a sequential `run_number`, a status (`PENDING`, `RUNNING`, `SUCCEEDED`, `FAILED`, or `CANCELLED`), timing metadata, and the effective `config` it ran with: the Flight version's stored config merged with any [per-run overrides](../run-flight).

The SQL equivalent is [`MD_LIST_FLIGHT_RUNS`](/sql-reference/motherduck-sql-reference/flights/md-list-flight-runs).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `limit` | integer | No | Max results to return (default: 100, max: 500). |

## Output schema

```json
{
  "success": boolean,
  "flight_id": string,
  "runs": [
    {
      "run_id": string,
      "flight_id": string,
      "flight_name": string,
      "flight_version": number,
      "config": object,         // effective config for the run, including per-run overrides
      "run_number": number,
      "is_scheduled": boolean,
      "status": string,
      "created_at": string,
      "started_at": string,
      "ended_at": string,
      "scheduled_at": string,
      "cancelled_at": string,   // null unless the run was cancelled
      "exit_code": number
    }
  ],
  "count": number,
  "totalCount": number,
  "error": string
}
```

## Example usage

```json
{ "id": "80000000-0000-0000-0000-000000000001", "limit": 10 }
```

## Related

- [`run_flight`](../run-flight) — Trigger an on-demand run.
- [`get_flight_run_logs`](../get-flight-run-logs) — Read a run's output.
- [`cancel_flight_run`](../cancel-flight-run) — Cancel an in-progress run.
- [`MD_LIST_FLIGHT_RUNS`](/sql-reference/motherduck-sql-reference/flights/md-list-flight-runs) — SQL equivalent.

---

## get_flight_run_logs

Source: https://motherduck.com/docs/sql-reference/mcp/flights/get-flight-run-logs

> Fetch the logs and run record for a single Flight run.

Fetch the plain-text combined stdout and stderr of a [Flight](/concepts/flights) run, plus the matching `Run` record (status, exit code, timing). The response also reports whether the log was truncated.

The SQL equivalent is [`MD_GET_FLIGHT_LOGS`](/sql-reference/motherduck-sql-reference/flights/md-get-flight-logs) — note that the SQL surface returns only the logs, while this MCP tool also returns the run record.

## Description

Use `get_flight_run_logs` to interpret a failed run without a follow-up call: status, exit code, and timing arrive in the same response as the log content. For runs with large logs, pass `max_bytes` to cap the response size; the response returns the tail and sets `truncated: true`.

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `run_number` | integer | Yes | Sequential run number from [`list_flight_runs`](../list-flight-runs). |
| `max_bytes` | integer | No | Maximum log bytes to return. Minimum 1024. Truncation returns the tail. |

## Output schema

```json
{
  "success": boolean,
  "flight_id": string,
  "run_number": number,
  "run": {
    "run_id": string,
    "flight_id": string,
    "flight_name": string,
    "flight_version": number,
    "config": object,          // effective config for the run, including per-run overrides
    "run_number": number,
    "is_scheduled": boolean,
    "status": string,          // PENDING | RUNNING | SUCCEEDED | FAILED | CANCELLED
    "created_at": string,
    "started_at": string|null,
    "ended_at": string|null,
    "scheduled_at": string,
    "cancelled_at": string|null,
    "exit_code": number|null
  },
  "logs": string,              // Combined stdout + stderr
  "truncated": boolean,        // True if max_bytes truncated the log
  "original_length": number,   // Full log length in bytes, present when truncated
  "error": string
}
```

## Example usage

Read the full logs for run 42:

```json
{ "id": "80000000-...", "run_number": 42 }
```

Read only the last 4 KB:

```json
{ "id": "80000000-...", "run_number": 42, "max_bytes": 4096 }
```

## Related

- [`list_flight_runs`](../list-flight-runs) — Find the `run_number` to read.
- [`MD_GET_FLIGHT_LOGS`](/sql-reference/motherduck-sql-reference/flights/md-get-flight-logs) — SQL equivalent (logs only).

---

## cancel_flight_run

Source: https://motherduck.com/docs/sql-reference/mcp/flights/cancel-flight-run

> Cancel an in-progress Flight run.

Cancel an in-progress run of a [Flight](/concepts/flights), identified by the Flight UUID and the sequential `run_number` (from [`list_flight_runs`](../list-flight-runs)).

Returns `canceled: true` on a successful transition. Calling on an already-terminal run (`SUCCEEDED`, `FAILED`, `CANCELLED`) or one that doesn't exist returns a tool error.

The SQL equivalent is [`MD_CANCEL_FLIGHT_RUN`](/sql-reference/motherduck-sql-reference/flights/md-cancel-flight-run).

## Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `id` | string (UUID) | Yes | The Flight UUID. |
| `run_number` | integer | Yes | Sequential run number to cancel. |

## Output schema

```json
{
  "success": boolean,
  "canceled": boolean,
  "error": string
}
```

## Example usage

```json
{ "id": "80000000-0000-0000-0000-000000000001", "run_number": 42 }
```

## Related

- [`list_flight_runs`](../list-flight-runs) — Find runs that are still in progress.
- [`run_flight`](../run-flight) — Trigger a new run.
- [`MD_CANCEL_FLIGHT_RUN`](/sql-reference/motherduck-sql-reference/flights/md-cancel-flight-run) — SQL equivalent.

---
