MCP: у каждого коннектора KH Build своя иконка и название (serverInfo.icons/title)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -703,7 +703,10 @@ const rpcError = (id: unknown, code: number, message: string): Json => ({ jsonrp
|
|||||||
|
|
||||||
/** Обрабатывает одно JSON-RPC сообщение от аутентифицированного человека; null - уведомление (ответа нет). */
|
/** Обрабатывает одно JSON-RPC сообщение от аутентифицированного человека; null - уведомление (ответа нет). */
|
||||||
const SUPPORTED_VERSIONS = ["2026-07-28", "2025-11-25", "2025-06-18", "2025-03-26"];
|
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('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#16833a"/><text x="32" y="46" font-size="40" font-weight="700" text-anchor="middle" fill="#fff" font-family="Arial">$</text></svg>');
|
||||||
|
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] } } };
|
const CAPABILITIES = { tools: { listChanged: true }, resources: {}, prompts: {}, extensions: { "io.modelcontextprotocol/ui": { mimeTypes: [REVIEW_UI_MIME] } } };
|
||||||
|
|
||||||
/** Подсказки кэширования (2026-07-28) для списков, discover и ресурсов; во всех результатах resultType: "complete". */
|
/** Подсказки кэширования (2026-07-28) для списков, discover и ресурсов; во всех результатах resultType: "complete". */
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { createPublicKey, createVerify, timingSafeEqual, type JsonWebKey } from "node:crypto";
|
import { createPublicKey, createVerify, timingSafeEqual, type JsonWebKey } from "node:crypto";
|
||||||
import type { FastifyInstance } from "fastify";
|
import type { FastifyInstance } from "fastify";
|
||||||
import type { Pool } from "khb_common";
|
import type { Pool } from "khb_common";
|
||||||
|
|
||||||
|
/** Иконка коннектора (MCP serverInfo.icons): у каждого MCP KH Build свой цвет и знак, чтобы не путать их в списке коннекторов. */
|
||||||
|
const MCP_ICON = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#7a3fd1"/><text x="32" y="43" font-size="30" font-weight="700" text-anchor="middle" fill="#fff" font-family="Arial">AI</text></svg>');
|
||||||
|
const MCP_ICONS = [{ src: MCP_ICON, mimeType: "image/svg+xml", sizes: ["any"] }];
|
||||||
import { chunkOf, fullTextStore, type FullTextStore } from "./fulltext.js";
|
import { chunkOf, fullTextStore, type FullTextStore } from "./fulltext.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +195,7 @@ export async function handleMcpRequest(req: RpcReq, tools: McpTool[], serverName
|
|||||||
return ok({
|
return ok({
|
||||||
protocolVersion: typeof req.params?.protocolVersion === "string" ? req.params.protocolVersion : "2025-03-26",
|
protocolVersion: typeof req.params?.protocolVersion === "string" ? req.params.protocolVersion : "2025-03-26",
|
||||||
capabilities: { tools: {} },
|
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.",
|
instructions: "Чтение данных сервиса агентов без ограничений по размеру: read_full_text (полный текст по ref из пометки ОБРЕЗАНО), read_slack_message, agent_issues.",
|
||||||
});
|
});
|
||||||
case "ping":
|
case "ping":
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { HttpError, type TodoCore } from "./core.js";
|
import { HttpError, type TodoCore } from "./core.js";
|
||||||
|
|
||||||
|
/** Иконка коннектора (MCP serverInfo.icons): у каждого MCP KH Build свой цвет и знак, чтобы не путать их в списке коннекторов. */
|
||||||
|
const MCP_ICON = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#1d5fd1"/><path d="M18 33l9 9 19-21" fill="none" stroke="#fff" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/></svg>');
|
||||||
|
const MCP_ICONS = [{ src: MCP_ICON, mimeType: "image/svg+xml", sizes: ["any"] }];
|
||||||
import type { Caller } from "./access.js";
|
import type { Caller } from "./access.js";
|
||||||
|
|
||||||
/** MCP (Streamable HTTP, без сессий): тонкий адаптер над тем же ядром, что и REST. Реализация JSON-RPC 2.0 вручную. */
|
/** MCP (Streamable HTTP, без сессий): тонкий адаптер над тем же ядром, что и REST. Реализация JSON-RPC 2.0 вручную. */
|
||||||
@@ -89,7 +93,7 @@ export async function handleMcpMessage(core: TodoCore, caller: Caller, msg: Json
|
|||||||
switch (method) {
|
switch (method) {
|
||||||
case "initialize": {
|
case "initialize": {
|
||||||
const asked = (msg.params as Json | undefined)?.protocolVersion;
|
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":
|
case "ping":
|
||||||
return { jsonrpc: "2.0", id, result: {} };
|
return { jsonrpc: "2.0", id, result: {} };
|
||||||
|
|||||||
Reference in New Issue
Block a user