Flights functions
SQL table functions for managing Flights, MotherDuck's scheduled Python execution. Use these functions from any MotherDuck client (DuckDB CLI, BI tool, or another Flight) to create, schedule, list, and monitor Flights without leaving SQL.
The MCP server exposes the same operations to AI agents through create_flight, list_flights, run_flight, and so on. The MCP and SQL surfaces use slightly different parameter names — see each function page for the details, or read the Flights MCP reference for the agent-facing tools.
These functions execute server-side on MotherDuck. They are not available on local-only DuckDB connections.
A minimal end-to-end Flight from SQL:
-- Create the Flight
SELECT flight_id, current_version
FROM MD_CREATE_FLIGHT(
name := 'heartbeat',
source_code := $$
import duckdb
def main():
con = duckdb.connect("md:")
con.execute("CREATE DATABASE IF NOT EXISTS flights_demo")
print("ok")
if __name__ == "__main__":
main()
$$,
requirements_txt := 'duckdb==1.5.3'
);
-- Trigger an on-demand run
CALL MD_RUN_FLIGHT(flight_id := '<flight_id>');
-- Inspect the run
SELECT run_number, status, created_at
FROM MD_LIST_FLIGHT_RUNS(flight_id := '<flight_id>')
ORDER BY run_number DESC LIMIT 1;
Available functions
MD_CREATE_FLIGHT
Create a new Flight in your MotherDuck account.
MD_UPDATE_FLIGHT
Update a Flight's source code, requirements, config, token, secrets, name, or schedule.
MD_DELETE_FLIGHT
Delete a Flight, its versions, runs, and logs.
MD_GET_FLIGHT
Fetch the summary metadata for a single Flight.
MD_GET_FLIGHT_VERSION
Fetch the full content (source, requirements, config, token, secrets) for a specific Flight version.
MD_LIST_FLIGHTS
List the Flights you own with summary metadata.
MD_LIST_FLIGHT_VERSIONS
List the version history of a Flight.
MD_RUN_FLIGHT
Trigger an on-demand execution of a Flight using its current version.
MD_LIST_FLIGHT_RUNS
List the execution history of a Flight, newest first.
MD_GET_FLIGHT_LOGS
Read the combined stdout and stderr captured during a Flight run.
MD_CANCEL_FLIGHT_RUN
Cancel an in-progress Flight run.