search-knowledge-base
Find relevant information by searching a knowledge base with specific queries and result counts.
Instructions
Search a knowledge base for relevant information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| knowledgeBaseId | Yes | Knowledge base ID | |
| query | Yes | Search query | |
| resultCount | No | Number of results |
Implementation Reference
- src/index.ts:903-921 (handler)Handler function that sends a POST request to the external API endpoint `/api/v1/query-knowledge-base` using the DUMPLING_API_KEY for authentication, and returns the response as formatted JSON text.async ({ knowledgeBaseId, query, resultCount }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch( `${NWS_API_BASE}/api/v1/query-knowledge-base`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ knowledgeBaseId, query, resultCount }), } ); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:898-902 (schema)Zod schema defining the input parameters: knowledgeBaseId (required string), query (required string), resultCount (optional number with default 5).{ knowledgeBaseId: z.string().describe("Knowledge base ID"), query: z.string().describe("Search query"), resultCount: z.number().optional().default(5).describe("Number of results"), },
- src/index.ts:895-922 (registration)Registration of the 'search-knowledge-base' tool using server.tool(), including name, description, input schema, and inline handler function.server.tool( "search-knowledge-base", "Search a knowledge base for relevant information.", { knowledgeBaseId: z.string().describe("Knowledge base ID"), query: z.string().describe("Search query"), resultCount: z.number().optional().default(5).describe("Number of results"), }, async ({ knowledgeBaseId, query, resultCount }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch( `${NWS_API_BASE}/api/v1/query-knowledge-base`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ knowledgeBaseId, query, resultCount }), } ); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );