Repository navigation
feat(mcp): add clear_cloud_connection tool and CloudConnection.clear() - #1431
Michael Lip (theluckystrike) wants to merge 1 commit into
Conversation
…ar()` Agents had no way to clear synced data for a Cloud connection, so a re-sync after a schema or cursor change meant leaving the agent for the UI or the API. `CloudConnection.clear()` starts a clear job for the whole connection or for named selected streams (Config API /v1/connections/clear and /v1/connections/clear/stream). The new `clear_cloud_connection` MCP tool is marked destructive, respects safe mode, and requires the connection name as confirmation. Closes airbytehq#1385
|
Note 📝 PR Converted to Draft More info...Thank you for creating this PR. As a policy to protect our engineers' time, Airbyte requires all PRs to be created first in draft status. Your PR has been automatically converted to draft status in respect for this policy. As soon as your PR is ready for formal review, you can proceed to convert the PR to "ready for review" status by clicking the "Ready for review" button at the bottom of the PR page. To skip draft status in future PRs, please include |
👋 Welcome to PyAirbyte!Thank you for your contribution from theluckystrike/PyAirbyte! We're excited to have you in the Airbyte community. 💡 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/theluckystrike/PyAirbyte.git@fix/1385-clear-cloud-connection' pyairbyte --help
# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/theluckystrike/PyAirbyte.git@fix/1385-clear-cloud-connection'PR Slash CommandsAs needed or by request, Airbyte Maintainers can execute the following slash commands on your PR:
📚 Show Repo GuidanceHelpful ResourcesIf you have any questions, feel free to ask in the PR comments or join our community:
|
Overview
TL;DR: Agents can now clear synced data for an Airbyte Cloud connection, for all streams or only the named ones, without leaving the agent for the UI or the API. The new
clear_cloud_connectionMCP tool is marked destructive, respects safe mode, and needs the connection name as confirmation.Closes #1385
Changes
api_util.clear_connection(): calls the Config APIPOST /v1/connections/clear, orPOST /v1/connections/clear/streamwhen stream descriptors are given. These are the same endpoints the Cloud web app uses for "Clear data".CloudConnection.clear(stream_names=None): starts the clear job and returns aSyncResultfor it (no wait; callwait_for_completion()to wait). Named streams are resolved against the selected streams of the connection's catalog, so each descriptor carries its source namespace. It raisesPyAirbyteInputErrorbefore any API call for an empty list, for a stream that is unknown or not selected, and for a stream name that exists in more than one namespace (it does not guess which one).clear_cloud_connectionMCP tool:destructive=True,open_world=True. It callscheck_guid_created_in_sessionlike the other destructive tools, and requiresnameto match the connection's actual name, likepermanently_delete_cloud_connection.stream_namesaccepts a list, a CSV string or a JSON array string, throughresolve_list_of_strings. An empty string resolves to an empty list and is refused, so it can never fall back to "clear everything". The reply gives the job ID and the job URL.Review Spotlight
CloudConnection._resolve_stream_descriptors(): how stream names map to namespaced descriptors.clear_cloud_connection: safe mode check, then workspace lookup, then name confirmation, then the clear.Risks
jobsendpoint has no per-stream clear.Test plan
tests/unit_tests/test_cloud_api_util.py: endpoint path and body for a full clear and a per-stream clear.tests/unit_tests/test_cloud_connections.py: full clear, per-stream clear with namespaces and de-duplication, and the refusals for an empty list, an unknown stream, an unselected stream and an ambiguous stream name.tests/unit_tests/test_mcp_cloud.py: stream name forms (none, CSV, list), name mismatch, safe mode refusal, and the destructive hint.Commands and results (base
f229555,uv sync --frozen --all-groups):uv run pytest tests/unit_tests/test_cloud_connections.py tests/unit_tests/test_mcp_cloud.py tests/unit_tests/test_cloud_api_util.py: 122 passed.test_cloud_api_util.pyfails at collection (noclear_connection).ruff check,ruff format --checkandpyrefly check(0 errors) pass.This change was made with AI assistance and reviewed by me.