get_workspace_by_handle
Retrieve workspace details using account and workspace handles to access specific workflow automation environments in Prefect.
Instructions
Get a workspace by its handle.
Args: account_handle: The account handle workspace_handle: The workspace handle
Returns: Workspace details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_handle | Yes | ||
| workspace_handle | Yes |
Implementation Reference
- src/mcp_prefect/workspace.py:94-123 (handler)The main handler function for the 'get_workspace_by_handle' MCP tool. It is decorated with @mcp.tool, which registers it. The function retrieves the Prefect workspace using the provided account_handle and workspace_handle via the Prefect client and returns its details as text content.@mcp.tool async def get_workspace_by_handle( account_handle: str, workspace_handle: str, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: """ Get a workspace by its handle. Args: account_handle: The account handle workspace_handle: The workspace handle Returns: Workspace details """ try: async with get_client() as client: workspace = await client.read_workspace_by_handle( account_handle=account_handle, workspace_handle=workspace_handle ) return [types.TextContent(type="text", text=str(workspace.dict()))] except Exception as e: # For local Prefect instances, workspace APIs may not be available return [types.TextContent( type="text", text="Workspaces are only available in Prefect Cloud. This appears to be a local Prefect instance." )]