create-variable
Add a new variable to a specified workspace in Terrakube MCP Server. Define key, value, category, and sensitivity to manage infrastructure configurations effectively.
Instructions
Creates a new variable in the specified workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Variable category (e.g., terraform, environment) | |
| description | No | Variable description | |
| key | Yes | Variable key | |
| organizationId | Yes | Organization ID | |
| sensitive | No | Whether the variable is sensitive | |
| value | Yes | Variable value | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/tools/variables.ts:81-113 (handler)The async handler function that executes the 'create-variable' tool logic by sending a POST request to create a new variable in the Terrakube workspace.async ({ organizationId, workspaceId, key, value, description, category, sensitive }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable`, { method: "POST", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "variable", attributes: { key, value, description, category, sensitive } } }) }); if (!response.ok) { throw new Error(`Failed to create variable: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/tools/variables.ts:72-80 (schema)Zod schema defining the input parameters for the 'create-variable' tool.{ organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), key: z.string().describe("Variable key"), value: z.string().describe("Variable value"), description: z.string().optional().describe("Variable description"), category: z.string().optional().describe("Variable category (e.g., terraform, environment)"), sensitive: z.boolean().optional().describe("Whether the variable is sensitive") },
- src/tools/variables.ts:69-114 (registration)The server.tool() call that registers the 'create-variable' tool on the MCP server, specifying name, description, input schema, and handler function.server.tool( "create-variable", "Creates a new variable in the specified workspace", { organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), key: z.string().describe("Variable key"), value: z.string().describe("Variable value"), description: z.string().optional().describe("Variable description"), category: z.string().optional().describe("Variable category (e.g., terraform, environment)"), sensitive: z.boolean().optional().describe("Whether the variable is sensitive") }, async ({ organizationId, workspaceId, key, value, description, category, sensitive }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable`, { method: "POST", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "variable", attributes: { key, value, description, category, sensitive } } }) }); if (!response.ok) { throw new Error(`Failed to create variable: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/index.ts:25-25 (registration)Call to registerVariableTools which includes the 'create-variable' tool registration on the main MCP server instance.registerVariableTools(server);