Skip to main content
Glama

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
NameRequiredDescriptionDefault
dataYesJSON 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'] } },
  • 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'] } },
  • 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' } ] }; }
  • 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}`); } }

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/hlsitechio/mcp-instruct'

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