get_xcom_entries
Retrieve cross-communication data entries from Apache Airflow workflows to access task execution outputs and shared variables between DAG runs.
Instructions
Get all XCom entries
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| dag_run_id | Yes | ||
| limit | No | ||
| map_index | No | ||
| offset | No | ||
| task_id | Yes | ||
| xcom_key | No |
Input Schema (JSON Schema)
{
"properties": {
"dag_id": {
"title": "Dag Id",
"type": "string"
},
"dag_run_id": {
"title": "Dag Run Id",
"type": "string"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"map_index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Map Index"
},
"offset": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Offset"
},
"task_id": {
"title": "Task Id",
"type": "string"
},
"xcom_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Xcom Key"
}
},
"required": [
"dag_id",
"dag_run_id",
"task_id"
],
"type": "object"
}
Implementation Reference
- src/airflow/xcom.py:19-41 (handler)The main asynchronous handler function for the 'get_xcom_entries' tool. It constructs parameters from inputs, calls the Airflow XComApi to fetch entries, and returns the response as formatted TextContent.async def get_xcom_entries( dag_id: str, dag_run_id: str, task_id: str, map_index: Optional[int] = None, xcom_key: Optional[str] = None, limit: Optional[int] = None, offset: Optional[int] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: # Build parameters dictionary kwargs: Dict[str, Any] = {} if map_index is not None: kwargs["map_index"] = map_index if xcom_key is not None: kwargs["xcom_key"] = xcom_key if limit is not None: kwargs["limit"] = limit if offset is not None: kwargs["offset"] = offset response = xcom_api.get_xcom_entries(dag_id=dag_id, dag_run_id=dag_run_id, task_id=task_id, **kwargs) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/xcom.py:11-16 (registration)The module-level get_all_functions that provides the registration tuple for 'get_xcom_entries', imported and used in src/main.py to register the tool with the MCP server.def get_all_functions() -> list[tuple[Callable, str, str, bool]]: """Return list of (function, name, description, is_read_only) tuples for registration.""" return [ (get_xcom_entries, "get_xcom_entries", "Get all XCom entries", True), (get_xcom_entry, "get_xcom_entry", "Get an XCom entry", True), ]
- src/main.py:19-19 (registration)Import of the xcom module's get_all_functions alias as get_xcom_functions, which is mapped to APIType.XCOM and used to dynamically register tools including 'get_xcom_entries'.from src.airflow.xcom import get_all_functions as get_xcom_functions
- src/main.py:90-92 (registration)The dynamic tool registration loop in the main function that calls app.add_tool for each function from get_xcom_functions(), including 'get_xcom_entries'.for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)