get_workspace
Retrieve workspace details from Prefect's workflow automation platform by providing the workspace UUID to access specific workflow environments and configurations.
Instructions
Get a workspace by ID.
Args: workspace_id: The workspace UUID
Returns: Workspace details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | Yes |
Implementation Reference
- src/mcp_prefect/workspace.py:68-92 (handler)The @mcp.tool decorated handler function that implements the get_workspace tool. It fetches the workspace details by ID using the Prefect client and returns it as TextContent, with fallback message for local instances.@mcp.tool async def get_workspace( workspace_id: str, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: """ Get a workspace by ID. Args: workspace_id: The workspace UUID Returns: Workspace details """ try: async with get_client() as client: workspace = await client.read_workspace_by_id(UUID(workspace_id)) 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." )]
- src/mcp_prefect/main.py:54-56 (registration)The conditional import of the workspace module in main.py, which triggers the registration of workspace tools (including get_workspace) via their @mcp.tool decorators when the Workspace API is enabled.if APIType.WORKSPACE.value in apis: info("Loading Workspace API...") from . import workspace