Skip to content

Commit 52310a0

Browse files
authored
feat(mcp): add cloud describe mcp tools (#879)
1 parent f7ba17f commit 52310a0

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

airbyte/mcp/cloud_ops.py

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,55 @@ class CloudConnectionResult(BaseModel):
6464
"""ID of the destination used by this connection."""
6565

6666

67+
class CloudSourceDetails(BaseModel):
68+
"""Detailed information about a deployed source connector in Airbyte Cloud."""
69+
70+
source_id: str
71+
"""The source ID."""
72+
source_name: str
73+
"""Display name of the source."""
74+
source_url: str
75+
"""Web URL for managing this source in Airbyte Cloud."""
76+
connector_definition_id: str
77+
"""The connector definition ID (e.g., the ID for 'source-postgres')."""
78+
79+
80+
class CloudDestinationDetails(BaseModel):
81+
"""Detailed information about a deployed destination connector in Airbyte Cloud."""
82+
83+
destination_id: str
84+
"""The destination ID."""
85+
destination_name: str
86+
"""Display name of the destination."""
87+
destination_url: str
88+
"""Web URL for managing this destination in Airbyte Cloud."""
89+
connector_definition_id: str
90+
"""The connector definition ID (e.g., the ID for 'destination-snowflake')."""
91+
92+
93+
class CloudConnectionDetails(BaseModel):
94+
"""Detailed information about a deployed connection in Airbyte Cloud."""
95+
96+
connection_id: str
97+
"""The connection ID."""
98+
connection_name: str
99+
"""Display name of the connection."""
100+
connection_url: str
101+
"""Web URL for managing this connection in Airbyte Cloud."""
102+
source_id: str
103+
"""ID of the source used by this connection."""
104+
source_name: str
105+
"""Display name of the source."""
106+
destination_id: str
107+
"""ID of the destination used by this connection."""
108+
destination_name: str
109+
"""Display name of the destination."""
110+
selected_streams: list[str]
111+
"""List of stream names selected for syncing."""
112+
table_prefix: str | None
113+
"""Table prefix applied when syncing to the destination."""
114+
115+
67116
def _get_cloud_workspace(workspace_id: str | None = None) -> CloudWorkspace:
68117
"""Get an authenticated CloudWorkspace.
69118
@@ -601,6 +650,128 @@ def list_deployed_cloud_destination_connectors(
601650
]
602651

603652

653+
@mcp_tool(
654+
domain="cloud",
655+
read_only=True,
656+
idempotent=True,
657+
open_world=True,
658+
)
659+
def describe_cloud_source(
660+
source_id: Annotated[
661+
str,
662+
Field(description="The ID of the source to describe."),
663+
],
664+
*,
665+
workspace_id: Annotated[
666+
str | None,
667+
Field(
668+
description="Workspace ID. Defaults to AIRBYTE_CLOUD_WORKSPACE_ID env var.",
669+
default=None,
670+
),
671+
],
672+
) -> CloudSourceDetails:
673+
"""Get detailed information about a specific deployed source connector.
674+
675+
By default, the `AIRBYTE_CLIENT_ID`, `AIRBYTE_CLIENT_SECRET`, `AIRBYTE_WORKSPACE_ID`,
676+
and `AIRBYTE_API_ROOT` environment variables will be used to authenticate with the
677+
Airbyte Cloud API.
678+
"""
679+
workspace: CloudWorkspace = _get_cloud_workspace(workspace_id)
680+
source = workspace.get_source(source_id=source_id)
681+
682+
# Access name property to ensure _connector_info is populated
683+
source_name = cast(str, source.name)
684+
685+
return CloudSourceDetails(
686+
source_id=source.source_id,
687+
source_name=source_name,
688+
source_url=source.connector_url,
689+
connector_definition_id=source._connector_info.definition_id, # noqa: SLF001 # type: ignore[union-attr]
690+
)
691+
692+
693+
@mcp_tool(
694+
domain="cloud",
695+
read_only=True,
696+
idempotent=True,
697+
open_world=True,
698+
)
699+
def describe_cloud_destination(
700+
destination_id: Annotated[
701+
str,
702+
Field(description="The ID of the destination to describe."),
703+
],
704+
*,
705+
workspace_id: Annotated[
706+
str | None,
707+
Field(
708+
description="Workspace ID. Defaults to AIRBYTE_CLOUD_WORKSPACE_ID env var.",
709+
default=None,
710+
),
711+
],
712+
) -> CloudDestinationDetails:
713+
"""Get detailed information about a specific deployed destination connector.
714+
715+
By default, the `AIRBYTE_CLIENT_ID`, `AIRBYTE_CLIENT_SECRET`, `AIRBYTE_WORKSPACE_ID`,
716+
and `AIRBYTE_API_ROOT` environment variables will be used to authenticate with the
717+
Airbyte Cloud API.
718+
"""
719+
workspace: CloudWorkspace = _get_cloud_workspace(workspace_id)
720+
destination = workspace.get_destination(destination_id=destination_id)
721+
722+
# Access name property to ensure _connector_info is populated
723+
destination_name = cast(str, destination.name)
724+
725+
return CloudDestinationDetails(
726+
destination_id=destination.destination_id,
727+
destination_name=destination_name,
728+
destination_url=destination.connector_url,
729+
connector_definition_id=destination._connector_info.definition_id, # noqa: SLF001 # type: ignore[union-attr]
730+
)
731+
732+
733+
@mcp_tool(
734+
domain="cloud",
735+
read_only=True,
736+
idempotent=True,
737+
open_world=True,
738+
)
739+
def describe_cloud_connection(
740+
connection_id: Annotated[
741+
str,
742+
Field(description="The ID of the connection to describe."),
743+
],
744+
*,
745+
workspace_id: Annotated[
746+
str | None,
747+
Field(
748+
description="Workspace ID. Defaults to AIRBYTE_CLOUD_WORKSPACE_ID env var.",
749+
default=None,
750+
),
751+
],
752+
) -> CloudConnectionDetails:
753+
"""Get detailed information about a specific deployed connection.
754+
755+
By default, the `AIRBYTE_CLIENT_ID`, `AIRBYTE_CLIENT_SECRET`, `AIRBYTE_WORKSPACE_ID`,
756+
and `AIRBYTE_API_ROOT` environment variables will be used to authenticate with the
757+
Airbyte Cloud API.
758+
"""
759+
workspace: CloudWorkspace = _get_cloud_workspace(workspace_id)
760+
connection = workspace.get_connection(connection_id=connection_id)
761+
762+
return CloudConnectionDetails(
763+
connection_id=connection.connection_id,
764+
connection_name=cast(str, connection.name),
765+
connection_url=cast(str, connection.connection_url),
766+
source_id=connection.source_id,
767+
source_name=cast(str, connection.source.name),
768+
destination_id=connection.destination_id,
769+
destination_name=cast(str, connection.destination.name),
770+
selected_streams=connection.stream_names,
771+
table_prefix=connection.table_prefix,
772+
)
773+
774+
604775
@mcp_tool(
605776
domain="cloud",
606777
read_only=True,

0 commit comments

Comments
 (0)