Skip to main content
Glama
matchs

Terraform Cloud MCP Server

by matchs

Get Workspace Details

get_workspace_details

Retrieve detailed information about a Terraform Cloud workspace, including its configuration and current state, to manage infrastructure deployments effectively.

Instructions

Get detailed information about a Terraform Cloud workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceNameYesWorkspace name
organizationNoOrganization nameurbanmedia

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
nameYes
lockedYes
vcsRepoNo
autoApplyYes
executionModeYes
terraformVersionYes
workingDirectoryNo

Implementation Reference

  • The handler function that implements the logic for the 'get_workspace_details' tool by fetching workspace data from the Terraform Cloud API using tfCloudRequest and formatting the output.
    async ({ workspaceName, organization }) => {
      try {
        const data = await tfCloudRequest(`/organizations/${organization}/workspaces/${workspaceName}`);
        const attrs = data.data.attributes;
        
        const output = {
          id: data.data.id,
          name: attrs.name,
          locked: attrs.locked,
          executionMode: attrs['execution-mode'],
          autoApply: attrs['auto-apply'],
          terraformVersion: attrs['terraform-version'],
          workingDirectory: attrs['working-directory'] || undefined,
          vcsRepo: attrs['vcs-repo'] ? {
            identifier: attrs['vcs-repo'].identifier,
            branch: attrs['vcs-repo'].branch
          } : undefined
        };
    
        return {
          content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
          structuredContent: output
        };
      } catch (error) {
        const errorMsg = error instanceof Error ? error.message : String(error);
        return {
          content: [{ type: 'text', text: `Error: ${errorMsg}` }],
          isError: true
        };
      }
    }
  • Zod schema definitions for input (workspaceName, organization) and output fields of the get_workspace_details tool.
    {
      title: 'Get Workspace Details',
      description: 'Get detailed information about a Terraform Cloud workspace',
      inputSchema: {
        workspaceName: z.string().describe('Workspace name'),
        organization: z.string().default('urbanmedia').describe('Organization name')
      },
      outputSchema: {
        id: z.string(),
        name: z.string(),
        locked: z.boolean(),
        executionMode: z.string(),
        autoApply: z.boolean(),
        terraformVersion: z.string(),
        workingDirectory: z.string().optional(),
        vcsRepo: z.object({
          identifier: z.string(),
          branch: z.string()
        }).optional()
      }
    },
  • src/index.ts:166-220 (registration)
    The server.registerTool call that registers the 'get_workspace_details' tool with its schema and handler function.
    server.registerTool(
      'get_workspace_details',
      {
        title: 'Get Workspace Details',
        description: 'Get detailed information about a Terraform Cloud workspace',
        inputSchema: {
          workspaceName: z.string().describe('Workspace name'),
          organization: z.string().default('urbanmedia').describe('Organization name')
        },
        outputSchema: {
          id: z.string(),
          name: z.string(),
          locked: z.boolean(),
          executionMode: z.string(),
          autoApply: z.boolean(),
          terraformVersion: z.string(),
          workingDirectory: z.string().optional(),
          vcsRepo: z.object({
            identifier: z.string(),
            branch: z.string()
          }).optional()
        }
      },
      async ({ workspaceName, organization }) => {
        try {
          const data = await tfCloudRequest(`/organizations/${organization}/workspaces/${workspaceName}`);
          const attrs = data.data.attributes;
          
          const output = {
            id: data.data.id,
            name: attrs.name,
            locked: attrs.locked,
            executionMode: attrs['execution-mode'],
            autoApply: attrs['auto-apply'],
            terraformVersion: attrs['terraform-version'],
            workingDirectory: attrs['working-directory'] || undefined,
            vcsRepo: attrs['vcs-repo'] ? {
              identifier: attrs['vcs-repo'].identifier,
              branch: attrs['vcs-repo'].branch
            } : undefined
          };
    
          return {
            content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
            structuredContent: output
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          return {
            content: [{ type: 'text', text: `Error: ${errorMsg}` }],
            isError: true
          };
        }
      }
    );
  • Helper function used by the tool to make authenticated API requests to Terraform Cloud.
    async function tfCloudRequest(endpoint: string): Promise<any> {
      const token = getTerraformToken();
      const response = await fetch(`${TF_API_BASE}${endpoint}`, {
        headers: {
          'Authorization': `Bearer ${token}`,
          'Content-Type': 'application/vnd.api+json'
        }
      });
    
      if (!response.ok) {
        throw new Error(`Terraform Cloud API error: ${response.statusText}`);
      }
    
      return response.json();
    }
Behavior2/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 states this is a read operation ('Get'), implying it's non-destructive, but doesn't mention any behavioral traits like authentication needs, rate limits, error handling, or what 'detailed information' entails beyond the output schema.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with no wasted content.

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

Completeness3/5

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

Given the tool's low complexity, 100% schema coverage, and presence of an output schema, the description is minimally adequate. However, it lacks context about when to use it versus siblings and behavioral details, which are gaps despite the structured data support.

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

Parameters3/5

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

The schema description coverage is 100%, so the schema already documents both parameters ('workspaceName' and 'organization') adequately. The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or constraints, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'detailed information about a Terraform Cloud workspace', making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'list_workspaces' or 'get_run_details', which prevents a perfect score.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives such as 'list_workspaces' for a broader overview or 'get_run_details' for run-specific information. The description lacks any context about prerequisites or exclusions.

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/matchs/tf-cloud-mcp-server'

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