import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import type { ToolContext } from "../utils/api.js";
const json = (d: unknown) => ({ type: "text" as const, text: JSON.stringify(d, null, 2) });
export function registerSpace(server: McpServer, ctx: ToolContext): void {
const { api, requireConfig } = ctx;
server.registerTool(
"get_space",
{ description: "Get the current space details (the one from STORYBLOK_SPACE_ID)." },
async () => {
requireConfig();
const d = await api("");
return { content: [json(d)] };
}
);
server.registerTool(
"update_space",
{
description: "Update space settings. Pass an object with name, domain, plan, etc.",
inputSchema: { space: z.record(z.unknown()) },
},
async ({ space }) => {
requireConfig();
const d = await api("", { method: "PUT", body: JSON.stringify({ space }) });
return { content: [json(d)] };
}
);
}