kb_import
Import structured knowledge base data from JSON to enable AI agents to maintain persistent context and long-term memory across sessions.
Instructions
Import knowledge base from JSON string
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | JSON string of knowledge base data |
Implementation Reference
- src/KnowledgeManager.ts:364-377 (handler)Core handler logic for importing knowledge base: parses JSON input, performs basic structure validation, replaces current KB, and persists to disk via save().async importKnowledgeBase(data: string): Promise<void> { try { const imported = JSON.parse(data); // Validate the structure if (imported.version && imported.personal !== undefined) { this.kb = imported; await this.save(); } else { throw new Error('Invalid knowledge base format'); } } catch (error) { throw new Error(`Failed to import knowledge base: ${error}`); } }
- src/index.ts:843-854 (handler)Tool dispatcher case that extracts the 'data' parameter from tool arguments and delegates to KnowledgeManager.importKnowledgeBase, returning success message.case 'kb_import': { const { data } = args as any; await km.importKnowledgeBase(data); return { content: [ { type: 'text', text: '✅ Knowledge base imported successfully' } ] }; }
- src/index.ts:310-322 (schema)Tool definition including name, description, and input schema specifying required 'data' field as JSON string.{ name: 'kb_import', description: 'Import knowledge base from JSON string', inputSchema: { type: 'object', properties: { data: { type: 'string', description: 'JSON string of knowledge base data' } }, required: ['data'] }
- src/index.ts:423-425 (registration)Registration of ListToolsRequestHandler that returns the tools array containing kb_import.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });