diff --git a/.github/workflows/python_lint.yml b/.github/workflows/python_lint.yml index dce70476..37ccd8fe 100644 --- a/.github/workflows/python_lint.yml +++ b/.github/workflows/python_lint.yml @@ -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 diff --git a/airbyte/_util/meta.py b/airbyte/_util/meta.py index 644051e7..f2e1d3b0 100644 --- a/airbyte/_util/meta.py +++ b/airbyte/_util/meta.py @@ -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.""" @@ -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 diff --git a/airbyte/mcp/server.py b/airbyte/mcp/server.py index 6e771f7a..d1dd8d27 100644 --- a/airbyte/mcp/server.py +++ b/airbyte/mcp/server.py @@ -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) @@ -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: diff --git a/airbyte/secrets/base.py b/airbyte/secrets/base.py index b9e4ab7d..aa0ba911 100644 --- a/airbyte/secrets/base.py +++ b/airbyte/secrets/base.py @@ -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. diff --git a/airbyte/secrets/config.py b/airbyte/secrets/config.py index 63e30e95..e8ae43e8 100644 --- a/airbyte/secrets/config.py +++ b/airbyte/secrets/config.py @@ -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] = [] @@ -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)