refactor(mcp): u6u_* tool 全面 rename 為 arcrun_* + 前綴收斂單一來源

零 u6u 洩漏(leo 要求 1):connector tool 清單只剩 arcrun_*,並移除壞掉/
重複的 u6u_ workflow tool(deploy/execute/get/list_workflows 由 arcrun_
push/run/get/list_workflows 取代);MCP server name 也由 u6u-mcp-server
改 arcrun-mcp-server。

前綴單一真相源(leo 要求 2):新增 mcp/src/brand.ts(TOOL_PREFIX + toolName()
helper),所有 server.tool() 註冊一律走 toolName("suffix"),前綴不再明碼散寫。
未來 rebrand 只改 brand.ts 一行。

- 12 個獨有能力 tool rename(component/tag/gui/search_workflows)
- 4 個重複/壞掉 tool 移除
- inter-tool hint、描述字串、註解內 u6u_ 名字全數更新
- tsc exit 0;vitest 19/19 綠

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015d5jDbuqT5Htwv3Q88XXKk
This commit is contained in:
Claude
2026-07-07 05:21:34 +00:00
parent befc63cfe0
commit 5fc7277c3c
26 changed files with 111 additions and 308 deletions
+87
View File
@@ -0,0 +1,87 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { toolName } from "../brand.js";
import { z } from "zod";
import { Env } from "../types.js";
/**
* arcrun_search_workflows — 用自然語言找現成工作流(workflow-discovery R2
*
* 北極星入口:AI 先查「有沒有現成工作流能做這件事」→ 找到就執行,別重造。
* 呼叫 cypher GET /workflows/search → 轉發 KBDB /entries/searchentry_type=workflow + 本租戶)。
* 優先語意搜尋;KBDB 未開 Vectorize → 自動降級關鍵字 + 回 capability_hint(不假裝語義)。
*
* 薄殼(rule 07):只做參數轉換 + 呼叫 + 格式化,零業務邏輯。形態對齊 arcrun_search_components。
* flag 安全:AI 收到意圖時主動 call 一次,無輪詢/排程。
*/
export function registerSearchWorkflows(
server: McpServer,
env: Env,
orgNamespace: string,
partnerToken: string,
) {
server.tool(
toolName("search_workflows"),
"用自然語言找現成的工作流(先查有沒有現成的能做這件事,找到就用,別重造)。例如:「把資料寫進 Google Sheets」、「每天抓 RSS 發通知」、「webhook 轉發到別的 API」。回傳本帳號下符合的工作流清單。",
{
query: z.string().describe("自然語言描述要找的工作流,如「把資料寫進 Google Sheets」"),
},
async ({ query }) => {
try {
if (!env.CYPHER_EXECUTOR) {
return {
content: [{ type: "text", text: "Error: CYPHER_EXECUTOR service binding is not configured." }],
isError: true,
};
}
const response = await env.CYPHER_EXECUTOR.fetch(
`http://cypher-executor/workflows/search?q=${encodeURIComponent(query)}`,
{ method: "GET", headers: { "X-Arcrun-API-Key": partnerToken } },
);
if (!response.ok) {
const errorText = await response.text();
return {
content: [{ type: "text", text: `Search failed: ${errorText}` }],
isError: true,
};
}
const result = await response.json() as {
entries?: Array<{ page_name?: string; content?: string }>;
count?: number;
mode?: string;
capability_hint?: string;
};
const entries = result.entries ?? [];
const count = result.count ?? entries.length;
if (count === 0) {
const hint = result.capability_hint ? `\n\n${result.capability_hint}` : "";
return {
content: [{
type: "text",
text: `找不到符合「${query}」的現成工作流。可以用 arcrun_push_workflow 部署一個新的。${hint}`,
}],
};
}
// capability_hint 透傳給 AI:未開語義時 AI 看到就能主動問用戶要不要開 Vectorize(R2.3 閉環)。
const hintLine = result.capability_hint
? `\n\n⚠️ ${result.capability_hint}`
: "";
return {
content: [{
type: "text",
text: `找到 ${count} 個工作流(mode: ${result.mode ?? "keyword"}):\n${JSON.stringify(entries, null, 2)}${hintLine}`,
}],
};
} catch (error) {
return {
content: [{ type: "text", text: `Internal Error: ${error instanceof Error ? error.message : String(error)}` }],
isError: true,
};
}
}
);
}