Skip to main content
Glama

import_persona

Enables dynamic AI persona management by importing a persona from a specified file path or JSON string, with optional overwrite capabilities.

Instructions

Import a persona from a file path or JSON string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
overwriteNoOverwrite if persona already exists (default: false)
sourceYesFile path to a .md or .json file, or a JSON string of the persona

Implementation Reference

  • MCP tool registration for 'import_persona' including name, description, input schema validation, and handler that delegates to server.importPersona
    { tool: { name: "import_persona", description: "Import a persona from a file path or JSON string", inputSchema: { type: "object", properties: { source: { type: "string", description: "File path to a .md or .json file, or a JSON string of the persona", }, overwrite: { type: "boolean", description: "Overwrite if persona already exists (default: false)", }, }, required: ["source"], }, }, handler: (args: any) => server.importPersona(args.source, args.overwrite) } ];
  • Core implementation of persona import handling various input formats (file, base64, JSON, markdown), security validation, conflict checking, and file creation. Likely called from server.importPersona method.
    async importPersona(source: string, existingPersonas: Map<string, Persona>, overwrite = false): Promise<ImportResult> { try { // Determine source type let personaData: ExportedPersona | null = null; // Check if it's a file path if (source.startsWith('/') || source.startsWith('./') || source.endsWith('.md') || source.endsWith('.json')) { personaData = await this.importFromFile(source); } // Check if it's base64 encoded else if (this.isBase64(source)) { personaData = await this.importFromBase64(source); } // Try parsing as JSON directly else { try { const parsed = JSON.parse(source); if (this.isExportBundle(parsed)) { return this.importBundle(parsed, existingPersonas, overwrite); } else if (this.isExportedPersona(parsed)) { personaData = parsed; } } catch { // Not JSON, might be raw markdown return this.importFromMarkdown(source, existingPersonas, overwrite); } } if (!personaData) { return { success: false, message: "Could not parse import source. Please provide a file path, JSON string, or base64 encoded data." }; } // Validate and create persona return await this.createPersonaFromExport(personaData, existingPersonas, overwrite); } catch (error) { logger.error('Import error', error); return { success: false, message: `Import failed: ${error instanceof Error ? error.message : String(error)}` }; } }
  • Type definition for the server.importPersona method called by the tool handler.
    importPersona(source: string, overwrite?: boolean): Promise<any>;

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/DollhouseMCP/mcp-server'

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