feat(mcp): gate Agents tools behind insiders mode, add org-id header - #1135
feat(mcp): gate Agents tools behind insiders mode, add org-id header#1135Aaron ("AJ") Steers (aaronsteers) wants to merge 2 commits into
Conversation
Agents MCP tools are no longer advertised by default. They appear when insiders mode is enabled (AIRBYTE_MCP_INSIDERS / X-MCP-Insiders, following the GitHub MCP server's naming) or when the include-modules list names the agents module explicitly. Adds X-Airbyte-Organization-Id as a per-request source for the organization ID, and turns Agents 401/403 responses into concise tool results instead of tracebacks. Co-Authored-By: AJ Steers <aj@airbyte.io>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This PyAirbyte VersionYou can test this version of PyAirbyte using the following: # Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1787935160-agents-optin-gate' pyairbyte --help
# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1787935160-agents-optin-gate'PR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
📚 Show Repo GuidanceHelpful ResourcesCommunity SupportQuestions? Join the #pyairbyte channel in our Slack workspace. |
There was a problem hiding this comment.
Pull request overview
This PR refines the Airbyte MCP server’s tool surface and request scoping by (1) hiding subscription/preview tool modules by default behind an “insiders” gate, and (2) adding per-request organization scoping, while also improving how Agents authorization failures are surfaced to callers.
Changes:
- Add an insiders-mode gate to prevent advertising
agentsMCP tools by default unless explicitly opted in (header/env var or include list). - Add
X-Airbyte-Organization-Id/AIRBYTE_CLOUD_ORGANIZATION_IDsupport via a new MCP config arg and use it as a fallback for Agents organization-scoped operations. - Convert Agents 401/403 failures from exceptions into normal-shaped tool results with empty payloads and a human-actionable message (tests included).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit_tests/test_mcp_tool_filters.py | Adds unit tests covering the insiders gate behavior and include/exclude precedence. |
| tests/unit_tests/test_mcp_agents.py | Extends MCP Agents tests for org-id fallback precedence and graceful 401/403 result shaping. |
| airbyte/mcp/server.py | Registers the new insiders and organization-id config args with the MCP server. |
| airbyte/mcp/agents.py | Implements org-id fallback plus graceful authorization failure shaping for Agents tools. |
| airbyte/mcp/_tool_utils.py | Adds INSIDERS_CONFIG_ARG, ORGANIZATION_ID_CONFIG_ARG, and updates the module filter to support insiders-gated modules. |
| airbyte/constants.py | Introduces constants for insiders gating and the organization-id header/config keys. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: AJ Steers <aj@airbyte.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe MCP server adds organization ID and insiders configuration. It filters insiders-only modules. Agents tools resolve organization scope and return structured results for 401 and 403 responses. Unit tests cover filtering, configuration precedence, and authorization handling. ChangesMCP access controls
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The PR limits Agents tools to opted-in callers, supports per-request organization scoping, and makes authorization failures readable without changing successful behavior. No actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant MCPTool
participant AgentOrganization
participant AgentsAPI
MCPTool->>AgentOrganization: Resolve explicit or configured organization_id
AgentOrganization->>AgentsAPI: Request workspace or connector data
AgentsAPI-->>AgentOrganization: Return data or HTTP 401/403 error
AgentOrganization-->>MCPTool: Return result or structured access-denied message
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Code Coverage OverviewLanguages: Python Python / code-coverage/pytest-fastThe overall line coverage in commit bd1e472 in the Show a line coverage summary of the most impacted files.
Python / code-coverage/pytest-no-credsThe overall line coverage in commit bd1e472 in the Show a line coverage summary of the most impacted files.
Python / code-coverage/pytestThe overall line coverage in commit bd1e472 in the Show a line coverage summary of the most impacted files.
Updated |
Summary
The Agents MCP tools added in #1127 are advertised to every caller today, but most organizations have no Airbyte Agents subscription, so those tools cost context and produce authorization failures nobody can act on. This hides them by default and makes the failures readable when they do happen.
Three changes:
1. Insiders gate on the
agentsmodule.MCP_INSIDERS_MODULES = {"agents"}marks modules that are not part of the default surface.airbyte_module_filtergains one branch, ordered so an explicit exclusion still wins:So Agents tools appear when
AIRBYTE_MCP_INSIDERS/X-MCP-Insidersis set (they join the normal surface), or when the include list namesagents(AIRBYTE_MCP_DOMAINS=agentsstill yields Agent-only mode, unchanged). Names follow the GitHub MCP server's configuration surface, which is the closest thing to a convention here — MCP itself has no annotation or header for preview/subscription-gated tools, and tool annotations are client hints, so the filtering has to be server-side regardless.This is a caller-settable gate that widens the tool surface, unlike
AIRBYTE_MCP_TRUSTED_EXECUTIONwhich deliberately has no header. That is safe because it changes only which tools are advertised: each Agents tool still authorizes every call against the Airbyte API, and no entitlement probe happens duringlist_tools.2.
X-Airbyte-Organization-Id. Pairs with the existingAIRBYTE_CLOUD_ORGANIZATION_IDenv var, so hosted callers can scope organization-level listings per request. An explicitorganization_idtool argument still wins over it.3. Readable authorization failures.
401/403from the Agents API previously surfaced as anAirbyteErrortraceback. The four Agents tools now return their normal result shape with an empty payload and amessageexplaining which of the two situations applies — invalid credentials, versus authenticated-but-not-entitled/no workspace access — and telling the agent to ask rather than retry. Anything else re-raises with its original context, following the_handle_discovery_permission_errorprecedent inairbyte/mcp/cloud.py.Naming/deprecation work discussed alongside this (
AIRBYTE_MCP_DOMAINS→ include/exclude-modules,AIRBYTE_MCP_HOSTING_URL, adopting more of GitHub's header names, and a documented index of every setting) is intentionally not here and follows in a separate PR.Link to Devin session: https://app.devin.ai/sessions/57a0c3e7b98f4c52a9c09a5cd721ee3a
Open in Devin Desktop: https://app.devin.ai/desktop/session/57a0c3e7b98f4c52a9c09a5cd721ee3a?variant=devin
Requested by: Aaron ("AJ") Steers (@aaronsteers)
Summary by CodeRabbit