Skip to content

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Sep 18, 2025

Summary by CodeRabbit

  • New Features
    • Display MCP and Python versions at startup for clearer diagnostics.
    • SecretSourceEnum now importable from the secrets config module.
  • Refactor
    • Initialized MCP mode and secrets earlier in the startup sequence for more predictable app boot.
  • Bug Fixes
    • Improved secret source matching by using consistent string representations, reducing misidentification issues.
  • Chores
    • CI lint step now shows formatting diffs instead of a strict check, making required changes easier to review.

Important

Auto-merge enabled.

This PR is set to merge automatically when all requirements are met.

Copy link

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Testing This PyAirbyte Version

You can test this version of PyAirbyte using the following:

# Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@aj/fix/properly-disable-prompt-secret-source-in-mcp-mode' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@aj/fix/properly-disable-prompt-secret-source-in-mcp-mode'

Helpful Resources

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /fix-pr - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test-pr - Runs tests with the updated PyAirbyte

Community Support

Questions? Join the #pyairbyte channel in our Slack workspace.

📝 Edit this welcome message.

Copy link

github-actions bot commented Sep 18, 2025

PyTest Results (Fast Tests Only, No Creds)

301 tests  ±0   300 ✅ ±0   4m 29s ⏱️ -1s
  1 suites ±0     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit b7db48a. ± Comparison against base commit 1d9292f.

♻️ This comment has been updated with latest results.

Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

📝 Walkthrough

Walkthrough

Moves MCP initialization and secrets setup to module import time in the MCP server, adds versioned MCP mode stderr logging, adjusts SecretSourceEnum string representation and its use in config disabling, exposes SecretSourceEnum via config, and updates the CI Ruff format check to use --diff.

Changes

Cohort / File(s) Summary
MCP mode diagnostics
airbyte/_util/meta.py
Adds stderr print in set_mcp_mode() showing MCP and Python versions via get_version() and python_version().
MCP server startup flow
airbyte/mcp/server.py
Moves set_mcp_mode() and initialize_secrets() to import time; constructs app and registers tools (including cloud ops) at import; main() now primarily runs app.run_stdio_async().
Secrets enum behavior
airbyte/secrets/base.py
Adds SecretSourceEnum.str to return the enum value.
Secrets config integration
airbyte/secrets/config.py
Imports and re-exports SecretSourceEnum at module scope; updates disable_secret_source to compare str(existing_source) with str(source); removes TYPE_CHECKING import.
CI linting
.github/workflows/python_lint.yml
Changes Ruff format check from --check to --diff.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Import as Module Import
  participant Meta as meta.set_mcp_mode
  participant Secrets as initialize_secrets
  participant App as MCP App
  participant Tools as Tool Registrations
  participant Main as main()
  participant Runtime as app.run_stdio_async

  rect rgb(245,245,255)
    note over Import: Import-time initialization (moved)
    Import->>Meta: set_mcp_mode()
    Meta-->>Import: stderr log "MCP vX (Python vY)"
    Import->>Secrets: initialize_secrets()
    Secrets-->>Import: Secrets ready
    Import->>App: construct app
    Import->>Tools: register connector/local/cloud ops tools
    Tools-->>Import: registrations complete
  end

  Main->>Runtime: run stdio async loop
  Runtime-->>Main: exit
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix: properly disable prompt secret source in mcp mode" is concise and accurately summarizes the primary intent of the changeset—disabling the prompt-based secret source when running in MCP mode; the updated secrets handling and enum stringification reflect that focus. It is specific to the main behavioral fix and avoids vague phrasing, so a reviewer scanning history can understand the primary change. Therefore it aligns well with the changes in the provided summary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch aj/fix/properly-disable-prompt-secret-source-in-mcp-mode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
airbyte/secrets/config.py (2)

6-6: Remove unused sys import, wdyt?

The linter correctly flags this unused import. Since no code uses sys in this file, let's clean it up.

-import sys

7-7: Remove unused TYPE_CHECKING import, wdyt?

Since you've moved SecretSourceEnum to runtime import (Line 10), the TYPE_CHECKING import is no longer needed and should be removed.

-from typing import TYPE_CHECKING
airbyte/mcp/_util.py (1)

5-5: Fix: Remove unused sys import.

The linter caught that sys is imported but never used in this file. Should we remove it to keep the imports clean, wdyt?

-import sys
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9292f and c94bc8d.

📒 Files selected for processing (5)
  • airbyte/_util/meta.py (2 hunks)
  • airbyte/mcp/_util.py (1 hunks)
  • airbyte/mcp/server.py (1 hunks)
  • airbyte/secrets/base.py (1 hunks)
  • airbyte/secrets/config.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
airbyte/secrets/config.py (1)
airbyte/secrets/base.py (2)
  • SecretManager (146-208)
  • SecretSourceEnum (23-35)
airbyte/mcp/server.py (2)
airbyte/_util/meta.py (1)
  • set_mcp_mode (41-52)
airbyte/mcp/_util.py (1)
  • initialize_secrets (37-70)
airbyte/_util/meta.py (1)
airbyte/version.py (1)
  • get_version (12-14)
🪛 GitHub Actions: Run Linters
airbyte/secrets/config.py

