Skip to main content
Glama
VinayakTiwari1103

MCP-Smallest.ai

getKnowledgeBase

Retrieve structured knowledge base entries using a unique ID to access and manage information efficiently within the MCP-Smallest.ai system.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • index.ts:85-110 (handler)
    Handler function that retrieves a specific knowledge base by ID from the Smallest.ai API via HTTP GET request, returning formatted JSON details or an error message.
    async (args) => {
      try {
        const response = await fetch(`${config.BASE_URL}/knowledgebase/${args.id}`, {
          method: 'GET',
          headers: {
            'Authorization': `Bearer ${config.API_KEY}`
          }
        });
    
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
    
        const data = await response.json();
        return {
          content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
        console.error('Error fetching knowledge base:', error);
        return {
          content: [{ type: "text", text: `Error: ${errorMessage}` }],
          isError: true
        };
      }
    }
  • Zod input schema defining the required 'id' parameter as a string for the getKnowledgeBase tool.
    {
      id: z.string()
    },
  • index.ts:80-111 (registration)
    MCP server registration of the 'getKnowledgeBase' tool, specifying input schema and handler function.
    server.tool(
      "getKnowledgeBase",
      {
        id: z.string()
      },
      async (args) => {
        try {
          const response = await fetch(`${config.BASE_URL}/knowledgebase/${args.id}`, {
            method: 'GET',
            headers: {
              'Authorization': `Bearer ${config.API_KEY}`
            }
          });
    
          if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
          }
    
          const data = await response.json();
          return {
            content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
          console.error('Error fetching knowledge base:', error);
          return {
            content: [{ type: "text", text: `Error: ${errorMessage}` }],
            isError: true
          };
        }
      }
    );
  • config.ts:1-4 (helper)
    Exported configuration constants used by the tool handler for API endpoint and authentication.
    export const config = {
        API_KEY: 'smallest-ai-api-key',
        BASE_URL: 'https://atoms-api.smallest.ai/api/v1'
    }; 
Install Server

Other Tools

Related 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/VinayakTiwari1103/MCP-smallest-ai'

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