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
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | Topic name (e.g. typescript, docker, recipes) | |
| title | Yes | Entry title / question | |
| content | Yes | Entry content / answer / explanation |
Implementation Reference
- src/core/knowledge.ts:89-117 (handler)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 }; } - src/tools/knowledge.ts:31-45 (registration)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) ) );