import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { BirstClient } from "../../client/birstClient.js";
import { z } from "zod";
interface Space {
id: string;
name: string;
ownerUsername?: string;
comments?: string;
automatic?: boolean;
spaceTimeZone?: string;
usageTracking?: boolean;
isDocumentRepository?: boolean;
alwaysOn?: boolean;
useNewDashboards?: boolean;
readOnly?: boolean;
modifiedByUsername?: string;
databaseLinks?: string[];
}
const inputSchema = z.object({
spaceId: z.string().describe("The ID of the space to retrieve"),
});
export function registerGetSpace(server: McpServer, client: BirstClient): void {
server.tool(
"birst_get_space",
"Get detailed information about a specific Birst space including timezone, settings, and configuration.",
inputSchema.shape,
async (args) => {
const { spaceId } = inputSchema.parse(args);
const space = await client.rest<Space>(`/spaces/${spaceId}`);
return {
content: [
{
type: "text" as const,
text: JSON.stringify(
{
success: true,
space: {
id: space.id,
name: space.name,
owner: space.ownerUsername,
description: space.comments,
timezone: space.spaceTimeZone,
settings: {
usageTracking: space.usageTracking,
isDocumentRepository: space.isDocumentRepository,
alwaysOn: space.alwaysOn,
useNewDashboards: space.useNewDashboards,
readOnly: space.readOnly,
},
modifiedBy: space.modifiedByUsername,
databaseLinks: space.databaseLinks,
},
},
null,
2
),
},
],
};
}
);
}