Skip to main content
Glama
dannwaneri

MCP Knowledge Base Server

by dannwaneri

advanced_search

Search a knowledge base with filters for category and result limits to find specific information quickly.

Instructions

Search with additional filters like category and result limit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
categoryNoOptional: filter by category
limitNoMaximum results to return

Implementation Reference

  • src/index.ts:198-220 (registration)
    Registration of the 'advanced_search' tool including its name, description, and input schema.
    {
      name: "advanced_search",
      description: "Search with additional filters like category and result limit",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query",
          },
          category: {
            type: "string",
            description: "Optional: filter by category",
          },
          limit: {
            type: "number",
            description: "Maximum results to return",
            default: 5,
          },
        },
        required: ["query"],
      },
    },
  • Handler function for executing the 'advanced_search' tool. It searches the knowledge base, applies optional category filter and limit, formats results as JSON, caches the response, and returns it.
    if (name === "advanced_search") {
      const query = args?.query as string;
      const category = args?.category as string | undefined;
      const limit = (args?.limit as number) || 5;
    
      if (!query) {
        throw new Error("Query parameter is required");
      }
    
      let results = searchKnowledge(query, knowledgeBase.length);
    
      // Apply category filter if provided
      if (category) {
        results = results.filter(
          (item) => item.category.toLowerCase() === category.toLowerCase()
        );
      }
    
      // Apply limit
      results = results.slice(0, limit);
    
      const responseText = JSON.stringify(
        {
          query,
          filters: {
            category: category || "none",
            limit,
          },
          resultsCount: results.length,
          results: results.map((r) => ({
            id: r.id,
            content: r.content,
            category: r.category,
            metadata: r.metadata,
          })),
        },
        null,
        2
      );
    
      // Cache the response
      setCache(cacheKey, responseText);
    
      return {
        content: [
          {
            type: "text",
            text: responseText,
          },
        ],
      };
    }
  • Helper function used by advanced_search to perform initial keyword search on the knowledge base.
    function searchKnowledge(query: string, limit: number = 5): KnowledgeEntry[] {
        const lowerQuery = query.toLowerCase();
        return knowledgeBase
          .filter((item) =>
            item.content.toLowerCase().includes(lowerQuery) ||
            item.category.toLowerCase().includes(lowerQuery)
          )
          .slice(0, limit);
      }
  • Type definition for knowledge base entries used in advanced_search results.
    interface KnowledgeEntry {
        id: string;
        content: string;
        category: string;
        metadata: {
          source: string;
          date: string;
        };
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'search' and 'additional filters', implying a read-only operation, but fails to describe critical behaviors such as authentication needs, rate limits, error handling, or the format of returned results. This leaves significant gaps for a tool with 3 parameters.

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 that front-loads the core purpose. It avoids unnecessary words and gets straight to the point, though it could be slightly more structured by explicitly naming the tool's differentiation.

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 tool's complexity (3 parameters, no annotations, no output schema), the description is incomplete. It lacks details on behavioral traits, output format, and usage guidelines relative to siblings. For a search tool with filtering capabilities, this leaves the agent with insufficient context to use it effectively.

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 already documents all parameters (query, category, limit) with descriptions. The description adds minimal value by mentioning 'category and result limit' as examples of filters, but doesn't provide additional syntax, format details, or usage context beyond what the schema provides.

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

Purpose4/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 as 'Search with additional filters like category and result limit', which specifies the verb (search) and key resources (filters: category, limit). It distinguishes from basic search by mentioning 'additional filters', but doesn't explicitly differentiate from sibling tools like 'search_knowledge' or 'get_by_category'.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'additional filters' but doesn't specify scenarios where this is preferred over sibling tools like 'search_knowledge' or 'get_by_category', nor does it mention any prerequisites or exclusions.

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/dannwaneri/mcp-knowledge-base-server'

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