[error] 6-6: F401 [*] sys imported but unused


[error] 7-7: F401 [*] typing.TYPE_CHECKING imported but unused

airbyte/_util/meta.py

[error] 19-19: PLW0406 Module airbyte._util.meta imports itself

airbyte/mcp/_util.py

[error] 5-5: F401 [*] sys imported but unused

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (No Creds)
  • GitHub Check: Pytest (Fast)
🔇 Additional comments (4)
airbyte/secrets/config.py (1)

10-10: LGTM: Improved string-based source comparison logic!

The changes work well together:

  1. Moving SecretSourceEnum to runtime import enables proper string comparisons
  2. Using str(existing_source) == str(source) leverages the new __str__ method from SecretSourceEnum
  3. The .copy() ensures we're iterating over a snapshot to avoid modification issues

This approach is much cleaner than the previous .name attribute comparison and aligns with the new __str__ behavior.

Also applies to: 76-78

airbyte/mcp/server.py (2)

16-22: LGTM: Proper initialization order at import time!

Moving the initialization to module import time is a good approach for MCP mode. This ensures:

  1. MCP mode detection is available immediately
  2. Secrets are initialized before any app functionality
  3. All tools (connector, local, cloud ops) are registered at startup

The sequence looks correct: set mode → initialize secrets → create app → register tools.


25-37: LGTM: Clean main function focused on execution!

The main function is now properly focused on just running the server loop and handling errors, with all initialization moved to import time. The error handling and user feedback are appropriate for an MCP server.

airbyte/secrets/base.py (1)

33-35: LGTM! Nice implementation of the __str__ method.

The addition of __str__ method to SecretSourceEnum returning the enum's underlying value makes perfect sense and aligns well with the changes in the secrets config handling. This enables cleaner string comparisons and is exactly what you need for the updated comparison logic in disable_secret_source, wdyt?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
.github/workflows/python_lint.yml (3)

59-59: Ensure format step fails CI when reformatting is needed

ruff format --diff shows the diff but may not fail the job. Do you want CI to fail on unformatted code? If yes, can we add --check (you can keep --diff for preview), wdyt?

-      run: poetry run ruff format --diff .
+      run: poetry run ruff format --check --diff .

20-31: Duplicate “Set up Poetry” step in the same job

This block duplicates the earlier Poetry setup (Lines 21–24 vs 29–31). Can we drop one to shave runner time and noise, wdyt?

-    - name: Set up Poetry
-      uses: Gr1N/setup-poetry@v9
-      with:
-        poetry-version: "2.0.1"

69-79: Duplicate “Set up Poetry” step in mypy job

Same duplication here. Remove one to simplify the workflow, wdyt?

-    - name: Set up Poetry
-      uses: Gr1N/setup-poetry@v9
-      with:
-        poetry-version: "2.0.1"
airbyte/_util/meta.py (2)

46-49: Make MCP-mode log idempotent and include implementation

If set_mcp_mode() gets called twice, we’ll emit the banner twice. Also, would you prefer the richer Python string (e.g., “3.10.14 (CPython)”) via get_python_version() and flush immediately, wdyt?

-def set_mcp_mode() -> None:
-    """Set flag indicating we are running in MCP (Model Context Protocol) mode.
+def set_mcp_mode() -> None:
+    """Set flag indicating we are running in MCP (Model Context Protocol) mode.
@@
-    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
+    global _MCP_MODE_ENABLED
+    if _MCP_MODE_ENABLED:
+        return
+    print(
+        f"Running in MCP mode: PyAirbyte MCP v{get_version()} (Python {get_python_version()})",
+        file=sys.stderr,
+        flush=True,
+    )
+    _MCP_MODE_ENABLED = True

124-126: Avoid potential hang when probing Colab session

requests.get() has no timeout and could block. Shall we add a small timeout (e.g., 0.5–1s) to keep imports snappy, wdyt?

-            response = requests.get(COLAB_SESSION_URL)
+            response = requests.get(COLAB_SESSION_URL, timeout=1)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c94bc8d and b7db48a.

📒 Files selected for processing (3)
  • .github/workflows/python_lint.yml (1 hunks)
  • airbyte/_util/meta.py (2 hunks)
  • airbyte/secrets/config.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte/secrets/config.py
🧰 Additional context used
🧬 Code graph analysis (1)
airbyte/_util/meta.py (1)
airbyte/version.py (1)
  • get_version (12-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (No Creds)
🔇 Additional comments (1)
airbyte/_util/meta.py (1)

19-20: LGTM: import of get_version

Import looks clean and resolves the prior circular import concern noted in earlier CI. Nice fix.

Copy link

PyTest Results (Full)

364 tests  ±0   348 ✅ ±0   21m 57s ⏱️ +2s
  1 suites ±0    16 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit b7db48a. ± Comparison against base commit 1d9292f.

@aaronsteers aaronsteers enabled auto-merge (squash) September 19, 2025 00:21
@aaronsteers aaronsteers merged commit 8ef7237 into main Sep 19, 2025
24 checks passed
@aaronsteers aaronsteers deleted the aj/fix/properly-disable-prompt-secret-source-in-mcp-mode branch September 19, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant