Skip to main content
Glama

get_workspaces

Retrieve a list of accessible Prefect workspaces with optional filtering by name, pagination controls, and workspace details to help manage workflow automation environments.

Instructions

Get a list of accessible workspaces.

Args: limit: Maximum number of workspaces to return offset: Number of workspaces to skip name: Filter workspaces by name (note: filtering may not be supported by all Prefect versions)

Returns: A list of workspaces with their details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
nameNo
offsetNo

Implementation Reference

  • The main handler function for the 'get_workspaces' tool, decorated with @mcp.tool which registers it. Fetches workspaces using the Prefect client and handles local vs Cloud differences.
    @mcp.tool
    async def get_workspaces(
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        name: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Get a list of accessible workspaces.
        
        Args:
            limit: Maximum number of workspaces to return
            offset: Number of workspaces to skip
            name: Filter workspaces by name (note: filtering may not be supported by all Prefect versions)
            
        Returns:
            A list of workspaces with their details
        """
        try:
            async with get_client() as client:
                workspaces = await client.read_workspaces(
                    limit=limit,
                    offset=offset,
                )
                
                workspaces_result = {
                    "workspaces": [workspace.dict() for workspace in workspaces]
                }
                
                return [types.TextContent(type="text", text=str(workspaces_result))]
        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."
            )]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/allen-munsch/mcp-prefect'

If you have feedback or need assistance with the MCP directory API, please join our Discord server