feat: initialize BetterNews MCP server with core functionality

- Add .gitignore to exclude node_modules, dist, and .env files
- Create README.md with setup instructions and API key information
- Add package.json with dependencies, scripts, and project metadata
- Implement BetterNewsClient for API interactions
- Set up index.ts to initialize MCP server and register tools
- Create tools for managing news, comments, sources, users, moderation, and tickets
- Add TypeScript configuration for project compilation
This commit is contained in:
Space-Banane
2026-06-17 21:30:52 +02:00
commit 6c0a079808
13 changed files with 1005 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
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<unknown>("/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<unknown>("/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<unknown>("/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<unknown>("/api/legal/accept");
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
},
);
}