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,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Template engine for auth_mapping in x-airbyte-auth-config.
|
|
3
|
+
|
|
4
|
+
Handles template substitution for mapping user-provided config values to auth parameters.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
from typing import Dict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MissingVariableError(ValueError):
|
|
12
|
+
"""Raised when a template variable is not found in config.
|
|
13
|
+
|
|
14
|
+
Extends ValueError for backwards compatibility with code that catches ValueError.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, var_name: str, available_fields: list):
|
|
18
|
+
self.var_name = var_name
|
|
19
|
+
self.available_fields = available_fields
|
|
20
|
+
super().__init__(f"Template variable '${{{var_name}}}' not found in config. " f"Available fields: {available_fields}")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def apply_template(template: str, values: Dict[str, str]) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Apply template substitution for auth_mapping.
|
|
26
|
+
|
|
27
|
+
Template syntax:
|
|
28
|
+
- ${variable}: Replaced with value from the values dict
|
|
29
|
+
- Any other text: Used as-is (constants or concatenation)
|
|
30
|
+
|
|
31
|
+
Examples:
|
|
32
|
+
>>> apply_template("${api_key}", {"api_key": "abc123"})
|
|
33
|
+
'abc123'
|
|
34
|
+
|
|
35
|
+
>>> apply_template("${email}/token", {"email": "user@example.com"})
|
|
36
|
+
'user@example.com/token'
|
|
37
|
+
|
|
38
|
+
>>> apply_template("api_token", {})
|
|
39
|
+
'api_token'
|
|
40
|
+
|
|
41
|
+
>>> apply_template("", {})
|
|
42
|
+
''
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
template: Template string with ${variable} placeholders
|
|
46
|
+
values: Dict of variable names to values
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
Resolved template string
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
MissingVariableError: If template contains unresolved variables
|
|
53
|
+
"""
|
|
54
|
+
if not template:
|
|
55
|
+
return ""
|
|
56
|
+
|
|
57
|
+
# Check if it's a pure constant (no variables)
|
|
58
|
+
if "${" not in template:
|
|
59
|
+
return template
|
|
60
|
+
|
|
61
|
+
# Find all variable references
|
|
62
|
+
variable_pattern = re.compile(r"\$\{([^}]+)\}")
|
|
63
|
+
matches = variable_pattern.findall(template)
|
|
64
|
+
|
|
65
|
+
# Substitute all ${var} with values
|
|
66
|
+
result = template
|
|
67
|
+
for var_name in matches:
|
|
68
|
+
if var_name not in values:
|
|
69
|
+
raise MissingVariableError(var_name, list(values.keys()))
|
|
70
|
+
# Replace the variable with its value
|
|
71
|
+
result = result.replace(f"${{{var_name}}}", values[var_name])
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def apply_auth_mapping(
|
|
77
|
+
auth_mapping: Dict[str, str],
|
|
78
|
+
user_config: Dict[str, str],
|
|
79
|
+
required_fields: list | None = None,
|
|
80
|
+
) -> Dict[str, str]:
|
|
81
|
+
"""
|
|
82
|
+
Apply auth_mapping templates to user config.
|
|
83
|
+
|
|
84
|
+
Takes the auth_mapping from x-airbyte-auth-config and user-provided config,
|
|
85
|
+
and returns the mapped auth parameters. Optional fields (not in required_fields)
|
|
86
|
+
are skipped if their template variables are not provided.
|
|
87
|
+
|
|
88
|
+
Example:
|
|
89
|
+
>>> auth_mapping = {
|
|
90
|
+
... "username": "${api_key}",
|
|
91
|
+
... "password": ""
|
|
92
|
+
... }
|
|
93
|
+
>>> user_config = {"api_key": "my_key_123"}
|
|
94
|
+
>>> apply_auth_mapping(auth_mapping, user_config)
|
|
95
|
+
{'username': 'my_key_123', 'password': ''}
|
|
96
|
+
|
|
97
|
+
>>> # Optional fields are skipped if not provided
|
|
98
|
+
>>> auth_mapping = {
|
|
99
|
+
... "access_token": "${access_token}",
|
|
100
|
+
... "refresh_token": "${refresh_token}",
|
|
101
|
+
... }
|
|
102
|
+
>>> user_config = {"access_token": "abc123"}
|
|
103
|
+
>>> apply_auth_mapping(auth_mapping, user_config, required_fields=["access_token"])
|
|
104
|
+
{'access_token': 'abc123'}
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
auth_mapping: Dict mapping auth parameters to template strings
|
|
108
|
+
user_config: Dict of user-provided field values
|
|
109
|
+
required_fields: List of required field names. If a template references
|
|
110
|
+
a variable not in user_config and that variable is not required,
|
|
111
|
+
the mapping is skipped. Behavior:
|
|
112
|
+
- None: all fields are treated as required (backward compatible)
|
|
113
|
+
- []: no fields are required (all optional)
|
|
114
|
+
- ["foo"]: only "foo" is required
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
Dict of resolved auth parameters
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
MissingVariableError: If a required template variable is not found
|
|
121
|
+
"""
|
|
122
|
+
resolved = {}
|
|
123
|
+
required_set = set(required_fields) if required_fields is not None else None
|
|
124
|
+
|
|
125
|
+
for param, template in auth_mapping.items():
|
|
126
|
+
try:
|
|
127
|
+
resolved[param] = apply_template(template, user_config)
|
|
128
|
+
except MissingVariableError as e:
|
|
129
|
+
# If the missing variable is not in required fields, skip this mapping
|
|
130
|
+
if required_set is not None and e.var_name not in required_set:
|
|
131
|
+
continue
|
|
132
|
+
# Otherwise, re-raise the error
|
|
133
|
+
raise
|
|
134
|
+
|
|
135
|
+
return resolved
|