airbyte-agent-mcp 0.1.30__py3-none-any.whl
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.
- airbyte_agent_mcp/__init__.py +0 -0
- airbyte_agent_mcp/__main__.py +26 -0
- airbyte_agent_mcp/_vendored/__init__.py +1 -0
- airbyte_agent_mcp/_vendored/connector_sdk/__init__.py +82 -0
- airbyte_agent_mcp/_vendored/connector_sdk/auth_strategies.py +1123 -0
- airbyte_agent_mcp/_vendored/connector_sdk/auth_template.py +135 -0
- airbyte_agent_mcp/_vendored/connector_sdk/connector_model_loader.py +938 -0
- airbyte_agent_mcp/_vendored/connector_sdk/constants.py +78 -0
- airbyte_agent_mcp/_vendored/connector_sdk/exceptions.py +23 -0
- airbyte_agent_mcp/_vendored/connector_sdk/executor/__init__.py +31 -0
- airbyte_agent_mcp/_vendored/connector_sdk/executor/hosted_executor.py +188 -0
- airbyte_agent_mcp/_vendored/connector_sdk/executor/local_executor.py +1504 -0
- airbyte_agent_mcp/_vendored/connector_sdk/executor/models.py +190 -0
- airbyte_agent_mcp/_vendored/connector_sdk/extensions.py +655 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/__init__.py +37 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/adapters/__init__.py +9 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/adapters/httpx_adapter.py +251 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/config.py +98 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/exceptions.py +119 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/protocols.py +114 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http/response.py +102 -0
- airbyte_agent_mcp/_vendored/connector_sdk/http_client.py +679 -0
- airbyte_agent_mcp/_vendored/connector_sdk/logging/__init__.py +11 -0
- airbyte_agent_mcp/_vendored/connector_sdk/logging/logger.py +264 -0
- airbyte_agent_mcp/_vendored/connector_sdk/logging/types.py +92 -0
- airbyte_agent_mcp/_vendored/connector_sdk/observability/__init__.py +11 -0
- airbyte_agent_mcp/_vendored/connector_sdk/observability/models.py +19 -0
- airbyte_agent_mcp/_vendored/connector_sdk/observability/redactor.py +81 -0
- airbyte_agent_mcp/_vendored/connector_sdk/observability/session.py +94 -0
- airbyte_agent_mcp/_vendored/connector_sdk/performance/__init__.py +6 -0
- airbyte_agent_mcp/_vendored/connector_sdk/performance/instrumentation.py +57 -0
- airbyte_agent_mcp/_vendored/connector_sdk/performance/metrics.py +93 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/__init__.py +75 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/base.py +160 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/components.py +238 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/connector.py +131 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/extensions.py +109 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/operations.py +146 -0
- airbyte_agent_mcp/_vendored/connector_sdk/schema/security.py +213 -0
- airbyte_agent_mcp/_vendored/connector_sdk/secrets.py +182 -0
- airbyte_agent_mcp/_vendored/connector_sdk/telemetry/__init__.py +10 -0
- airbyte_agent_mcp/_vendored/connector_sdk/telemetry/config.py +32 -0
- airbyte_agent_mcp/_vendored/connector_sdk/telemetry/events.py +58 -0
- airbyte_agent_mcp/_vendored/connector_sdk/telemetry/tracker.py +151 -0
- airbyte_agent_mcp/_vendored/connector_sdk/types.py +239 -0
- airbyte_agent_mcp/_vendored/connector_sdk/utils.py +60 -0
- airbyte_agent_mcp/_vendored/connector_sdk/validation.py +822 -0
- airbyte_agent_mcp/config.py +97 -0
- airbyte_agent_mcp/connector_manager.py +340 -0
- airbyte_agent_mcp/models.py +147 -0
- airbyte_agent_mcp/registry_client.py +103 -0
- airbyte_agent_mcp/secret_manager.py +94 -0
- airbyte_agent_mcp/server.py +265 -0
- airbyte_agent_mcp-0.1.30.dist-info/METADATA +134 -0
- airbyte_agent_mcp-0.1.30.dist-info/RECORD +56 -0
- airbyte_agent_mcp-0.1.30.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Data models and protocols for executor implementations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import AsyncIterator
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Protocol, runtime_checkable
|
|
9
|
+
|
|
10
|
+
from dotenv import load_dotenv
|
|
11
|
+
|
|
12
|
+
# Load environment variables from .env file
|
|
13
|
+
_env_path = Path(__file__).parent.parent.parent / ".env"
|
|
14
|
+
if _env_path.exists():
|
|
15
|
+
load_dotenv(dotenv_path=_env_path)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class ExecutionConfig:
|
|
20
|
+
"""Configuration for connector execution.
|
|
21
|
+
|
|
22
|
+
Used by both LocalExecutor and HostedExecutor to specify the operation to execute.
|
|
23
|
+
Executor-specific configuration (like api_url for HostedExecutor) is passed to
|
|
24
|
+
the executor's constructor instead of being part of the execution config.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
entity: Entity name (e.g., "customers", "invoices")
|
|
28
|
+
action: Operation action (e.g., "list", "get", "create")
|
|
29
|
+
params: Optional parameters for the operation
|
|
30
|
+
- For GET: {"id": "cus_123"}
|
|
31
|
+
- For LIST: {"limit": 10}
|
|
32
|
+
- For CREATE: {"email": "...", "name": "..."}
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
config = ExecutionConfig(
|
|
36
|
+
entity="customers",
|
|
37
|
+
action="list",
|
|
38
|
+
params={"limit": 10}
|
|
39
|
+
)
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
entity: str
|
|
43
|
+
action: str
|
|
44
|
+
params: dict[str, Any] | None = field(default=None, kw_only=True)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class StandardExecuteResult:
|
|
49
|
+
"""Result from standard operation handlers (GET, LIST, CREATE, UPDATE, DELETE, etc.).
|
|
50
|
+
|
|
51
|
+
This is returned by _StandardOperationHandler to provide type-safe data and metadata
|
|
52
|
+
returns instead of using tuples. Download operations continue to return AsyncIterator[bytes]
|
|
53
|
+
directly for simplicity.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
data: Response data from the operation
|
|
57
|
+
metadata: Optional metadata extracted from response (e.g., pagination info)
|
|
58
|
+
|
|
59
|
+
Example:
|
|
60
|
+
result = StandardExecuteResult(
|
|
61
|
+
data={"id": "1", "name": "Test"},
|
|
62
|
+
metadata={"pagination": {"cursor": "next123", "totalRecords": 100}}
|
|
63
|
+
)
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
data: dict[str, Any]
|
|
67
|
+
metadata: dict[str, Any] | None = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class ExecutionResult:
|
|
72
|
+
"""Result of a connector execution.
|
|
73
|
+
|
|
74
|
+
This is returned by all executor implementations. It provides a consistent
|
|
75
|
+
interface for handling both successful executions and execution failures.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
success: True if execution completed successfully, False if it failed
|
|
79
|
+
data: Response data from the execution
|
|
80
|
+
- dict[str, Any] for standard operations (GET, LIST, CREATE, etc.)
|
|
81
|
+
- AsyncIterator[bytes] for download operations (streaming file content)
|
|
82
|
+
error: Error message if success=False, None otherwise
|
|
83
|
+
meta: Optional metadata extracted from response (e.g., pagination info)
|
|
84
|
+
|
|
85
|
+
Example (Success - Standard):
|
|
86
|
+
result = ExecutionResult(
|
|
87
|
+
success=True,
|
|
88
|
+
data=[{"id": "1"}, {"id": "2"}],
|
|
89
|
+
error=None,
|
|
90
|
+
meta={"pagination": {"cursor": "next123", "totalRecords": 100}}
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
Example (Success - Download):
|
|
94
|
+
result = ExecutionResult(
|
|
95
|
+
success=True,
|
|
96
|
+
data=async_iterator_of_bytes,
|
|
97
|
+
error=None
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
Example (Failure):
|
|
101
|
+
result = ExecutionResult(
|
|
102
|
+
success=False,
|
|
103
|
+
data={},
|
|
104
|
+
error="Entity 'invalid' not found",
|
|
105
|
+
meta=None
|
|
106
|
+
)
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
success: bool
|
|
110
|
+
data: dict[str, Any] | AsyncIterator[bytes]
|
|
111
|
+
error: str | None = None
|
|
112
|
+
meta: dict[str, Any] | None = None
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# ============================================================================
|
|
116
|
+
# Executor Protocol
|
|
117
|
+
# ============================================================================
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@runtime_checkable
|
|
121
|
+
class ExecutorProtocol(Protocol):
|
|
122
|
+
"""Protocol for connector execution.
|
|
123
|
+
|
|
124
|
+
This defines the interface that both LocalExecutor and HostedExecutor implement.
|
|
125
|
+
Uses structural typing (Protocol) - any class with a matching execute() method
|
|
126
|
+
satisfies this protocol, regardless of inheritance.
|
|
127
|
+
|
|
128
|
+
The @runtime_checkable decorator allows isinstance() checks at runtime.
|
|
129
|
+
|
|
130
|
+
Example:
|
|
131
|
+
def run_connector(executor: ExecutorProtocol, config: ExecutionConfig):
|
|
132
|
+
result = await executor.execute(config)
|
|
133
|
+
if result.success:
|
|
134
|
+
print(f"Success: {result.data}")
|
|
135
|
+
else:
|
|
136
|
+
print(f"Error: {result.error}")
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
async def execute(self, config: ExecutionConfig) -> ExecutionResult:
|
|
140
|
+
"""Execute connector with given configuration.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
config: Configuration for execution (entity, action, params)
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
ExecutionResult with success status, data, and optional error message
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
Infrastructure exceptions (network errors, HTTP errors, auth failures)
|
|
150
|
+
These are exceptional cases where the system cannot complete the request.
|
|
151
|
+
|
|
152
|
+
Execution errors (entity not found, invalid operation) are returned
|
|
153
|
+
in ExecutionResult.error instead of being raised.
|
|
154
|
+
"""
|
|
155
|
+
...
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# ============================================================================
|
|
159
|
+
# Executor Exceptions
|
|
160
|
+
# ============================================================================
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class ExecutorError(Exception):
|
|
164
|
+
"""Base exception for executor errors."""
|
|
165
|
+
|
|
166
|
+
pass
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class EntityNotFoundError(ExecutorError):
|
|
170
|
+
"""Raised when an entity is not found in the connector."""
|
|
171
|
+
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class ActionNotSupportedError(ExecutorError):
|
|
176
|
+
"""Raised when an action is not supported for an entity."""
|
|
177
|
+
|
|
178
|
+
pass
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class MissingParameterError(ExecutorError):
|
|
182
|
+
"""Raised when a required parameter is missing."""
|
|
183
|
+
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class InvalidParameterError(ExecutorError):
|
|
188
|
+
"""Raised when a parameter has an invalid type or value."""
|
|
189
|
+
|
|
190
|
+
pass
|