Skip to main content
Glama

Terrakube MCP Server

by terrakube-io
organizations.ts3.85 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { CONFIG } from "../config.js"; /** * Register organization tools to an MCP server * @param server The MCP server instance */ export function registerOrganizationTools(server: McpServer) { server.tool( "list-organizations", "Lists all organizations accessible to the current user", {}, async () => { const response = await fetch(`${CONFIG.apiUrl}/organization`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to list organizations: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); server.tool( "get-organization", "Retrieves detailed information about a specific organization by its ID", { id: z.string().describe("Organization ID") }, async ({ id }) => { const response = await fetch(`${CONFIG.apiUrl}/organization/${id}`, { headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" } }); if (!response.ok) { throw new Error(`Failed to get organization: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); server.tool( "create-organization", "Creates a new organization with the specified name and optional description", { name: z.string().describe("Organization name"), description: z.string().optional().describe("Organization description") }, async ({ name, description = "" }) => { const body = JSON.stringify({ data: { type: "organization", attributes: { name, description } } }); const response = await fetch(`${CONFIG.apiUrl}/organization`, { method: "POST", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: body }); if (response.status === 201) { const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } else { throw new Error(`Failed to create organization: ${response.statusText}`); } } ); server.tool( "edit-organization", "Updates an existing organization's details", { id: z.string().describe("Organization ID"), name: z.string().optional().describe("New organization name"), description: z.string().optional().describe("New organization description") }, async ({ id, name, description }) => { const body = JSON.stringify({ data: { type: "organization", id, attributes: { name, description } } }); const response = await fetch(`${CONFIG.apiUrl}/organization/${id}`, { method: "PATCH", headers: { Authorization: `Bearer ${CONFIG.patToken}`, "Content-Type": "application/vnd.api+json" }, body: body }); if (!response.ok) { throw new Error(`Failed to update organization: ${response.statusText}`); } const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/terrakube-io/mcp-server-terrakube'

If you have feedback or need assistance with the MCP directory API, please join our Discord server