Skip to main content

create_flight

Create a new Flight. A Flight is a Python entrypoint plus an optional requirements.txt that runs on MotherDuck compute. Optionally provide access_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 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.

The tool uses the same parameter names as MD_CREATE_FLIGHT: access_token_name and flight_secret_names.

Input parameters​

ParameterTypeRequiredDescription
namestringYesFlight name (used in logs and listings).
source_codestringYesPython source for the Flight. A single-file program, executed as a plain script; end it with if __name__ == "__main__": main() to invoke your entrypoint.
access_token_namestringNoLabel 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_cronstringNo5-field cron expression in UTC. Omit for on-demand only.
requirements_txtstringNorequirements.txt contents, one pinned package per line.
configobjectNoNon-secret key/value pairs surfaced as environment variables.
flight_secret_namesstring[]NoNames of Flight secrets whose key-value pairs are surfaced as environment variables.
metadataobjectNoFlight control metadata. The only supported key is chart: the run chart for the Flight Explainer, as raw Mermaid starting at the flowchart line. Limited to 64 KiB as UTF-8. See get_flight_viz_guide.
max_runtime_secintegerNoPer-run timeout in seconds. 0 means no timeout. Omit to use your plan's default. A value above your plan's cap is rejected.
instance_typestringNoInstance size: F4, F16, or F32. Omit to use your plan's default. A size above your plan's cap is rejected.

Output schema​

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

Example usage​

Minimal Flight:

{
"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:

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