mcp-server-apache-airflow 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/PKG-INFO +82 -7
  2. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/README.md +81 -6
  3. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/pyproject.toml +7 -2
  4. mcp_server_apache_airflow-0.2.2/src/__init__.py +0 -0
  5. mcp_server_apache_airflow-0.2.2/src/airflow/__init__.py +0 -0
  6. mcp_server_apache_airflow-0.2.2/src/airflow/airflow_client.py +11 -0
  7. mcp_server_apache_airflow-0.2.2/src/airflow/config.py +34 -0
  8. mcp_server_apache_airflow-0.2.2/src/airflow/connection.py +139 -0
  9. mcp_server_apache_airflow-0.2.2/src/airflow/dag.py +273 -0
  10. mcp_server_apache_airflow-0.2.2/src/airflow/dagrun.py +226 -0
  11. mcp_server_apache_airflow-0.2.2/src/airflow/dagstats.py +26 -0
  12. mcp_server_apache_airflow-0.2.2/src/airflow/dataset.py +159 -0
  13. mcp_server_apache_airflow-0.2.2/src/airflow/eventlog.py +74 -0
  14. mcp_server_apache_airflow-0.2.2/src/airflow/importerror.py +40 -0
  15. mcp_server_apache_airflow-0.2.2/src/airflow/monitoring.py +32 -0
  16. mcp_server_apache_airflow-0.2.2/src/airflow/plugin.py +39 -0
  17. mcp_server_apache_airflow-0.2.2/src/airflow/pool.py +146 -0
  18. mcp_server_apache_airflow-0.2.2/src/airflow/provider.py +39 -0
  19. mcp_server_apache_airflow-0.2.2/src/airflow/taskinstance.py +96 -0
  20. mcp_server_apache_airflow-0.2.2/src/airflow/variable.py +75 -0
  21. mcp_server_apache_airflow-0.2.2/src/airflow/xcom.py +63 -0
  22. mcp_server_apache_airflow-0.2.2/src/enums.py +18 -0
  23. mcp_server_apache_airflow-0.2.2/src/main.py +67 -0
  24. mcp_server_apache_airflow-0.2.0/src/__init__.py +0 -2
  25. mcp_server_apache_airflow-0.2.0/src/airflow.py +0 -537
  26. mcp_server_apache_airflow-0.2.0/src/main.py +0 -17
  27. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/.gitignore +0 -0
  28. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/LICENSE +0 -0
  29. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/src/__main__.py +0 -0
  30. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/src/envs.py +0 -0
  31. {mcp_server_apache_airflow-0.2.0 → mcp_server_apache_airflow-0.2.2}/src/server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-server-apache-airflow
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Model Context Protocol (MCP) server for Apache Airflow
5
5
  Project-URL: Homepage, https://github.com/yangkyeongmo/mcp-server-apache-airflow
6
6
  Project-URL: Repository, https://github.com/yangkyeongmo/mcp-server-apache-airflow.git
@@ -31,6 +31,10 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  A Model Context Protocol (MCP) server implementation for Apache Airflow, enabling seamless integration with MCP clients. This project provides a standardized way to interact with Apache Airflow through the Model Context Protocol.
33
33
 
34
+ <a href="https://glama.ai/mcp/servers/e99b6vx9lw">
35
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/e99b6vx9lw/badge" alt="Server for Apache Airflow MCP server" />
36
+ </a>
37
+
34
38
  ## About
35
39
 
