Skip to main content
Glama
dannwaneri

MCP Knowledge Base Server

by dannwaneri

get_by_category

Retrieve knowledge base entries filtered by specific categories like 'ai', 'technology', or 'product' to access organized information efficiently.

Instructions

Get all knowledge base entries for a specific category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory to filter by (e.g., 'ai', 'technology', 'product')

Implementation Reference

  • Executes the get_by_category tool: extracts category from args, validates it, filters the knowledgeBase array case-insensitively, handles no-results case with available categories list, formats and returns JSON response with entries (id, content, metadata), caches successful results.
    if (name === "get_by_category") { const category = args?.category as string; if (!category) { throw new Error("Category parameter is required"); } const results = knowledgeBase.filter( (item) => item.category.toLowerCase() === category.toLowerCase() ); if (results.length === 0) { const responseText = JSON.stringify({ category, message: "No entries found for this category", availableCategories: [ ...new Set(knowledgeBase.map((item) => item.category)), ], }); // Don't cache errors return { content: [ { type: "text", text: responseText, }, ], }; } const responseText = JSON.stringify( { category, count: results.length, entries: results.map((r) => ({ id: r.id, content: r.content, metadata: r.metadata, })), }, null, 2 ); // Cache the response setCache(cacheKey, responseText); return { content: [ { type: "text", text: responseText, }, ], }; }
  • src/index.ts:166-179 (registration)
    Registers the get_by_category tool in the tools list provided to MCP clients, including name, description, and input schema requiring a 'category' string.
    { name: "get_by_category", description: "Get all knowledge base entries for a specific category", inputSchema: { type: "object", properties: { category: { type: "string", description: "Category to filter by (e.g., 'ai', 'technology', 'product')", }, }, required: ["category"], }, },
  • Input schema for get_by_category tool: object with required 'category' string property.
    inputSchema: { type: "object", properties: { category: { type: "string", description: "Category to filter by (e.g., 'ai', 'technology', 'product')", }, }, required: ["category"], },

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