import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import test from "node:test"; test("exposes one authenticated idempotent MCP tool for creating distribution tasks", async () => { const [route, taskService, actionRoute, readme, envExample, packageJson] = await Promise.all([ readFile(new URL("../app/api/mcp/route.ts", import.meta.url), "utf8"), readFile(new URL("../lib/task-service.ts", import.meta.url), "utf8"), readFile(new URL("../app/api/action/route.ts", import.meta.url), "utf8"), readFile(new URL("../README.md", import.meta.url), "utf8"), readFile(new URL("../.dev.vars.example", import.meta.url), "utf8"), readFile(new URL("../package.json", import.meta.url), "utf8"), ]); assert.match(route, /createMcpHandler/); assert.match(route, /create_distribution_task/); assert.match(route, /KOC_MCP_API_KEY/); assert.match(route, /Authorization/); assert.match(route, /Bearer/); assert.match(route, /idempotentHint: true/); assert.match(route, /brand_project\?\.trim\(\) \|\| "未设置项目"/); assert.match(route, /buildClaimUrl/); assert.match(route, /structuredContent: output/); assert.match(route, /legacy: "stateless"/); assert.match(route, /responseMode: "json"/); assert.doesNotMatch(route, /ADMIN_INTERNAL_TOKEN/); assert.match(taskService, /readFeishuSource/); assert.match(taskService, /options\.deduplicate/); assert.ok( taskService.indexOf("findExistingTask(input.feishuUrl, input)") < taskService.indexOf("readFeishuSource(input.feishuUrl, bindings)"), ); assert.match(taskService, /searchParams\.delete\("from"\)/); assert.match(taskService, /status IN \('active', 'importing'\)/); assert.match(taskService, /shareToken/); assert.match(actionRoute, /createDistributionTask/); assert.doesNotMatch(actionRoute, /function createTaskFromSource/); assert.match(readme, /create_distribution_task/); assert.match(readme, /\/api\/mcp/); assert.match(envExample, /KOC_MCP_API_KEY/); assert.match(packageJson, /@modelcontextprotocol\/server/); assert.match(packageJson, /"zod"/); });