Skip to main content
Glama

kb_search

Search a knowledge base using semantic queries to find relevant information based on meaning rather than exact keywords.

Instructions

Search knowledge base using semantic search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
limitNoMaximum results to return

Implementation Reference

  • Main handler for kb_search tool execution. Parses arguments, calls KnowledgeManager.search(), limits results, and formats response as MCP content.
    case 'kb_search': {
      const { query, limit = 10 } = args as any;
      const results = km.search(query).slice(0, limit);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(results, null, 2)
          }
        ]
      };
    }
  • Tool definition including name, description, and input schema (query: string required, limit: number optional).
    {
      name: 'kb_search',
      description: 'Search knowledge base using semantic search',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query'
          },
          limit: {
            type: 'number',
            default: 10,
            description: 'Maximum results to return'
          }
        },
        required: ['query']
      }
    },
  • Core search logic using Fuse.js fuzzy search engine on flattened knowledge base data, returning formatted SearchResult objects.
    search(query: string): SearchResult[] {
      if (!this.fuse) {
        this.initializeSearch();
      }
    
      const results = this.fuse!.search(query);
      
      return results.map(result => ({
        category: result.item.category,
        field: result.item.field,
        value: result.item.original || result.item.value,
        relevance: 1 - (result.score || 0),
        context: this.getContext(result.item.category, result.item.field)
      }));
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'semantic search' but doesn't explain what that entails (e.g., natural language processing, relevance scoring, or limitations). It lacks details on permissions, rate limits, error handling, or output format. The description is minimal and doesn't compensate for the absence of annotations.

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 a single, efficient sentence with no wasted words. It's front-loaded and directly states the tool's function. However, it could be more structured by including key details, but as-is, it's appropriately concise for its limited content.

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

Completeness2/5

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

Given the complexity (search tool with semantic aspects), lack of annotations, no output schema, and many sibling tools, the description is incomplete. It doesn't cover behavioral traits, usage context, or output expectations. For a tool with 2 parameters and no structured support, it should provide more guidance to be effective.

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 description coverage is 100%, so the schema fully documents the parameters (query and limit). The description adds no meaning beyond the schema—it doesn't clarify query syntax, semantic aspects, or result ordering. With high schema coverage, the baseline is 3, and the description doesn't enhance parameter understanding.

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

Purpose3/5

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

The description 'Search knowledge base using semantic search' states the verb (search) and resource (knowledge base) but is vague about scope and differentiation. It doesn't specify what type of content is searched (e.g., articles, documents, entries) or how it differs from sibling tools like kb_get_context or kb_get_all. The purpose is understandable but lacks specificity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. With many sibling tools (e.g., kb_get_context, kb_get_all, kb_get_personal), the description doesn't indicate if this is for general queries, specific contexts, or filtered searches. There's no mention of prerequisites, exclusions, or comparative use cases.

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/hlsitechio/mcp-instruct'

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