knowledge-base-retrieve
Search the Knowledge Base to retrieve company policies, procedures, technical documentation, or project data. Use this tool to find relevant information and answer company-specific questions efficiently.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query to search for data in the Knowledge Base | |
| rerank | No | Whether to rerank the results based on relevance. Defaults to true. | |
| topK | No | The maximum number of results to return. Defaults to 10. |
Implementation Reference
- src/index.ts:72-88 (handler)The handler function for the 'knowledge-base-retrieve' tool. It takes a query and optional parameters topK and rerank, searches the namespace using ns.search, maps the results to a content array of text items, and returns it.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)Input schema using Zod for the tool parameters: query (required string), topK (optional number 1-100 default 10), rerank (optional boolean 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), },
- src/index.ts:50-89 (registration)Registration of the 'knowledge-base-retrieve' tool on the MCP server, including name, dynamic description, input schema, and handler function.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/utils.ts:20-27 (helper)Default description string for the 'knowledge-base-retrieve' tool, used if not overridden.const defaultDescription = ` 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 `.trim();