MCP: поток GET /mcp (SSE) с notifications/tools/list_changed при подключении, capabilities.tools.listChanged
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -367,6 +367,25 @@ d("MCP бухгалтерии (временная БД)", () => {
|
||||
expect(rows[0].hi - rows[0].lo).toBe(9);
|
||||
});
|
||||
|
||||
it("GET /mcp: поток SSE шлёт tools/list_changed при подключении; без токена 401, без SSE-Accept 405", async () => {
|
||||
const app = Fastify();
|
||||
registerMcp(app, { pool: db.pool, settings, now: () => NOW, verifyJwt });
|
||||
expect((await app.inject({ method: "GET", url: "/mcp" })).statusCode).toBe(405);
|
||||
expect((await app.inject({ method: "GET", url: "/mcp", headers: { accept: "text/event-stream" } })).statusCode).toBe(401);
|
||||
await app.listen({ port: 0, host: "127.0.0.1" });
|
||||
const port = (app.server.address() as { port: number }).port;
|
||||
const ac = new AbortController();
|
||||
const r = await fetch(`http://127.0.0.1:${port}/mcp`, { headers: { accept: "text/event-stream", ...bearer(TOKEN_A) }, signal: ac.signal });
|
||||
expect(r.status).toBe(200);
|
||||
expect(r.headers.get("content-type")).toContain("text/event-stream");
|
||||
const chunk = new TextDecoder().decode((await r.body!.getReader().read()).value);
|
||||
expect(chunk).toContain("notifications/tools/list_changed");
|
||||
ac.abort();
|
||||
await app.close();
|
||||
expect((await post({}, rpc("initialize"))).statusCode).toBe(401);
|
||||
expect((await post(bearer(TOKEN_A), rpc("initialize"))).json().result.capabilities.tools.listChanged).toBe(true);
|
||||
});
|
||||
|
||||
it("JWT Keycloak: person по основной и дополнительной почте; чужой email - 403; плохие токены - 401", async () => {
|
||||
await addInvoice();
|
||||
const call = { name: "acc_review_list", arguments: {} };
|
||||
|
||||
Reference in New Issue
Block a user