MCP: server/discover (2026-07-28), resultType и кэш-подсказки; таблица передаёт выделение в контекст Claude (ui/update-model-context) и кнопка «Спросить Claude про выбранные» (ui/message)
All checks were successful
ci / deploy (push) Successful in 2m42s
ci / test (push) Successful in 40s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 19:44:53 +03:00
parent 4b5e0444b9
commit 053b5018c0
3 changed files with 60 additions and 6 deletions

View File

@@ -269,12 +269,30 @@ d("MCP бухгалтерии (временная БД)", () => {
expect((await post({ authorization: "Basic abc" }, rpc("initialize"))).statusCode).toBe(401);
});
it("server/discover (2026-07-28): версии, capabilities с расширением UI, serverInfo в _meta, instructions, кэш-подсказки; resultType у всех результатов", async () => {
const d = (await post(bearer(TOKEN_A), rpc("server/discover", { _meta: { "io.modelcontextprotocol/protocolVersion": "2026-07-28" } }))).json().result;
expect(d.resultType).toBe("complete");
expect(d.supportedVersions).toContain("2026-07-28");
expect(d.capabilities.extensions["io.modelcontextprotocol/ui"].mimeTypes).toContain("text/html;profile=mcp-app");
expect(d.capabilities.tools.listChanged).toBe(true);
expect(d._meta["io.modelcontextprotocol/serverInfo"].name).toBe("accounting_automation");
expect(d.instructions).toContain("acc_review_list");
expect(d.ttlMs).toBeGreaterThan(0);
expect(["public", "private"]).toContain(d.cacheScope);
const l = (await post(bearer(TOKEN_A), rpc("tools/list"))).json().result;
expect(l).toMatchObject({ resultType: "complete", ttlMs: 60000, cacheScope: "public" });
const c = (await post(bearer(TOKEN_A), rpc("tools/call", { name: "acc_review_list", arguments: {} }))).json().result;
expect(c.resultType).toBe("complete");
expect(c.ttlMs).toBeUndefined();
expect((await post({}, rpc("server/discover"))).statusCode).toBe(401);
});
it("initialize, notifications/initialized, ping, tools/list", async () => {
const i = await post(bearer(TOKEN_A), rpc("initialize", { protocolVersion: "2025-03-26" }));
expect(i.statusCode).toBe(200);
expect(i.json().result.serverInfo.name).toBe("accounting_automation");
expect((await post(bearer(TOKEN_A), { jsonrpc: "2.0", method: "notifications/initialized" })).statusCode).toBe(202);
expect(((await post(bearer(TOKEN_A), rpc("ping"))).json()).result).toEqual({});
expect(((await post(bearer(TOKEN_A), rpc("ping"))).json()).result).toEqual({ resultType: "complete" });
const l = (await post(bearer(TOKEN_A), rpc("tools/list"))).json();
expect(l.result.tools.map((t: { name: string }) => t.name)).toEqual([
"acc_review_list", "acc_review_get", "acc_review_update", "acc_review_done", "acc_review_handoff", "acc_review_return", "acc_review_batch", "acc_review_snooze",