mcpStatusDiagnostics.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { describe, expect, it } from "vitest";
  2. import { zcodeMcpServerStatusSnapshotSchema } from "../src/zcode-protocol/index.js";
  3. describe("MCP status diagnostics protocol", () => {
  4. it("accepts structured failure diagnostics and keeps legacy snapshots compatible", () => {
  5. expect(
  6. zcodeMcpServerStatusSnapshotSchema.parse({
  7. error: "raw sdk error",
  8. failureKind: "server_unavailable",
  9. serverRequestId: "20260822000000abcdef1234567890abcd",
  10. status: "failed",
  11. toolCount: 0,
  12. transport: "http",
  13. updatedAt: "2026-08-22T00:00:00.000Z",
  14. }),
  15. ).toMatchObject({
  16. failureKind: "server_unavailable",
  17. serverRequestId: "20260822000000abcdef1234567890abcd",
  18. });
  19. expect(
  20. zcodeMcpServerStatusSnapshotSchema.parse({
  21. status: "connected",
  22. toolCount: 3,
  23. transport: "stdio",
  24. updatedAt: "2026-08-22T00:00:00.000Z",
  25. }),
  26. ).not.toHaveProperty("failureKind");
  27. });
  28. it("rejects empty request ids", () => {
  29. expect(
  30. zcodeMcpServerStatusSnapshotSchema.safeParse({
  31. serverRequestId: "",
  32. status: "failed",
  33. toolCount: 0,
  34. transport: "http",
  35. updatedAt: "2026-08-22T00:00:00.000Z",
  36. }).success,
  37. ).toBe(false);
  38. });
  39. });