knowledge-base-retrieve
Retrieve relevant documents from an uploaded knowledge base to answer company-specific questions. Searches policies, procedures, product specs, and historical data.
Instructions
Look up information in the Knowledge Base. Use this tool when you need to:
Find relevant documents or information on specific topics
Retrieve company policies, procedures, or guidelines
Access product specifications or technical documentation
Get contextual information to answer company-specific questions
Find historical data or information about projects
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query to search for data in the Knowledge Base | |
| topK | No | The maximum number of results to return. Defaults to 10. | |
| rerank | No | Whether to rerank the results based on relevance. Defaults to true. |
Implementation Reference
- src/index.ts:50-89 (handler)The 'knowledge-base-retrieve' tool is defined and registered via server.tool(). The handler takes query, topK, rerank parameters, calls ns.search() on the Agentset namespace, and maps results to text content.
server.tool( "knowledge-base-retrieve", description, { query: z .string() .describe("The query to search for data in the Knowledge Base"), topK: z .number() .describe("The maximum number of results to return. Defaults to 10.") .min(1) .max(100) .optional() .default(10), rerank: z .boolean() .describe( "Whether to rerank the results based on relevance. Defaults to true.", ) .optional() .default(true), }, async ({ query, topK, rerank }) => { const result = await ns.search( query, { topK, rerank, }, tenantId ? { tenantId } : undefined, ); const content = result.map((item) => ({ type: "text" as const, text: item.text, })); return { content }; }, ); - src/index.ts:50-89 (registration)The tool is registered using server.tool() with the name 'knowledge-base-retrieve' on line 50.
server.tool( "knowledge-base-retrieve", description, { query: z .string() .describe("The query to search for data in the Knowledge Base"), topK: z .number() .describe("The maximum number of results to return. Defaults to 10.") .min(1) .max(100) .optional() .default(10), rerank: z .boolean() .describe( "Whether to rerank the results based on relevance. Defaults to true.", ) .optional() .default(true), }, async ({ query, topK, rerank }) => { const result = await ns.search( query, { topK, rerank, }, tenantId ? { tenantId } : undefined, ); const content = result.map((item) => ({ type: "text" as const, text: item.text, })); return { content }; }, ); - src/index.ts:53-71 (schema)Zod schema for the tool's inputs: query (string, required), topK (number, 1-100, optional default 10), rerank (boolean, optional default true).
{ query: z .string() .describe("The query to search for data in the Knowledge Base"), topK: z .number() .describe("The maximum number of results to return. Defaults to 10.") .min(1) .max(100) .optional() .default(10), rerank: z .boolean() .describe( "Whether to rerank the results based on relevance. Defaults to true.", ) .optional() .default(true), },