add_learning
Add learnings, patterns, or insights to a personal knowledge base for future reference and professional development.
Instructions
Add a learning, pattern, or insight to Chen's context. Use when Chen adopts a new approach, learns something from a project, or asks to remember something for future use.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The learning or insight to remember | |
| source | No | Optional: project or context where this was learned | |
| category | No | Optional: e.g. 'resume', 'coding', 'process' |
Implementation Reference
- src/index.ts:133-154 (handler)The MCP tool request handler for 'add_learning' which validates arguments and calls the underlying service function.
if (name === "add_learning") { const content = safeArgs.content as string; if (!content) { return { content: [{ type: "text", text: "Error: content is required" }], isError: true, }; } const learning = await addLearning({ content, source: safeArgs.source as string | undefined, category: safeArgs.category as string | undefined, }); return { content: [ { type: "text", text: `Added learning: ${JSON.stringify(learning, null, 2)}`, }, ], }; } - src/storage/context-store.ts:100-110 (handler)The core business logic function that adds a learning item to the storage.
export async function addLearning(learning: Omit<Learning, "id" | "date">): Promise<Learning> { const learnings = await loadJson<Learning[]>("learnings.json", []); const newLearning: Learning = { ...learning, id: `l-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, date: new Date().toISOString(), }; learnings.push(newLearning); await saveJson("learnings.json", learnings); return newLearning; } - src/index.ts:48-60 (schema)Registration and definition of the 'add_learning' tool in the ListTools response.
name: "add_learning", description: "Add a learning, pattern, or insight to Chen's context. Use when Chen adopts a new approach, learns something from a project, or asks to remember something for future use.", inputSchema: { type: "object", properties: { content: { type: "string", description: "The learning or insight to remember" }, source: { type: "string", description: "Optional: project or context where this was learned" }, category: { type: "string", description: "Optional: e.g. 'resume', 'coding', 'process'" }, }, required: ["content"], }, }, - src/storage/context-store.ts:26-32 (schema)Interface definition for the Learning object.
export interface Learning { id: string; content: string; source?: string; category?: string; date: string; }