Skip to main content
Glama
dannwaneri

MCP Knowledge Base Server

by dannwaneri

get_by_id

Retrieve a specific knowledge base entry using its unique ID to access precise information quickly.

Instructions

Get a specific knowledge base entry by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the entry to retrieve

Implementation Reference

  • src/index.ts:182-195 (registration)
    Registers the 'get_by_id' tool in the ListTools response, defining its name, description, and input schema (object with required 'id' string).
    {
      name: "get_by_id",
      description: "Get a specific knowledge base entry by its ID",
      inputSchema: {
        type: "object",
        properties: {
          id: {
            type: "string",
            description: "The ID of the entry to retrieve",
          },
        },
        required: ["id"],
      },
    },
  • Executes the 'get_by_id' tool: retrieves entry by ID from knowledgeBase, returns formatted JSON with content/category/metadata or error if not found, includes caching.
    if (name === "get_by_id") {
      const id = args?.id as string;
    
      if (!id) {
        throw new Error("ID parameter is required");
      }
    
      const entry = knowledgeBase.find((item) => item.id === id);
    
      if (!entry) {
        const responseText = JSON.stringify({
          id,
          error: "Entry not found",
          availableIds: knowledgeBase.map((item) => item.id),
        });
    
        // Don't cache errors
        return {
          content: [
            {
              type: "text",
              text: responseText,
            },
          ],
          isError: true,
        };
      }
    
      const responseText = JSON.stringify(
        {
          id: entry.id,
          content: entry.content,
          category: entry.category,
          metadata: entry.metadata,
        },
        null,
        2
      );
    
      // Cache the response
      setCache(cacheKey, responseText);
    
      return {
        content: [
          {
            type: "text",
            text: responseText,
          },
        ],
      };
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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