36
40
  This project implements a [Model Context Protocol](https://modelcontextprotocol.io/introduction) server that wraps Apache Airflow's REST API, allowing MCP clients to interact with Airflow in a standardized way. It uses the official Apache Airflow client library to ensure compatibility and maintainability.
@@ -44,25 +48,29 @@ This project implements a [Model Context Protocol](https://modelcontextprotocol.
44
48
  | Get DAG Details | `/api/v1/dags/{dag_id}` | ✅ |
45
49
  | Pause DAG | `/api/v1/dags/{dag_id}` | ✅ |
46
50
  | Unpause DAG | `/api/v1/dags/{dag_id}` | ✅ |
47
- | Update DAG | `/api/v1/dags/{dag_id}` | ✅ | |
51
+ | Update DAG | `/api/v1/dags/{dag_id}` | ✅ |
48
52
  | Delete DAG | `/api/v1/dags/{dag_id}` | ✅ |
53
+ | Get DAG Source | `/api/v1/dagSources/{file_token}` | ✅ |
54
+ | Patch Multiple DAGs | `/api/v1/dags` | ✅ |
55
+ | Reparse DAG File | `/api/v1/dagSources/{file_token}/reparse` | ✅ |
49
56
  | **DAG Runs** | | |
50
57
  | List DAG Runs | `/api/v1/dags/{dag_id}/dagRuns` | ✅ |
51
58
  | Create DAG Run | `/api/v1/dags/{dag_id}/dagRuns` | ✅ |
52
59
  | Get DAG Run Details | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
53
60
  | Update DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
54
61
  | Delete DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
62
+ | Get DAG Runs Batch | `/api/v1/dags/~/dagRuns/list` | ✅ |
63
+ | Clear DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/clear` | ✅ |
64
+ | Set DAG Run Note | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/setNote` | ✅ |
65
+ | Get Upstream Dataset Events | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/upstreamDatasetEvents` | ✅ |
55
66
  | **Tasks** | | |
56
67
  | List DAG Tasks | `/api/v1/dags/{dag_id}/tasks` | ✅ |
57
68
  | Get Task Details | `/api/v1/dags/{dag_id}/tasks/{task_id}` | ✅ |
58
69
  | Get Task Instance | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}` | ✅ |
59
70
  | List Task Instances | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances` | ✅ |
60
71
  | Update Task Instance | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}` | ✅ |
61
- | **System** | | |
62
- | Get Import Errors | `/api/v1/importErrors` | ✅ |
63
- | Get Import Error Details | `/api/v1/importErrors/{import_error_id}` | ✅ |
64
- | Get Health Status | `/api/v1/health` | ✅ |
65
- | Get Version | `/api/v1/version` | ✅ |
72
+ | Clear Task Instances | `/api/v1/dags/{dag_id}/clearTaskInstances` | ✅ |
73
+ | Set Task Instances State | `/api/v1/dags/{dag_id}/updateTaskInstancesState` | ✅ |
66
74
  | **Variables** | | |
67
75
  | List Variables | `/api/v1/variables` | ✅ |
68
76
  | Create Variable | `/api/v1/variables` | ✅ |
@@ -75,6 +83,45 @@ This project implements a [Model Context Protocol](https://modelcontextprotocol.
75
83
  | Get Connection | `/api/v1/connections/{connection_id}` | ✅ |
76
84
  | Update Connection | `/api/v1/connections/{connection_id}` | ✅ |
77
85
  | Delete Connection | `/api/v1/connections/{connection_id}` | ✅ |
86
+ | Test Connection | `/api/v1/connections/test` | ✅ |
87
+ | **Pools** | | |
88
+ | List Pools | `/api/v1/pools` | ✅ |
89
+ | Create Pool | `/api/v1/pools` | ✅ |
90
+ | Get Pool | `/api/v1/pools/{pool_name}` | ✅ |
91
+ | Update Pool | `/api/v1/pools/{pool_name}` | ✅ |
92
+ | Delete Pool | `/api/v1/pools/{pool_name}` | ✅ |
93
+ | **XComs** | | |
94
+ | List XComs | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries` | ✅ |
95
+ | Get XCom Entry | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}` | ✅ |
96
+ | **Datasets** | | |
97
+ | List Datasets | `/api/v1/datasets` | ✅ |
98
+ | Get Dataset | `/api/v1/datasets/{uri}` | ✅ |
99
+ | Get Dataset Events | `/api/v1/datasetEvents` | ✅ |
100
+ | Create Dataset Event | `/api/v1/datasetEvents` | ✅ |
101
+ | Get DAG Dataset Queued Event | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents/{uri}` | ✅ |
102
+ | Get DAG Dataset Queued Events | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents` | ✅ |
103
+ | Delete DAG Dataset Queued Event | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents/{uri}` | ✅ |
104
+ | Delete DAG Dataset Queued Events | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents` | ✅ |
105
+ | Get Dataset Queued Events | `/api/v1/datasets/{uri}/dagRuns/queued/datasetEvents` | ✅ |
106
+ | Delete Dataset Queued Events | `/api/v1/datasets/{uri}/dagRuns/queued/datasetEvents` | ✅ |
107
+ | **Monitoring** | | |
108
+ | Get Health | `/api/v1/health` | ✅ |
109
+ | **DAG Stats** | | |
110
+ | Get DAG Stats | `/api/v1/dags/statistics` | ✅ |
111
+ | **Config** | | |
112
+ | Get Config | `/api/v1/config` | ✅ |
113
+ | **Plugins** | | |
114
+ | Get Plugins | `/api/v1/plugins` | ✅ |
115
+ | **Providers** | | |
116
+ | List Providers | `/api/v1/providers` | ✅ |
117
+ | **Event Logs** | | |
118
+ | List Event Logs | `/api/v1/eventLogs` | ✅ |
119
+ | Get Event Log | `/api/v1/eventLogs/{event_log_id}` | ✅ |
120
+ | **System** | | |
121
+ | Get Import Errors | `/api/v1/importErrors` | ✅ |
122
+ | Get Import Error Details | `/api/v1/importErrors/{import_error_id}` | ✅ |
123
+ | Get Health Status | `/api/v1/health` | ✅ |
124
+ | Get Version | `/api/v1/version` | ✅ |
78
125
 
79
126
  ## Setup
80
127
 
@@ -136,6 +183,34 @@ Alternative configuration using `uv`:
136
183
 
137
184
  Replace `/path/to/mcp-server-apache-airflow` with the actual path where you've cloned the repository.
138
185
 
186
+ ### Selecting the API groups
187
+
188
+ You can select the API groups you want to use by setting the `--apis` flag.
189
+
190
+ ```bash
191
+ uv run mcp-server-apache-airflow --apis "dag,dagrun"
192
+ ```
193
+
194
+ The default is to use all APIs.
195
+
196
+ Allowed values are:
197
+
198
+ - config
199
+ - connections
200
+ - dag
201
+ - dagrun
202
+ - dagstats
203
+ - dataset
204
+ - eventlog
205
+ - importerror
206
+ - monitoring
207
+ - plugin
208
+ - pool
209
+ - provider
210
+ - taskinstance
211
+ - variable
212
+ - xcom
213
+
139
214
  ### Manual Execution
140
215
 
141
216
  You can also run the server manually:
@@ -2,6 +2,10 @@
2
2
 
3
3
  A Model Context Protocol (MCP) server implementation for Apache Airflow, enabling seamless integration with MCP clients. This project provides a standardized way to interact with Apache Airflow through the Model Context Protocol.
4
4
 
5
+ <a href="https://glama.ai/mcp/servers/e99b6vx9lw">
6
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/e99b6vx9lw/badge" alt="Server for Apache Airflow MCP server" />
7
+ </a>
8
+
5
9
  ## About
6
10
 
7
11
  This project implements a [Model Context Protocol](https://modelcontextprotocol.io/introduction) server that wraps Apache Airflow's REST API, allowing MCP clients to interact with Airflow in a standardized way. It uses the official Apache Airflow client library to ensure compatibility and maintainability.
@@ -15,25 +19,29 @@ This project implements a [Model Context Protocol](https://modelcontextprotocol.
15
19
  | Get DAG Details | `/api/v1/dags/{dag_id}` | ✅ |
16
20
  | Pause DAG | `/api/v1/dags/{dag_id}` | ✅ |
17
21
  | Unpause DAG | `/api/v1/dags/{dag_id}` | ✅ |
18
- | Update DAG | `/api/v1/dags/{dag_id}` | ✅ | |
22
+ | Update DAG | `/api/v1/dags/{dag_id}` | ✅ |
19
23
  | Delete DAG | `/api/v1/dags/{dag_id}` | ✅ |
24
+ | Get DAG Source | `/api/v1/dagSources/{file_token}` | ✅ |
25
+ | Patch Multiple DAGs | `/api/v1/dags` | ✅ |
26
+ | Reparse DAG File | `/api/v1/dagSources/{file_token}/reparse` | ✅ |
20
27
  | **DAG Runs** | | |
21
28
  | List DAG Runs | `/api/v1/dags/{dag_id}/dagRuns` | ✅ |
22
29
  | Create DAG Run | `/api/v1/dags/{dag_id}/dagRuns` | ✅ |
23
30
  | Get DAG Run Details | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
24
31
  | Update DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
25
32
  | Delete DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}` | ✅ |
33
+ | Get DAG Runs Batch | `/api/v1/dags/~/dagRuns/list` | ✅ |
34
+ | Clear DAG Run | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/clear` | ✅ |
35
+ | Set DAG Run Note | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/setNote` | ✅ |
36
+ | Get Upstream Dataset Events | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/upstreamDatasetEvents` | ✅ |
26
37
  | **Tasks** | | |
27
38
  | List DAG Tasks | `/api/v1/dags/{dag_id}/tasks` | ✅ |
28
39
  | Get Task Details | `/api/v1/dags/{dag_id}/tasks/{task_id}` | ✅ |
29
40
  | Get Task Instance | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}` | ✅ |
30
41
  | List Task Instances | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances` | ✅ |
31
42
  | Update Task Instance | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}` | ✅ |
32
- | **System** | | |
33
- | Get Import Errors | `/api/v1/importErrors` | ✅ |
34
- | Get Import Error Details | `/api/v1/importErrors/{import_error_id}` | ✅ |
35
- | Get Health Status | `/api/v1/health` | ✅ |
36
- | Get Version | `/api/v1/version` | ✅ |
43
+ | Clear Task Instances | `/api/v1/dags/{dag_id}/clearTaskInstances` | ✅ |
44
+ | Set Task Instances State | `/api/v1/dags/{dag_id}/updateTaskInstancesState` | ✅ |
37
45
  | **Variables** | | |
38
46
  | List Variables | `/api/v1/variables` | ✅ |
39
47
  | Create Variable | `/api/v1/variables` | ✅ |
@@ -46,6 +54,45 @@ This project implements a [Model Context Protocol](https://modelcontextprotocol.
46
54
  | Get Connection | `/api/v1/connections/{connection_id}` | ✅ |
47
55
  | Update Connection | `/api/v1/connections/{connection_id}` | ✅ |
48
56
  | Delete Connection | `/api/v1/connections/{connection_id}` | ✅ |
57
+ | Test Connection | `/api/v1/connections/test` | ✅ |
58
+ | **Pools** | | |
59
+ | List Pools | `/api/v1/pools` | ✅ |
60
+ | Create Pool | `/api/v1/pools` | ✅ |
61
+ | Get Pool | `/api/v1/pools/{pool_name}` | ✅ |
62
+ | Update Pool | `/api/v1/pools/{pool_name}` | ✅ |
63
+ | Delete Pool | `/api/v1/pools/{pool_name}` | ✅ |
64
+ | **XComs** | | |
65
+ | List XComs | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries` | ✅ |
66
+ | Get XCom Entry | `/api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}` | ✅ |
67
+ | **Datasets** | | |
68
+ | List Datasets | `/api/v1/datasets` | ✅ |
69
+ | Get Dataset | `/api/v1/datasets/{uri}` | ✅ |
70
+ | Get Dataset Events | `/api/v1/datasetEvents` | ✅ |
71
+ | Create Dataset Event | `/api/v1/datasetEvents` | ✅ |
72
+ | Get DAG Dataset Queued Event | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents/{uri}` | ✅ |
73
+ | Get DAG Dataset Queued Events | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents` | ✅ |
74
+ | Delete DAG Dataset Queued Event | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents/{uri}` | ✅ |
75
+ | Delete DAG Dataset Queued Events | `/api/v1/dags/{dag_id}/dagRuns/queued/datasetEvents` | ✅ |
76
+ | Get Dataset Queued Events | `/api/v1/datasets/{uri}/dagRuns/queued/datasetEvents` | ✅ |
77
+ | Delete Dataset Queued Events | `/api/v1/datasets/{uri}/dagRuns/queued/datasetEvents` | ✅ |
78
+ | **Monitoring** | | |
79
+ | Get Health | `/api/v1/health` | ✅ |
80
+ | **DAG Stats** | | |
81
+ | Get DAG Stats | `/api/v1/dags/statistics` | ✅ |
82
+ | **Config** | | |
83
+ | Get Config | `/api/v1/config` | ✅ |
84
+ | **Plugins** | | |
85
+ | Get Plugins | `/api/v1/plugins` | ✅ |
86
+ | **Providers** | | |
87
+ | List Providers | `/api/v1/providers` | ✅ |
88
+ | **Event Logs** | | |
89
+ | List Event Logs | `/api/v1/eventLogs` | ✅ |
90
+ | Get Event Log | `/api/v1/eventLogs/{event_log_id}` | ✅ |
91
+ | **System** | | |
92
+ | Get Import Errors | `/api/v1/importErrors` | ✅ |
93
+ | Get Import Error Details | `/api/v1/importErrors/{import_error_id}` | ✅ |
94
+ | Get Health Status | `/api/v1/health` | ✅ |
95
+ | Get Version | `/api/v1/version` | ✅ |
49
96
 
50
97
  ## Setup
51
98
 
@@ -107,6 +154,34 @@ Alternative configuration using `uv`:
107
154
 
108
155
  Replace `/path/to/mcp-server-apache-airflow` with the actual path where you've cloned the repository.
109
156
 
157
+ ### Selecting the API groups
158
+
159
+ You can select the API groups you want to use by setting the `--apis` flag.
160
+
161
+ ```bash
162
+ uv run mcp-server-apache-airflow --apis "dag,dagrun"
163
+ ```
164
+
165
+ The default is to use all APIs.
166
+
167
+ Allowed values are:
168
+
169
+ - config
170
+ - connections
171
+ - dag
172
+ - dagrun
173
+ - dagstats
174
+ - dataset
175
+ - eventlog
176
+ - importerror
177
+ - monitoring
178
+ - plugin
179
+ - pool
180
+ - provider
181
+ - taskinstance
182
+ - variable
183
+ - xcom
184
+
110
185
  ### Manual Execution
111
186
 
112
187
  You can also run the server manually:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-server-apache-airflow"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Model Context Protocol (MCP) server for Apache Airflow"
5
5
  authors = [
6
6
  { name = "Gyeongmo Yang", email = "me@gmyang.dev" }
@@ -42,7 +42,7 @@ requires = ["hatchling"]
42
42
  build-backend = "hatchling.build"
43
43
 
44
44
  [project.scripts]
45
- mcp-server-apache-airflow = "server:main"
45
+ mcp-server-apache-airflow = "src.main:main"
46
46
 
47
47
  [tool.hatch.build.targets.wheel]
48
48
  packages = ["src"]
@@ -57,3 +57,8 @@ include = [
57
57
  [tool.ruff]
58
58
  select = ["E", "W", "F", "B", "I"]
59
59
  line-length = 120
60
+
61
+ [dependency-groups]
62
+ dev = [
63
+ "ruff>=0.11.0",
64
+ ]
File without changes
@@ -0,0 +1,11 @@
1
+ from airflow_client.client import ApiClient, Configuration
2
+
3
+ from src.envs import AIRFLOW_HOST, AIRFLOW_PASSWORD, AIRFLOW_USERNAME
4
+
5
+ # Create a configuration and API client
6
+ configuration = Configuration(
7
+ host=AIRFLOW_HOST,
8
+ username=AIRFLOW_USERNAME,
9
+ password=AIRFLOW_PASSWORD,
10
+ )
11
+ api_client = ApiClient(configuration)
@@ -0,0 +1,34 @@
1
+ from typing import Any, Callable, Dict, List, Optional, Union
2
+
3
+ import mcp.types as types
4
+ from airflow_client.client.api.config_api import ConfigApi
5
+
6
+ from src.airflow.airflow_client import api_client
7
+
8
+ config_api = ConfigApi(api_client)
9
+
10
+
11
+ def get_all_functions() -> list[tuple[Callable, str, str]]:
12
+ return [
13
+ (get_config, "get_config", "Get current configuration"),
14
+ (get_value, "get_value", "Get a specific option from configuration"),
15
+ ]
16
+
17
+
18
+ async def get_config(
19
+ section: Optional[str] = None,
20
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
21
+ # Build parameters dictionary
22
+ kwargs: Dict[str, Any] = {}
23
+ if section is not None:
24
+ kwargs["section"] = section
25
+
26
+ response = config_api.get_config(**kwargs)
27
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
28
+
29
+
30
+ async def get_value(
31
+ section: str, option: str
32
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
33
+ response = config_api.get_value(section=section, option=option)
34
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
@@ -0,0 +1,139 @@
1
+ from typing import Any, Callable, Dict, List, Optional, Union
2
+
3
+ import mcp.types as types
4
+ from airflow_client.client.api.connection_api import ConnectionApi
5
+
6
+ from src.airflow.airflow_client import api_client
7
+
8
+ connection_api = ConnectionApi(api_client)
9
+
10
+
11
+ def get_all_functions() -> list[tuple[Callable, str, str]]:
12
+ return [
13
+ (list_connections, "list_connections", "List all connections"),
14
+ (create_connection, "create_connection", "Create a connection"),
15
+ (get_connection, "get_connection", "Get a connection by ID"),
16
+ (update_connection, "update_connection", "Update a connection by ID"),
17
+ (delete_connection, "delete_connection", "Delete a connection by ID"),
18
+ (test_connection, "test_connection", "Test a connection"),
19
+ ]
20
+
21
+
22
+ async def list_connections(
23
+ limit: Optional[int] = None,
24
+ offset: Optional[int] = None,
25
+ order_by: Optional[str] = None,
26
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
27
+ # Build parameters dictionary
28
+ kwargs: Dict[str, Any] = {}
29
+ if limit is not None:
30
+ kwargs["limit"] = limit
31
+ if offset is not None:
32
+ kwargs["offset"] = offset
33
+ if order_by is not None:
34
+ kwargs["order_by"] = order_by
35
+
36
+ response = connection_api.get_connections(**kwargs)
37
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
38
+
39
+
40
+ async def create_connection(
41
+ conn_id: str,
42
+ conn_type: str,
43
+ host: Optional[str] = None,
44
+ port: Optional[int] = None,
45
+ login: Optional[str] = None,
46
+ password: Optional[str] = None,
47
+ schema: Optional[str] = None,
48
+ extra: Optional[str] = None,
49
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
50
+ connection_request = {
51
+ "connection_id": conn_id,
52
+ "conn_type": conn_type,
53
+ }
54
+ if host is not None:
55
+ connection_request["host"] = host
56
+ if port is not None:
57
+ connection_request["port"] = port
58
+ if login is not None:
59
+ connection_request["login"] = login
60
+ if password is not None:
61
+ connection_request["password"] = password
62
+ if schema is not None:
63
+ connection_request["schema"] = schema
64
+ if extra is not None:
65
+ connection_request["extra"] = extra
66
+
67
+ response = connection_api.post_connection(connection_request=connection_request)
68
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
69
+
70
+
71
+ async def get_connection(conn_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
72
+ response = connection_api.get_connection(connection_id=conn_id)
73
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
74
+
75
+
76
+ async def update_connection(
77
+ conn_id: str,
78
+ conn_type: Optional[str] = None,
79
+ host: Optional[str] = None,
80
+ port: Optional[int] = None,
81
+ login: Optional[str] = None,
82
+ password: Optional[str] = None,
83
+ schema: Optional[str] = None,
84
+ extra: Optional[str] = None,
85
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
86
+ update_request = {}
87
+ if conn_type is not None:
88
+ update_request["conn_type"] = conn_type
89
+ if host is not None:
90
+ update_request["host"] = host
91
+ if port is not None:
92
+ update_request["port"] = port
93
+ if login is not None:
94
+ update_request["login"] = login
95
+ if password is not None:
96
+ update_request["password"] = password
97
+ if schema is not None:
98
+ update_request["schema"] = schema
99
+ if extra is not None:
100
+ update_request["extra"] = extra
101
+
102
+ response = connection_api.patch_connection(
103
+ connection_id=conn_id, update_mask=list(update_request.keys()), connection_request=update_request
104
+ )
105
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
106
+
107
+
108
+ async def delete_connection(conn_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
109
+ response = connection_api.delete_connection(connection_id=conn_id)
110
+ return [types.TextContent(type="text", text=str(response.to_dict()))]
111
+
112
+
113
+ async def test_connection(
114
+ conn_type: str,
115
+ host: Optional[str] = None,
116
+ port: Optional[int] = None,
117
+ login: Optional[str] = None,
118
+ password: Optional[str] = None,
119
+ schema: Optional[str] = None,
120
+ extra: Optional[str] = None,
121
+ ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
122
+ connection_request = {
123
+ "conn_type": conn_type,
124
+ }
125
+ if host is not None:
126
+ connection_request["host"] = host
127
+ if port is not None:
128
+ connection_request["port"] = port
129
+ if login is not None:
130
+ connection_request["login"] = login
131
+ if password is not None:
132
+ connection_request["password"] = password
133
+ if schema is not None:
134
+ connection_request["schema"] = schema
135
+ if extra is not None:
136
+ connection_request["extra"] = extra
137
+
138
+ response = connection_api.test_connection(connection_request=connection_request)
139
+ return [types.TextContent(type="text", text=str(response.to_dict()))]