From 595e69d57f8fd44b903573ec3f2e4ad13124755b Mon Sep 17 00:00:00 2001 From: Yuri Yaryshev Date: Sun, 6 Dec 2026 17:01:07 +0300 Subject: [PATCH] =?UTF-8?q?MCP:=20=D1=83=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=BD=D0=BD=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20KH=20Build=20=D1=81=D0=B2=D0=BE=D1=8F=20=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D0=BA=D0=B0=20=D0=B8=20=D0=BD=D0=B0=D0=B7?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20(serverInfo.icons/title)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- packages/accounting_automation/src/mcp.ts | 5 ++++- packages/khbuild_assistant_prep/src/mcp-agents.ts | 6 +++++- packages/todo_service/src/mcp.ts | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/accounting_automation/src/mcp.ts b/packages/accounting_automation/src/mcp.ts index 9a212e0..10fcd50 100644 --- a/packages/accounting_automation/src/mcp.ts +++ b/packages/accounting_automation/src/mcp.ts @@ -703,7 +703,10 @@ const rpcError = (id: unknown, code: number, message: string): Json => ({ jsonrp /** Обрабатывает одно JSON-RPC сообщение от аутентифицированного человека; null - уведомление (ответа нет). */ const SUPPORTED_VERSIONS = ["2026-07-28", "2025-11-25", "2025-06-18", "2025-03-26"]; -const SERVER_INFO = { name: "accounting_automation", version: "0.1.0" }; +/** Иконка коннектора (MCP serverInfo.icons): у каждого MCP KH Build свой цвет и знак, чтобы не путать их в списке коннекторов. */ +const MCP_ICON = "data:image/svg+xml," + encodeURIComponent('$'); +const MCP_ICONS = [{ src: MCP_ICON, mimeType: "image/svg+xml", sizes: ["any"] }]; +const SERVER_INFO = { name: "accounting_automation", title: "KH Build: бухгалтерия", version: "0.1.0", icons: MCP_ICONS }; const CAPABILITIES = { tools: { listChanged: true }, resources: {}, prompts: {}, extensions: { "io.modelcontextprotocol/ui": { mimeTypes: [REVIEW_UI_MIME] } } }; /** Подсказки кэширования (2026-07-28) для списков, discover и ресурсов; во всех результатах resultType: "complete". */ diff --git a/packages/khbuild_assistant_prep/src/mcp-agents.ts b/packages/khbuild_assistant_prep/src/mcp-agents.ts index 6e942f1..4f6c63c 100644 --- a/packages/khbuild_assistant_prep/src/mcp-agents.ts +++ b/packages/khbuild_assistant_prep/src/mcp-agents.ts @@ -1,6 +1,10 @@ import { createPublicKey, createVerify, timingSafeEqual, type JsonWebKey } from "node:crypto"; import type { FastifyInstance } from "fastify"; import type { Pool } from "khb_common"; + +/** Иконка коннектора (MCP serverInfo.icons): у каждого MCP KH Build свой цвет и знак, чтобы не путать их в списке коннекторов. */ +const MCP_ICON = "data:image/svg+xml," + encodeURIComponent('AI'); +const MCP_ICONS = [{ src: MCP_ICON, mimeType: "image/svg+xml", sizes: ["any"] }]; import { chunkOf, fullTextStore, type FullTextStore } from "./fulltext.js"; /** @@ -191,7 +195,7 @@ export async function handleMcpRequest(req: RpcReq, tools: McpTool[], serverName return ok({ protocolVersion: typeof req.params?.protocolVersion === "string" ? req.params.protocolVersion : "2025-03-26", capabilities: { tools: {} }, - serverInfo: { name: serverName, version: "1.0.0" }, + serverInfo: { name: serverName, title: "KH Build: агенты (mcp_for_agents)", version: "1.0.0", icons: MCP_ICONS }, instructions: "Чтение данных сервиса агентов без ограничений по размеру: read_full_text (полный текст по ref из пометки ОБРЕЗАНО), read_slack_message, agent_issues.", }); case "ping": diff --git a/packages/todo_service/src/mcp.ts b/packages/todo_service/src/mcp.ts index d7369d1..fc023f5 100644 --- a/packages/todo_service/src/mcp.ts +++ b/packages/todo_service/src/mcp.ts @@ -1,4 +1,8 @@ import { HttpError, type TodoCore } from "./core.js"; + +/** Иконка коннектора (MCP serverInfo.icons): у каждого MCP KH Build свой цвет и знак, чтобы не путать их в списке коннекторов. */ +const MCP_ICON = "data:image/svg+xml," + encodeURIComponent(''); +const MCP_ICONS = [{ src: MCP_ICON, mimeType: "image/svg+xml", sizes: ["any"] }]; import type { Caller } from "./access.js"; /** MCP (Streamable HTTP, без сессий): тонкий адаптер над тем же ядром, что и REST. Реализация JSON-RPC 2.0 вручную. */ @@ -89,7 +93,7 @@ export async function handleMcpMessage(core: TodoCore, caller: Caller, msg: Json switch (method) { case "initialize": { const asked = (msg.params as Json | undefined)?.protocolVersion; - return { jsonrpc: "2.0", id, result: { protocolVersion: typeof asked === "string" ? asked : "2025-03-26", capabilities: { tools: {} }, serverInfo: { name: "khb-todo", version: "0.1.0" } } }; + return { jsonrpc: "2.0", id, result: { protocolVersion: typeof asked === "string" ? asked : "2025-03-26", capabilities: { tools: {} }, serverInfo: { name: "khb-todo", title: "KH Build: задачи (To-do)", version: "0.1.0", icons: MCP_ICONS } } }; } case "ping": return { jsonrpc: "2.0", id, result: {} };