tool-search-mcp.test.ts 912 B

123456789101112131415161718192021222324
  1. import { expect, it } from "vitest";
  2. import { normalizeMcpToolDescriptor } from "../src/mcp/descriptor.js";
  3. it("normalizes MCP search hints and respects server or tool alwaysLoad independently of trust", () => {
  4. const input = {
  5. name: "search",
  6. inputSchema: {},
  7. _meta: { "anthropic/searchHint": " find\n docs ", "anthropic/alwaysLoad": true },
  8. };
  9. expect(normalizeMcpToolDescriptor("test", input)).toMatchObject({
  10. alwaysLoad: true,
  11. searchHint: "find docs",
  12. });
  13. expect(normalizeMcpToolDescriptor("test", input).official).toBeUndefined();
  14. expect(
  15. normalizeMcpToolDescriptor("test", { ...input, _meta: {} }, undefined, false, true).alwaysLoad,
  16. ).toBe(true);
  17. expect(
  18. normalizeMcpToolDescriptor("test", {
  19. ...input,
  20. _meta: { "anthropic/alwaysLoad": "true", "anthropic/searchHint": 1 },
  21. }),
  22. ).toMatchObject({ alwaysLoad: false, searchHint: undefined });
  23. });