retrieve
Find relevant documents, policies, and product specs in your knowledge base using search and metadata filters. Control result count and recency for accurate answers.
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 | |
| filter | No | The metadata search filter on documents. Returns chunks only from documents which match the filter. The following filter operators are supported: $eq - Equal to (number, string, boolean), $ne - Not equal to (number, string, boolean), $gt - Greater than (number), $gte - Greater than or equal to (number), $lt - Less than (number), $lte - Less than or equal to (number), $in - In array (string or number), $nin - Not in array (string or number). The operators can be combined with AND and OR. Read Metadata & Filters guide for more details and examples. | |
| topK | No | The maximum number of results to return. Defaults to 8. | |
| rerank | No | Whether to try and find only the most relevant data. Defaults to false. | |
| recencyBias | No | Whether to favor data towards more recent documents. Defaults to false. |
Implementation Reference
- src/index.ts:55-109 (registration)Registration of the 'retrieve' tool via server.tool() with its schema and handler.
server.tool( "retrieve", description, { query: z .string() .describe("The query to search for data in the Knowledge Base"), filter: z .object({ field: z.string().describe("The field to filter by"), value: z.any().describe("The value to filter by"), }) .describe( "The metadata search filter on documents. Returns chunks only from documents which match the filter. The following filter operators are supported: $eq - Equal to (number, string, boolean), $ne - Not equal to (number, string, boolean), $gt - Greater than (number), $gte - Greater than or equal to (number), $lt - Less than (number), $lte - Less than or equal to (number), $in - In array (string or number), $nin - Not in array (string or number). The operators can be combined with AND and OR. Read Metadata & Filters guide for more details and examples." ) .optional(), topK: z .number() .describe("The maximum number of results to return. Defaults to 8.") .optional() .default(8), rerank: z .boolean() .describe( "Whether to try and find only the most relevant data. Defaults to false." ) .optional() .default(false), recencyBias: z .boolean() .describe( "Whether to favor data towards more recent documents. Defaults to false." ) .optional() .default(false), }, async ({ query, filter, topK, rerank, recencyBias }) => { const ragie = new Ragie({ auth: RAGIE_API_KEY }); const retrieval = await ragie.retrievals.retrieve({ query, filter, topK, rerank, recencyBias, partition: options.partition, }); const content = retrieval.scoredChunks.map((sc) => ({ type: "text" as const, text: sc.text, })); return { content }; } ); - src/index.ts:58-90 (schema)Zod schema defining the input parameters for the 'retrieve' tool: query (string), filter (optional object with field/value), topK (number, default 8), rerank (boolean, default false), recencyBias (boolean, default false).
{ query: z .string() .describe("The query to search for data in the Knowledge Base"), filter: z .object({ field: z.string().describe("The field to filter by"), value: z.any().describe("The value to filter by"), }) .describe( "The metadata search filter on documents. Returns chunks only from documents which match the filter. The following filter operators are supported: $eq - Equal to (number, string, boolean), $ne - Not equal to (number, string, boolean), $gt - Greater than (number), $gte - Greater than or equal to (number), $lt - Less than (number), $lte - Less than or equal to (number), $in - In array (string or number), $nin - Not in array (string or number). The operators can be combined with AND and OR. Read Metadata & Filters guide for more details and examples." ) .optional(), topK: z .number() .describe("The maximum number of results to return. Defaults to 8.") .optional() .default(8), rerank: z .boolean() .describe( "Whether to try and find only the most relevant data. Defaults to false." ) .optional() .default(false), recencyBias: z .boolean() .describe( "Whether to favor data towards more recent documents. Defaults to false." ) .optional() .default(false), }, - src/index.ts:91-108 (handler)The handler function for the 'retrieve' tool. Creates a Ragie client, calls ragie.retrievals.retrieve() with the input parameters, maps scoredChunks to text content, and returns the content.
async ({ query, filter, topK, rerank, recencyBias }) => { const ragie = new Ragie({ auth: RAGIE_API_KEY }); const retrieval = await ragie.retrievals.retrieve({ query, filter, topK, rerank, recencyBias, partition: options.partition, }); const content = retrieval.scoredChunks.map((sc) => ({ type: "text" as const, text: sc.text, })); return { content }; }