Skip to main content
Glama

infracost_cloud_list_guardrails

Retrieve all cost guardrails configured in Infracost Cloud to monitor and enforce budget controls across your cloud infrastructure.

Instructions

List all guardrails in Infracost Cloud. Requires INFRACOST_SERVICE_TOKEN environment variable.

Input Schema

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

Implementation Reference

  • The primary handler method in InfracostTools class that validates the input arguments using ListGuardrailsSchema, retrieves the organization slug, calls the API client's listGuardrails method, and returns the formatted response content.
    async handleListGuardrails(args: z.infer<typeof ListGuardrailsSchema>) { 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 result = await this.cloudApiClient.listGuardrails(orgSlug); if (!result.success) { throw new Error(result.error || 'List guardrails request failed'); } return { content: [ { type: 'text', text: result.output || 'Guardrails retrieved successfully', }, ], }; }
  • Zod schema defining the input parameters for the tool, including optional orgSlug.
    export const ListGuardrailsSchema = z.object({ orgSlug: z.string().optional().describe('Organization slug from Infracost Cloud (defaults to INFRACOST_ORG env var)'), });
  • src/index.ts:487-501 (registration)
    Tool registration in the ListTools response, providing name, description, and input schema.
    { name: 'infracost_cloud_list_guardrails', description: 'List all guardrails in 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)', }, }, required: [], }, },
  • Helper method in InfracostCloudAPIClient that performs the actual HTTP GET request to the Infracost Cloud API endpoint for listing guardrails, parses the JSON response, and handles errors.
    async listGuardrails(orgSlug: string): Promise<CommandResult> { try { const response = await fetch(`${INFRACOST_CLOUD_API_BASE}/orgs/${orgSlug}/guardrails`, { 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 GuardrailList; 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:754-757 (registration)
    Dispatching case in the CallToolRequest handler switch statement that parses arguments and delegates to the tool handler.
    case 'infracost_cloud_list_guardrails': { const validatedArgs = ListGuardrailsSchema.parse(args); return await tools.handleListGuardrails(validatedArgs); }

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