get-variable
Retrieve detailed information about a specific variable in Terrakube by providing the organization, workspace, and variable IDs for efficient infrastructure management.
Instructions
Retrieves detailed information about a specific variable
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID | |
| variableId | Yes | Variable ID | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/tools/variables.ts:47-66 (handler)The handler function for the 'get-variable' tool. It performs a GET request to the API to retrieve details of a specific variable identified by organizationId, workspaceId, and variableId, and returns the JSON data as text content.async ({ organizationId, workspaceId, variableId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable/${variableId}`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to get variable: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/tools/variables.ts:42-46 (schema)Input schema for the 'get-variable' tool, defining required string parameters: organizationId, workspaceId, and variableId using Zod.{ organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), variableId: z.string().describe("Variable ID") },
- src/tools/variables.ts:39-67 (registration)Registration of the 'get-variable' tool on the MCP server instance via server.tool(), specifying the tool name, description, input schema, and inline handler function.server.tool( "get-variable", "Retrieves detailed information about a specific variable", { organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), variableId: z.string().describe("Variable ID") }, async ({ organizationId, workspaceId, variableId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable/${variableId}`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to get variable: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );