list-variables
Retrieve all variables in a specified workspace within Terrakube MCP Server, using organization and workspace IDs for accurate identification.
Instructions
Lists all variables in the specified workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/tools/variables.ts:17-37 (handler)The handler function that fetches the list of variables from the Terrakube API for the given organization and workspace, then returns the JSON data as formatted text content.async ({ organizationId, workspaceId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to list variables: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/tools/variables.ts:14-16 (schema)Zod input schema defining the required parameters: organizationId and workspaceId.organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID") },
- src/tools/variables.ts:10-37 (registration)Registration of the 'list-variables' tool with the MCP server, including name, description, input schema, and handler function.server.tool( "list-variables", "Lists all variables in the specified workspace", { organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID") }, async ({ organizationId, workspaceId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to list variables: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/index.ts:25-25 (registration)Invocation of registerVariableTools which registers the 'list-variables' tool (among others) to the main MCP server instance.registerVariableTools(server);