Skip to main content
Glama
severity1

terraform-cloud-mcp

list_workspaces

Retrieve and filter workspaces in a Terraform Cloud organization to discover configurations or find specific workspaces by name.

Instructions

List workspaces in an organization.

Retrieves a paginated list of all workspaces in a Terraform Cloud organization. Results can be filtered using a search string to find specific workspaces by name. Use this tool to discover existing workspaces, check workspace configurations, or find specific workspaces by partial name match.

API endpoint: GET /organizations/{organization}/workspaces

Args: organization: The name of the organization to list workspaces from page_number: The page number to return (default: 1) page_size: The number of items per page (default: 20, max: 100) search: Optional search string to filter workspaces by name

Returns: Paginated list of workspaces with their configuration settings and metadata

See: docs/tools/workspace.md for reference documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationYes
page_numberNo
page_sizeNo
searchNo

Implementation Reference

  • The main handler function that executes the list_workspaces tool logic. It validates input using WorkspaceListRequest, constructs query parameters, and makes a GET request to the Terraform Cloud API endpoint /organizations/{organization}/workspaces.
    @handle_api_errors
    async def list_workspaces(
        organization: str,
        page_number: int = 1,
        page_size: int = 20,
        search: Optional[str] = None,
    ) -> APIResponse:
        """List workspaces in an organization.
    
        Retrieves a paginated list of all workspaces in a Terraform Cloud organization.
        Results can be filtered using a search string to find specific workspaces by name.
        Use this tool to discover existing workspaces, check workspace configurations,
        or find specific workspaces by partial name match.
    
        API endpoint: GET /organizations/{organization}/workspaces
    
        Args:
            organization: The name of the organization to list workspaces from
            page_number: The page number to return (default: 1)
            page_size: The number of items per page (default: 20, max: 100)
            search: Optional search string to filter workspaces by name
    
        Returns:
            Paginated list of workspaces with their configuration settings and metadata
    
        See:
            docs/tools/workspace.md for reference documentation
        """
        # Create request using Pydantic model for validation
        request = WorkspaceListRequest(
            organization=organization,
            page_number=page_number,
            page_size=page_size,
            search=search,
        )
    
        params = query_params(request)
    
        return await api_request(
            f"organizations/{organization}/workspaces", method="GET", params=params
        )
  • Registration of the list_workspaces tool using FastMCP's mcp.tool() decorator, making it available in the MCP server.
    mcp.tool()(workspaces.list_workspaces)
  • Pydantic model defining the input schema for list_workspaces, used for validation of parameters like organization, page_number, page_size, and search.
    class WorkspaceListRequest(APIRequest):
        """Request parameters for listing workspaces in an organization.
    
        Defines the parameters for the workspace listing API including pagination
        and search filtering options.
    
        Reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#list-workspaces
    
        See:
            docs/models/workspace.md for reference
        """
    
        organization: str = Field(
            ...,
            # No alias needed as field name matches API field name
            description="The name of the organization to list workspaces from",
        )
        page_number: Optional[int] = Field(1, ge=1, description="Page number to fetch")
        page_size: Optional[int] = Field(
            20, ge=1, le=100, description="Number of results per page"
        )
        search: Optional[str] = Field(None, description="Substring to search for")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does reveal important behavioral traits: pagination behavior, filtering capabilities, and that it retrieves configuration settings and metadata. However, it doesn't mention authentication requirements, rate limits, error conditions, or whether this is a read-only operation (though 'list' and 'retrieves' imply reading).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections: purpose statement, detailed explanation, API endpoint reference, parameter documentation, return value description, and documentation reference. While slightly longer than minimal, every section adds value. The front-loaded purpose statement is clear and informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description provides good coverage. It explains what the tool does, how to use parameters, what it returns, and references additional documentation. The main gap is lack of explicit behavioral constraints (auth, rate limits, errors) which would be helpful for a tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. It does this well by explaining all 4 parameters in the 'Args' section with clear semantics: organization context, pagination controls (with defaults and max), and search filtering purpose. The description adds significant value beyond what the bare schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('list', 'retrieves', 'filter') and resources ('workspaces in an organization', 'paginated list'). It distinguishes itself from siblings like 'get_workspace_details' by focusing on listing multiple workspaces rather than fetching details of a single one. The description explicitly mentions filtering capabilities and use cases.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('to discover existing workspaces, check workspace configurations, or find specific workspaces by partial name match'). It doesn't explicitly state when NOT to use it or name specific alternatives, but the context is sufficient to understand this is for listing/filtering workspaces rather than creating or modifying them.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/severity1/terraform-cloud-mcp'

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