Skip to main content
Glama
vuluu2k
by vuluu2k

addKnowledge

Store and organize information by adding entries to topics. Creates topics automatically when needed for facts, how-tos, decisions, or other valuable knowledge.

Instructions

Add a new knowledge entry to a topic. Creates the topic if it doesn't exist. Use this to store facts, how-tos, decisions, or anything worth remembering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesTopic name (e.g. typescript, docker, recipes)
titleYesEntry title / question
contentYesEntry content / answer / explanation

Implementation Reference

  • The core implementation of the addKnowledge logic within the KnowledgeBase class.
    async addKnowledge(
      topic: string,
      title: string,
      content: string
    ): Promise<{ success: true }> {
      const log = getLogger();
      const path = this.topicPath(topic);
    
      try {
        await this.atomicUpdate(
          path,
          (current) => appendEntry(current, title, content),
          `feat(ai): add knowledge to ${topic}`
        );
      } catch (err) {
        if (isNotFound(err)) {
          const displayName = topic.charAt(0).toUpperCase() + topic.slice(1);
          const initial = `# ${displayName}\n\n## ${title}\n\n${content}\n`;
          await this.client.createFile(
            path,
            initial,
            `feat(ai): create knowledge topic ${topic}`
          );
        } else throw err;
      }
    
      log.info("addKnowledge", { topic, title });
      return { success: true };
    }
  • Registration of the addKnowledge tool, which maps the tool request to the KnowledgeBase.addKnowledge method.
    server.registerTool(
      "addKnowledge",
      {
        description:
          "Add a new knowledge entry to a topic. Creates the topic if it doesn't exist. Use this to store facts, how-tos, decisions, or anything worth remembering.",
        inputSchema: {
          topic: z.string().describe("Topic name (e.g. typescript, docker, recipes)"),
          title: z.string().describe("Entry title / question"),
          content: z.string().describe("Entry content / answer / explanation"),
        },
      },
      toolHandler("addKnowledge", async ({ topic, title, content }) =>
        kb.addKnowledge(topic, title, content)
      )
    );

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/vuluu2k/knowledge_mcp'

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