import { describe, expect, it } from "bun:test";
import { getToolDefinitions } from "../src/mcp-tools.js";
describe("MCP Tools Module", () => {
it("should return array of tool definitions", () => {
const tools = getToolDefinitions();
expect(Array.isArray(tools)).toBe(true);
expect(tools.length).toBeGreaterThan(0);
});
it("should have required tool: add_item_text", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "add_item_text");
expect(tool).toBeDefined();
expect(tool.description).toBeTruthy();
expect(tool.inputSchema).toBeDefined();
});
it("should have required tool: add_item", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "add_item");
expect(tool).toBeDefined();
expect(tool.description).toBeTruthy();
expect(tool.inputSchema).toBeDefined();
});
it("should have required tool: search_text", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "search_text");
expect(tool).toBeDefined();
expect(tool.description).toBeTruthy();
expect(tool.inputSchema).toBeDefined();
});
it("should have required tool: search_vector", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "search_vector");
expect(tool).toBeDefined();
expect(tool.description).toBeTruthy();
expect(tool.inputSchema).toBeDefined();
});
it("should have required tool: llm_generate", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "llm_generate");
expect(tool).toBeDefined();
expect(tool.description).toBeTruthy();
expect(tool.inputSchema).toBeDefined();
});
it("add_item_text should have correct input schema", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "add_item_text");
const schema = tool.inputSchema;
expect(schema.type).toBe("object");
expect(schema.properties.content).toBeDefined();
expect(schema.properties.path).toBeDefined();
expect(schema.required).toContain("content");
});
it("search_vector should validate vector dimension", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "search_vector");
const schema = tool.inputSchema;
const vectorSchema = schema.properties.vector;
expect(vectorSchema.minItems).toBe(3);
expect(vectorSchema.maxItems).toBe(3);
expect(vectorSchema.items.type).toBe("number");
});
it("llm_generate should have prompt field", () => {
const tools = getToolDefinitions();
const tool = tools.find((t) => t.name === "llm_generate");
const schema = tool.inputSchema;
expect(schema.properties.prompt).toBeDefined();
expect(schema.required).toContain("prompt");
});
it("all tools should have name and description", () => {
const tools = getToolDefinitions();
tools.forEach((tool) => {
expect(tool.name).toBeTruthy();
expect(typeof tool.name).toBe("string");
expect(tool.description).toBeTruthy();
expect(typeof tool.description).toBe("string");
});
});
it("all tools should have valid inputSchema", () => {
const tools = getToolDefinitions();
tools.forEach((tool) => {
const schema = tool.inputSchema;
expect(schema).toBeDefined();
expect(schema.type).toBe("object");
expect(schema.properties).toBeDefined();
expect(typeof schema.properties).toBe("object");
});
});
});