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; }; }

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