fix(cloud): default to sole instance workspace; MCP tool names in guidance - #1305
Conversation
…ol names in local MCP guidance Co-Authored-By: AJ Steers <aj@airbyte.io>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
👋 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/1790904754-oss-mcp-workspace-defaults' pyairbyte --help
# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1790904754-oss-mcp-workspace-defaults'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. |
…llback Co-Authored-By: AJ Steers <aj@airbyte.io>
Code Coverage OverviewLanguages: Python Python / code-coverage/pytest-no-credsThe overall line coverage in commit 93e122c in the Show a line coverage summary of the most impacted files.
Python / code-coverage/pytestThe overall line coverage in commit 93e122c in the Show a line coverage summary of the most impacted files.
Python / code-coverage/pytest-unitThe overall line coverage in commit 93e122c in the Show a line coverage summary of the most covered files.
Updated |
|
E2E verification at The test user was an instance admin with no direct workspace memberships and no stored default.
Not covered: creating a connection and running a sync. Connector discovery hit Docker Hub rate limits (HTTP 429) in the test environment, and neither is affected by this PR. |
b76087a
into
release-candidate/v1
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| except (AirbyteError, exc.PyAirbyteInputError): | ||
| return None |
There was a problem hiding this comment.
🟡 Workspace lookup failures escape default resolution
If instance-wide discovery times out, _get_sole_instance_workspace_id propagates the transport error. _make_config_api_request leaves request failures unwrapped, so workspace-dependent calls fail instead of reporting missing workspace context.
Learn more
The fallback runs only after the user has no verified direct workspaces and has instance-admin permission. It calls the Config API through _make_config_api_request, which makes a requests.request call without converting connection or timeout failures to AirbyteError. Those failures bypass this handler, unlike Config API HTTP errors, so a failed optional lookup interrupts default resolution instead of returning None.
Example: An instance admin has no workspace memberships or stored default. The permissions lookup succeeds, then the workspace-list request times out. resolve_default_workspace_id() raises requests.Timeout rather than returning None; an MCP tool cannot raise its missing-workspace guidance.
Recommended fix: Catch the transport exceptions raised by _make_config_api_request in this optional fallback, or normalize them into AirbyteError at the API boundary. Preserve the current behavior for successful lookups and ambiguous workspace lists.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Fixes two problems found while testing the local stdio MCP against Airbyte OSS 2.3.0 (abctl). Requested by AJ Steers.
Fresh self-managed installs have no default workspace. The default OSS user is an instance admin with no workspace memberships and no
defaultWorkspaceId.resolve_default_workspace_id()therefore returnedNone, and every tool that needs a workspace failed. This PR adds a last fallback that applies only when the user has no direct workspace grants at all:api_util.list_workspaces_by_usergains an optionalpage_size(default 100, so existing callers are unchanged). The fallback therefore requests only two rows, even on Cloud.In local MCP mode, the
AirbyteMissingWorkspaceContextErrorguidance named tools that don't exist. MCP tool names (list_cloud_workspaces, ...) were used only whenis_hosted_mcp_mode()was true. Local stdio MCP users were therefore told to calllist_workspaces/list_organizations/get_default_context_for_user, which are Python method names. The check is nowis_mcp_mode(), which is set for both stdio and HTTP. Python library users still get the method names.Not in this PR: the self-managed web URL fix (
get_web_url_root, #563), which is being handled separately. The structured JSON returns for deploy and sync tools are tracked in #1306.Tests: a new parametrized test in
test_cloud_client.pycovers an instance admin with one workspace, an instance admin with several, and a non-admin. A new test checks thatlist_workspaces_by_userhonorspage_size.test_exceptions.pywas updated for the mode check. I also verified both fixes end to end against a fresh OSS install; details are in the PR comment.Link to Devin session: https://app.devin.ai/sessions/355af4efe7714d2c9cc309084393dcf9
Open in Devin Desktop: https://app.devin.ai/desktop/session/355af4efe7714d2c9cc309084393dcf9?variant=devin
Requested by: Aaron ("AJ") Steers (@aaronsteers)