Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

# Job-specifc step(s):
- name: Check code format
run: poetry run ruff format --check .
run: poetry run ruff format --diff .

mypy-check:
name: MyPy Check
Expand Down
6 changes: 6 additions & 0 deletions airbyte/_util/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import requests

from airbyte.version import get_version


_MCP_MODE_ENABLED: bool = False
"""Whether we are running in MCP (Model Context Protocol) mode."""
Expand All @@ -41,6 +43,10 @@ def set_mcp_mode() -> None:
This should be called early in MCP server initialization to ensure
proper detection and prevent interactive prompts.
"""
print(
f"Running in MCP mode: PyAirbyte MCP v{get_version()} (Python v{python_version()})",
file=sys.stderr,
)
global _MCP_MODE_ENABLED
_MCP_MODE_ENABLED = True

Expand Down
5 changes: 3 additions & 2 deletions airbyte/mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from airbyte.mcp._util import initialize_secrets


set_mcp_mode()
initialize_secrets()

app: FastMCP = FastMCP("airbyte-mcp")
register_connector_registry_tools(app)
register_local_ops_tools(app)
Expand All @@ -22,8 +25,6 @@
def main() -> None:
"""Main entry point for the MCP server."""
print("Starting Airbyte MCP server.", file=sys.stderr)
set_mcp_mode()
initialize_secrets()
try:
asyncio.run(app.run_stdio_async())
except KeyboardInterrupt:
Expand Down
4 changes: 4 additions & 0 deletions airbyte/secrets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class SecretSourceEnum(str, Enum):

PROMPT = "prompt"

def __str__(self) -> str:
"""Return the string representation of the enum value."""
return self.value


class SecretString(str): # noqa: FURB189 # Allow subclass from str instead of UserStr
"""A string that represents a secret.
Expand Down
14 changes: 4 additions & 10 deletions airbyte/secrets/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@

from __future__ import annotations

from typing import TYPE_CHECKING

from airbyte._util import meta
from airbyte.secrets.base import SecretManager
from airbyte.secrets.base import SecretManager, SecretSourceEnum
from airbyte.secrets.env_vars import DotenvSecretManager, EnvVarSecretManager
from airbyte.secrets.google_colab import ColabSecretManager
from airbyte.secrets.prompt import SecretsPrompt


if TYPE_CHECKING:
from airbyte.secrets.base import SecretSourceEnum


_SECRETS_SOURCES: list[SecretManager] = []


Expand Down Expand Up @@ -76,6 +70,6 @@ def disable_secret_source(source: SecretManager | SecretSourceEnum) -> None:
return

# Else, remove by name
for s in list(_SECRETS_SOURCES).copy():
if s.name == str(source):
_SECRETS_SOURCES.remove(s)
for existing_source in list(_SECRETS_SOURCES).copy():
if str(existing_source) == str(source):
_SECRETS_SOURCES.remove(existing_source)
Loading