Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe query to search for data in the Knowledge Base
topKNoThe maximum number of results to return. Defaults to 10.
rerankNoWhether to rerank the results based on relevance. Defaults to true.

Implementation Reference

  • 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 };
      },
    );
  • 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),
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description fully carries the burden of disclosing behavior. It only describes basic functionality without addressing side effects (none expected but not stated), read-only nature, error handling, or performance characteristics. For a retrieval tool, the description should at least imply idempotency or lack of mutations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and efficiently uses a bulleted list for clarity. The opening sentence is slightly generic, but overall it is well-structured and not verbose. Every line adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers common use cases but lacks information about the return format (no output schema) and potential errors. For a simple retrieval tool, it is partially complete, but missing output schema details and edge case handling reduces completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds no additional detail beyond the schema's parameter descriptions. It does not explain the implications of rerank or topK further, nor does it provide usage examples for parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Look up information in the Knowledge Base.' It provides a specific verb ('retrieve') and resource ('Knowledge Base'), and lists concrete use cases like finding documents, policies, and product specs. Since there are no sibling tools, no differentiation is needed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly instructs when to use the tool via a bulleted list of scenarios (e.g., 'Find relevant documents,' 'Access product specifications'). It provides clear context but does not mention when not to use it or alternatives, which is less critical given no sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/agentset-ai/mcp-server'

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