-
Notifications
You must be signed in to change notification settings - Fork 74
feat(mcp): wire trusted-execution gate and function-layer guards #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Aaron ("AJ") Steers (aaronsteers)
merged 6 commits into
main
from
devin/1784595371-mcp-trusted-execution
Jul 21, 2026
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1aba8c2
feat(mcp): wire Airbyte trusted-execution gate and function-layer guards
devin-ai-integration[bot] f9b55c6
test(mcp): cover destination_smoke_test in untrusted-guard parametriz…
devin-ai-integration[bot] 5410203
refactor(mcp): rename guard to raise_if_untrusted_execution_context
devin-ai-integration[bot] 498c85f
refactor(mcp): drop PyAirbyte prefix from MCP exception classes
devin-ai-integration[bot] 3d0946a
test(mcp): consolidate trusted-execution tests via parametrization
devin-ai-integration[bot] ffadce2
docs(mcp): clarify untrusted dotenv env-loading behavior in load_secrets
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
| """Trusted-execution guards for Airbyte MCP backend helpers. | ||
|
|
||
| Trusted execution is the master gate for the MCP server's *trusted-machine* capabilities: | ||
| local filesystem access, local connector installation/execution, and server-side secret | ||
| resolution. It is controlled solely by the `AIRBYTE_MCP_TRUSTED_EXECUTION` server | ||
| environment variable (`airbyte.constants.MCP_TRUSTED_EXECUTION_ENV_VAR`) and defaults to | ||
| *off* on every transport. | ||
|
|
||
| `fastmcp_extensions` already hides trusted-machine tools from the tool listing when the | ||
| gate is off, but that is a *visibility* control. The guards here are an independent | ||
| *function-layer* control: backend helpers call `raise_if_untrusted_execution_context` so a direct | ||
| call hard-fails when the gate is disabled, even if a future registration mistake left the | ||
| tool visible. Because the two layers are independent, a mistake in either one alone cannot | ||
| expose a trusted-machine capability to an untrusted (for example hosted HTTP) caller. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| from airbyte.constants import MCP_TRUSTED_EXECUTION_ENV_VAR | ||
| from airbyte.exceptions import AirbyteTrustedExecutionRequiredError | ||
|
|
||
|
|
||
| _TRUTHY_VALUES = frozenset({"1", "true", "yes"}) | ||
|
|
||
|
|
||
| def is_trusted_execution_enabled() -> bool: | ||
| """Return whether trusted execution is enabled for the MCP server. | ||
|
|
||
| Reads `AIRBYTE_MCP_TRUSTED_EXECUTION` from the server environment only. A value of | ||
| `1`/`true`/`yes` (case-insensitive) enables it; anything else -- including unset -- | ||
| leaves it disabled. | ||
| """ | ||
| return os.environ.get(MCP_TRUSTED_EXECUTION_ENV_VAR, "0").strip().lower() in _TRUTHY_VALUES | ||
|
|
||
|
|
||
| def raise_if_untrusted_execution_context(feature: str) -> None: | ||
| """Hard-fail when `feature` is invoked while trusted execution is disabled. | ||
|
|
||
| Call this from any backend helper that exposes a trusted-machine capability (local | ||
| filesystem access, connector installation/execution, or server-side secret | ||
| resolution). It raises `airbyte.exceptions.AirbyteTrustedExecutionRequiredError` | ||
| when the gate is off, independently of whether the corresponding tool was hidden from | ||
| the listing. | ||
| """ | ||
| if not is_trusted_execution_enabled(): | ||
| raise AirbyteTrustedExecutionRequiredError(feature=feature) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.