import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import type { BetterNewsClient } from "../client.js"; export function registerLegalTools(server: McpServer, client: BetterNewsClient) { server.tool( "get_terms_of_service", "Get the current published Terms of Service document.", {}, async () => { const data = await client.get("/api/legal/current/terms_of_service"); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }, ); server.tool( "get_privacy_policy", "Get the current published Privacy Policy document.", {}, async () => { const data = await client.get("/api/legal/current/privacy_policy"); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }, ); server.tool( "list_legal_documents", "List legal documents. Public sees published only; Mod/Admin see all.", { type: z.enum(["terms_of_service", "privacy_policy"]).optional().describe("Filter by document type"), status: z.enum(["draft", "published", "archived"]).optional().describe("Filter by status (Mod/Admin only)"), page: z.number().int().positive().optional(), limit: z.number().int().min(1).max(50).optional(), }, async (args) => { const data = await client.get("/api/legal", args); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }, ); server.tool( "accept_legal_documents", "Accept the current legal documents (Terms of Service and Privacy Policy). Clears the legalAcceptanceRequired flag.", {}, async () => { const data = await client.post("/api/legal/accept"); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }, ); }