edit-variable
Modify details of an existing variable in Terrakube MCP Server, including key, value, category, and sensitivity, to ensure accurate infrastructure configuration.
Instructions
Updates an existing variable's details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | New variable category | |
| description | No | New variable description | |
| key | No | New variable key | |
| organizationId | Yes | Organization ID | |
| sensitive | No | New sensitive flag | |
| value | No | New variable value | |
| variableId | Yes | Variable ID | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- src/tools/variables.ts:129-161 (handler)Handler function that performs a PATCH request to the Terraform Cloud API to update the variable's attributes (key, value, description, category, sensitive). Returns success message on 204 or throws error.async ({ organizationId, workspaceId, variableId, key, value, description, category, sensitive }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable/${variableId}`, { method: "PATCH", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "variable", id: variableId, attributes: { key, value, description, category, sensitive } } }) }); if (response.status === 204) { return { content: [{ type: "text", text: "Variable updated successfully" }] }; } else { throw new Error(`Failed to update variable: ${response.statusText}`); } }
- src/tools/variables.ts:119-128 (schema)Zod input schema for the edit-variable tool, requiring organizationId, workspaceId, variableId, and allowing optional updates to key, value, description, category, sensitive.{ organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), variableId: z.string().describe("Variable ID"), key: z.string().optional().describe("New variable key"), value: z.string().optional().describe("New variable value"), description: z.string().optional().describe("New variable description"), category: z.string().optional().describe("New variable category"), sensitive: z.boolean().optional().describe("New sensitive flag") },
- src/tools/variables.ts:116-162 (registration)Registration of the 'edit-variable' tool on the MCP server within the registerVariableTools function, specifying name, description, input schema, and handler implementation.server.tool( "edit-variable", "Updates an existing variable's details", { organizationId: z.string().describe("Organization ID"), workspaceId: z.string().describe("Workspace ID"), variableId: z.string().describe("Variable ID"), key: z.string().optional().describe("New variable key"), value: z.string().optional().describe("New variable value"), description: z.string().optional().describe("New variable description"), category: z.string().optional().describe("New variable category"), sensitive: z.boolean().optional().describe("New sensitive flag") }, async ({ organizationId, workspaceId, variableId, key, value, description, category, sensitive }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace/${workspaceId}/variable/${variableId}`, { method: "PATCH", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: JSON.stringify({ data: { type: "variable", id: variableId, attributes: { key, value, description, category, sensitive } } }) }); if (response.status === 204) { return { content: [{ type: "text", text: "Variable updated successfully" }] }; } else { throw new Error(`Failed to update variable: ${response.statusText}`); } } );