Skip to main content
Glama
by LassiterJ
search.test.tsโ€ข2.15 kB
import assert from "node:assert"; import { describe, it } from "node:test"; import { withTestClient, assertToolResponse, assertToolError } from "./helpers/test-client.ts"; describe("Search Tool Integration Tests", () => { it("should list search tool", async () => { await withTestClient(async (client) => { const response = await client.listTools(); const toolNames = response.tools.map(t => t.name); assert(toolNames.includes("search"), "Search tool should be listed"); const tool = response.tools.find(t => t.name === "search"); assert.strictEqual(tool?.description, "Search stub documents and return minimal results (id, title, url)"); }); }); it("should process valid input", async () => { await withTestClient(async (client) => { const response = await client.callTool("search", { query: "cats" }); // Validate JSON-encoded { results: [...] } assertToolResponse(response, (text) => { const parsed = JSON.parse(String(text)) as { results: Array<{ id: string; title: string; url: string }> }; assert(Array.isArray(parsed.results), "results should be an array"); const first = parsed.results[0]; if (first !== undefined) { assert.strictEqual(typeof first.id, "string"); assert.strictEqual(typeof first.title, "string"); assert.strictEqual(typeof first.url, "string"); } return true; }); }); }); it("should handle special characters", async () => { await withTestClient(async (client) => { const response = await client.callTool("search", { query: "Special chars: @#$%^&*() ๐Ÿš€" }); assertToolResponse(response, (text) => { const parsed = JSON.parse(String(text)) as { results: unknown }; return Array.isArray((parsed as { results: unknown[] }).results); }); }); }); it("should reject missing input parameter", async () => { await withTestClient(async (client) => { await assertToolError( client.callTool("search", {}), undefined, "Should reject missing query parameter" ); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LassiterJ/mcp-playground'

If you have feedback or need assistance with the MCP directory API, please join our Discord server