kb_import
Import structured knowledge base data from JSON to enable AI agents to maintain persistent 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/index.ts:310-323 (registration)Registers the 'kb_import' tool in the tools list with name, description, and input schema expecting a JSON string 'data'.{ 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:310-323 (schema)Defines the input schema for kb_import tool: object with required 'data' property as string containing JSON.{ 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:843-854 (handler)MCP tool handler: extracts 'data' from arguments, calls KnowledgeManager.importKnowledgeBase, returns success text message.case 'kb_import': { const { data } = args as any; await km.importKnowledgeBase(data); return { content: [ { type: 'text', text: '✅ Knowledge base imported successfully' } ] }; }
- src/KnowledgeManager.ts:364-377 (helper)Core implementation: Parses JSON data, validates it has version and personal fields, replaces internal KB state, saves to file, with error handling.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}`); } }