Skip to main content
Glama
saralegui-solutions

MCP Self-Learning Server

export_knowledge

Export the current knowledge base in JSON or Markdown format to save learned patterns and insights from autonomous learning interactions.

Instructions

Export current knowledge base

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNojson

Implementation Reference

  • Main handler for the 'export_knowledge' MCP tool. Extracts format parameter, calls KnowledgeSynchronizer.exportKnowledge(), handles JSON or Markdown output by writing files and returning metadata.
    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
      };
    }
  • KnowledgeSynchronizer method that gathers patterns and insights from the learning engine, serializes and saves to 'knowledge_export.json', returns the knowledge object.
    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;
    }
  • Input schema definition for the export_knowledge tool, specifying optional 'format' parameter with 'json' or 'markdown' options.
      name: 'export_knowledge',
      description: 'Export current knowledge base',
      inputSchema: {
        type: 'object',
        properties: {
          format: {
            type: 'string',
            enum: ['json', 'markdown'],
            default: 'json'
          }
        }
      }
    },
  • Tool dispatch in CallToolRequestSchema handler switch statement, routing 'export_knowledge' calls to the handler method.
    case 'export_knowledge':
      result = await this.handleExportKnowledge(args);
      break;
  • Helper method to convert exported knowledge to Markdown format, used when format='markdown'.
    convertToMarkdown(knowledge) {
      let markdown = '# Knowledge Export\n\n';
      markdown += `Generated: ${knowledge.timestamp}\n\n`;
      
      markdown += '## Insights\n\n';
      const insights = knowledge.insights;
      markdown += `- Total Interactions: ${insights.metrics.totalInteractions}\n`;
      markdown += `- Success Rate: ${(insights.metrics.successRate * 100).toFixed(2)}%\n`;
      markdown += `- Average Response Time: ${insights.metrics.averageResponseTime}ms\n\n`;
      
      markdown += '## Top Patterns\n\n';
      insights.topPatterns.forEach(pattern => {
        markdown += `- **${pattern.key}**: Confidence ${(pattern.confidence * 100).toFixed(2)}% (${pattern.count} occurrences)\n`;
      });
      
      markdown += '\n## Top Tools\n\n';
      insights.topTools.forEach(tool => {
        markdown += `- **${tool.tool}**: ${tool.count} uses\n`;
      });
      
      markdown += '\n## Recommendations\n\n';
      insights.recommendations.forEach(rec => {
        markdown += `- ${rec}\n`;
      });
      
      return markdown;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Export' implies a read operation that outputs data, but the description doesn't specify what 'export' entails (e.g., file generation, data transfer, permissions required, or potential side effects). It lacks details on output format beyond the schema's enum, rate limits, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just three words, front-loading the key action and resource without any wasted words. It's appropriately sized for a simple tool with minimal parameters.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple input schema, the description is incomplete. It doesn't explain what the exported knowledge base contains, how it's structured, or what the tool returns, leaving significant gaps for an AI agent to understand its behavior and output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and only one parameter, the description doesn't add specific parameter details, but it implicitly relates to the 'format' parameter by mentioning 'Export'. Since there's only one parameter and the schema defines it clearly with enum values, the description doesn't need to compensate heavily, earning a baseline score above minimum.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Export current knowledge base' states a clear verb ('Export') and resource ('current knowledge base'), but it's somewhat vague about what 'knowledge base' specifically refers to in this context. It doesn't distinguish this tool from sibling tools like 'import_knowledge' or 'get_insights' beyond the basic action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to export versus analyze, get insights, or import knowledge, nor does it specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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