Skip to main content
Glama

export_knowledge

Extract the current knowledge base in JSON or Markdown format for analysis, sharing, or integration with other systems.

Instructions

Export current knowledge base

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNojson

Implementation Reference

  • Registration of the 'export_knowledge' MCP tool in the ListTools response, including name, description, and input schema definition.
    { name: 'export_knowledge', description: 'Export current knowledge base', inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['json', 'markdown'], default: 'json' } } } },
  • Input schema for the 'export_knowledge' tool defining the optional 'format' parameter.
    inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['json', 'markdown'], default: 'json' } } }
  • Primary handler function for executing the 'export_knowledge' tool. Delegates core export to KnowledgeSynchronizer and handles markdown format conversion.
    async handleExportKnowledge(args) { const { format = 'json' } = args; const knowledge = await this.knowledgeSync.exportKnowledge(); if (format === 'markdown') { const markdown = this.convertToMarkdown(knowledge); const mdPath = path.join(process.cwd(), 'knowledge_export.md'); await fs.writeFile(mdPath, markdown); return { success: true, format: 'markdown', path: mdPath, size: markdown.length }; } return { success: true, format: 'json', path: path.join(process.cwd(), 'knowledge_export.json'), items: knowledge.patterns.length }; }
  • Supporting method in KnowledgeSynchronizer class that performs the actual knowledge export to JSON file, called by the tool handler.
    async exportKnowledge() { const knowledge = { timestamp: new Date().toISOString(), patterns: Array.from(this.learningEngine.patterns.entries()), insights: this.learningEngine.getInsights(), version: '1.0.0' }; // Save to file const exportPath = path.join(process.cwd(), 'knowledge_export.json'); await fs.writeFile(exportPath, JSON.stringify(knowledge, null, 2)); return knowledge; }

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/saralegui-solutions/mcp-self-learning-server'

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