get_xcom_entry
Retrieve cross-communication data between Airflow tasks by specifying DAG, task, and XCom key identifiers.
Instructions
Get an XCom entry
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| dag_run_id | Yes | ||
| deserialize | No | ||
| map_index | No | ||
| stringify | No | ||
| task_id | Yes | ||
| xcom_key | Yes |
Input Schema (JSON Schema)
{
"properties": {
"dag_id": {
"title": "Dag Id",
"type": "string"
},
"dag_run_id": {
"title": "Dag Run Id",
"type": "string"
},
"deserialize": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Deserialize"
},
"map_index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Map Index"
},
"stringify": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Stringify"
},
"task_id": {
"title": "Task Id",
"type": "string"
},
"xcom_key": {
"title": "Xcom Key",
"type": "string"
}
},
"required": [
"dag_id",
"dag_run_id",
"task_id",
"xcom_key"
],
"type": "object"
}
Implementation Reference
- src/airflow/xcom.py:43-64 (handler)The main handler function for the 'get_xcom_entry' tool. It takes parameters for DAG, run, task, and XCom key, calls the Airflow XComApi, and returns the response as TextContent.async def get_xcom_entry( dag_id: str, dag_run_id: str, task_id: str, xcom_key: str, map_index: Optional[int] = None, deserialize: Optional[bool] = None, stringify: Optional[bool] = 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 deserialize is not None: kwargs["deserialize"] = deserialize if stringify is not None: kwargs["stringify"] = stringify response = xcom_api.get_xcom_entry( dag_id=dag_id, dag_run_id=dag_run_id, task_id=task_id, xcom_key=xcom_key, **kwargs ) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/xcom.py:13-16 (registration)The registration tuple for 'get_xcom_entry' within the module's get_all_functions(), which is used by main.py to register the tool with the MCP server.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:75-98 (registration)The main() function in src/main.py collects functions from all modules (including xcom via get_xcom_functions) and registers them using app.add_tool in the MCP server.def main(transport: str, apis: list[str], read_only: bool) -> None: from src.server import app for api in apis: logging.debug(f"Adding API: {api}") get_function = APITYPE_TO_FUNCTIONS[APIType(api)] try: functions = get_function() except NotImplementedError: continue # Filter functions for read-only mode if requested if read_only: functions = filter_functions_for_read_only(functions) for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description) if transport == "sse": logging.debug("Starting MCP server for Apache Airflow with SSE transport") app.run(transport="sse") else: logging.debug("Starting MCP server for Apache Airflow with stdio transport") app.run(transport="stdio")