Expand KOC LOOP MCP operations
This commit is contained in:
@@ -2,10 +2,14 @@ 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] =
|
||||
test("exposes authenticated KOC task, recovery, collection, and resource MCP tools", async () => {
|
||||
const [route, tools, operations, tokenService, migration, taskService, actionRoute, readme, envExample, packageJson] =
|
||||
await Promise.all([
|
||||
readFile(new URL("../app/api/mcp/route.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../lib/mcp-tools.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../lib/mcp-operations.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../lib/mcp-export-token.ts", import.meta.url), "utf8"),
|
||||
readFile(new URL("../drizzle/0008_worried_ultimatum.sql", 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"),
|
||||
@@ -15,6 +19,22 @@ test("exposes one authenticated idempotent MCP tool for creating distribution ta
|
||||
|
||||
assert.match(route, /createMcpHandler/);
|
||||
assert.match(route, /create_distribution_task/);
|
||||
for (const name of [
|
||||
"task_list",
|
||||
"task_get",
|
||||
"recovery_list",
|
||||
"recovery_export",
|
||||
"collection_plan_set",
|
||||
"collection_run_due",
|
||||
"collection_collect_now",
|
||||
"collection_retry_failed",
|
||||
"resource_search",
|
||||
"resource_get",
|
||||
"resource_backfill_profile",
|
||||
"resource_export",
|
||||
]) {
|
||||
assert.match(tools, new RegExp(`"${name}"`));
|
||||
}
|
||||
assert.match(route, /KOC_MCP_API_KEY/);
|
||||
assert.match(route, /Authorization/);
|
||||
assert.match(route, /Bearer/);
|
||||
@@ -25,6 +45,16 @@ test("exposes one authenticated idempotent MCP tool for creating distribution ta
|
||||
assert.match(route, /legacy: "stateless"/);
|
||||
assert.match(route, /responseMode: "json"/);
|
||||
assert.doesNotMatch(route, /ADMIN_INTERNAL_TOKEN/);
|
||||
assert.match(route, /registerMcpOperationTools/);
|
||||
assert.match(operations, /runDueScheduledCollections/);
|
||||
assert.match(operations, /retryFailedCollections/);
|
||||
assert.match(operations, /enrichDistributionAccount/);
|
||||
assert.match(operations, /issueMcpExportToken/);
|
||||
assert.match(tokenService, /SHA-256/);
|
||||
assert.match(tokenService, /expires_at > CURRENT_TIMESTAMP/);
|
||||
assert.doesNotMatch(tokenService, /KOC_MCP_API_KEY/);
|
||||
assert.match(migration, /CREATE TABLE `mcp_export_tokens`/);
|
||||
assert.match(migration, /mcp_export_tokens_expires_at_idx/);
|
||||
|
||||
assert.match(taskService, /readFeishuSource/);
|
||||
assert.match(taskService, /options\.deduplicate/);
|
||||
@@ -39,6 +69,8 @@ test("exposes one authenticated idempotent MCP tool for creating distribution ta
|
||||
assert.doesNotMatch(actionRoute, /function createTaskFromSource/);
|
||||
|
||||
assert.match(readme, /create_distribution_task/);
|
||||
assert.match(readme, /collection_plan_set/);
|
||||
assert.match(readme, /resource_backfill_profile/);
|
||||
assert.match(readme, /\/api\/mcp/);
|
||||
assert.match(envExample, /KOC_MCP_API_KEY/);
|
||||
assert.match(packageJson, /@modelcontextprotocol\/server/);
|
||||
|
||||
@@ -246,6 +246,7 @@ test("exports complete task recovery data to Excel with embedded images", async
|
||||
assert.match(exportRoute, /screenshot_key/);
|
||||
assert.match(exportRoute, /image_assets/);
|
||||
assert.match(exportRoute, /isAdminRequest/);
|
||||
assert.match(exportRoute, /consumeMcpExportToken/);
|
||||
assert.match(workbook, /xl\/drawings\/drawing1\.xml/);
|
||||
assert.match(workbook, /xl\/media\/image/);
|
||||
assert.match(workbook, /oneCellAnchor/);
|
||||
@@ -327,6 +328,7 @@ test("filters and exports the current KOC resource result set", async () => {
|
||||
assert.match(exportRoute, /历史合作来源/);
|
||||
assert.match(exportRoute, /合作社资源 · 不可直联/);
|
||||
assert.match(exportRoute, /isManagerRequest/);
|
||||
assert.match(exportRoute, /consumeMcpExportToken/);
|
||||
assert.match(workbook, /relationships\/hyperlink/);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user