Skip to main content
Glama

infracost_cloud_get_guardrail

Retrieve specific cost guardrail details from Infracost Cloud to monitor and enforce cloud spending policies for Terraform infrastructure.

Instructions

Get a specific guardrail from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orgSlugNoOrganization slug from Infracost Cloud (defaults to INFRACOST_ORG env var)
guardrailIdYesGuardrail ID

Implementation Reference

  • Main handler for the 'infracost_cloud_get_guardrail' tool. Validates arguments using GetGuardrailSchema, calls the API client to fetch the guardrail, and formats the response as MCP content.
    async handleGetGuardrail(args: z.infer<typeof GetGuardrailSchema>) {
      if (!this.cloudApiClient) {
        throw new Error('INFRACOST_SERVICE_TOKEN is not configured for Infracost Cloud API operations');
      }
    
      const orgSlug = args.orgSlug || this.config.orgSlug;
      if (!orgSlug) {
        throw new Error('Organization slug is required. Provide it via orgSlug parameter or set INFRACOST_ORG environment variable');
      }
    
      const { guardrailId } = args;
      const result = await this.cloudApiClient.getGuardrail(orgSlug, guardrailId);
    
      if (!result.success) {
        throw new Error(result.error || 'Get guardrail request failed');
      }
    
      return {
        content: [
          {
            type: 'text',
            text: result.output || 'Guardrail retrieved successfully',
          },
        ],
      };
    }
  • Zod schema for input validation of the tool, defining orgSlug (optional) and required guardrailId.
    export const GetGuardrailSchema = z.object({
      orgSlug: z.string().optional().describe('Organization slug from Infracost Cloud (defaults to INFRACOST_ORG env var)'),
      guardrailId: z.string().describe('Guardrail ID'),
    });
  • Core API client method that performs the GET request to retrieve the specific guardrail from Infracost Cloud API.
    async getGuardrail(orgSlug: string, guardrailId: string): Promise<CommandResult> {
      try {
        const response = await fetch(
          `${INFRACOST_CLOUD_API_BASE}/orgs/${orgSlug}/guardrails/${guardrailId}`,
          {
            method: 'GET',
            headers: {
              Authorization: `Bearer ${this.serviceToken}`,
            },
          }
        );
    
        if (!response.ok) {
          const errorText = await response.text();
          return {
            success: false,
            error: `API request failed with status ${response.status}: ${errorText}`,
          };
        }
    
        const data = (await response.json()) as { data: Guardrail };
    
        return {
          success: true,
          output: JSON.stringify(data, null, 2),
          data,
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error occurred',
        };
      }
    }
  • src/index.ts:502-520 (registration)
    Tool registration in the ListTools handler, including name, description, and input schema (derived from GetGuardrailSchema).
    {
      name: 'infracost_cloud_get_guardrail',
      description:
        'Get a specific guardrail from Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.',
      inputSchema: {
        type: 'object',
        properties: {
          orgSlug: {
            type: 'string',
            description: 'Organization slug from Infracost Cloud (defaults to INFRACOST_ORG env var)',
          },
          guardrailId: {
            type: 'string',
            description: 'Guardrail ID',
          },
        },
        required: ['guardrailId'],
      },
    },
  • src/index.ts:759-762 (registration)
    Registration in the CallTool switch statement, parsing args with schema and delegating to tools.handleGetGuardrail.
    case 'infracost_cloud_get_guardrail': {
      const validatedArgs = GetGuardrailSchema.parse(args);
      return await tools.handleGetGuardrail(validatedArgs);
    }
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 mentions the required environment variable for authentication, which is useful context. However, it doesn't describe other key behaviors such as whether this is a read-only operation, potential error conditions, rate limits, or what the output looks like (especially since there's no output schema). This leaves significant gaps for a tool that fetches specific resources.

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 brief and front-loaded with the core purpose in the first sentence, followed by an important prerequisite. Both sentences earn their place by providing essential information without redundancy. A perfect score is reserved for exceptionally polished descriptions, but this is efficiently structured.

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

Completeness2/5

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

Given the complexity of fetching a specific resource, the lack of annotations, and no output schema, the description is incomplete. It mentions authentication but omits details about the guardrail concept, expected return format, error handling, or how it differs from sibling tools. For a tool with no structured behavioral hints, this leaves the agent under-informed.

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 input schema has 100% description coverage, clearly documenting both parameters (orgSlug and guardrailId) with their types and purposes. The description adds no additional parameter information beyond what's in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 action ('Get') and resource ('a specific guardrail from Infracost Cloud'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'infracost_cloud_list_guardrails' (which likely lists multiple guardrails) or explain what a 'guardrail' is in this context, preventing 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 Guidelines3/5

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

The description provides some usage context by mentioning the required INFRACOST_SERVICE_TOKEN environment variable, which implies authentication needs. However, it doesn't specify when to use this tool versus alternatives like 'infracost_cloud_list_guardrails' or 'infracost_cloud_update_guardrail', leaving the agent to infer based on tool names alone.

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/phildougherty/infracost_mcp'

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