list-workspaces
Retrieve all workspaces within a specified organization using the Terrakube MCP Server. Manage infrastructure efficiently by accessing and organizing workspace details.
Instructions
Lists all workspaces in the specified organization
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"organizationId": "<organizationId>"
},
"name": "list-workspaces"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID |
Implementation Reference
- src/tools/workspaces.ts:12-31 (handler)Handler function for 'list-workspaces' tool that fetches workspaces from the API for the given organizationId and returns JSON-formatted data.
async ({ organizationId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to list workspaces: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/tools/workspaces.ts:9-11 (schema)Input schema for 'list-workspaces' tool using Zod, requiring an organizationId string.
{ organizationId: z.string().describe("Organization ID") }, - src/tools/workspaces.ts:6-32 (registration)Registers the 'list-workspaces' tool on the MCP server, including name, description, input schema, and handler function.
server.tool( "list-workspaces", "Lists all workspaces in the specified organization", { organizationId: z.string().describe("Organization ID") }, async ({ organizationId }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${organizationId}/workspace`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to list workspaces: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); - src/index.ts:23-23 (registration)Top-level call to registerWorkspaceTools in the main server setup, which registers the 'list-workspaces' tool among others.
registerWorkspaceTools(server);