Skip to main content
Glama

import_persona

Add custom AI personas to the DollhouseMCP server by importing from files or JSON strings, enabling dynamic behavior switching for compatible assistants.

Instructions

Import a persona from a file path or JSON string

Input Schema

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

Implementation Reference

  • MCP tool definition including name, description, input schema, and handler function that executes the tool logic by calling server.importPersona(source, overwrite)
    {
      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)
    }
  • Registration of the persona tools (including import_persona) into the MCP tool registry during server setup
    // Register persona export/import tools (core functionality moved to element tools)
    this.toolRegistry.registerMany(getPersonaExportImportTools(instance));
  • Input schema validation for the import_persona tool
    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"],
    },
  • Core helper class with detailed import logic, validation, security checks, and file handling likely used by server.importPersona
    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)}`
        };
      }
    }
  • Function that provides the tool definitions and handlers for registration, called during server setup
    export function getPersonaExportImportTools(server: IToolHandler): Array<{ tool: ToolDefinition; handler: any }> {
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'import' but doesn't clarify key traits: whether this requires specific permissions, what happens on success/failure, if it's idempotent, or any rate limits. The 'overwrite' parameter hints at mutation behavior, but the description doesn't explicitly warn about potential data loss or side effects.

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 a single, efficient sentence that front-loads the core action ('import a persona') and specifies input types. There's no wasted verbiage, making it easy for an agent to parse quickly.

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 the complexity of importing data (a mutation operation) with no annotations and no output schema, the description is inadequate. It doesn't explain what a 'persona' is in this context, what formats are supported beyond implied .md/.json, or what the tool returns. This leaves significant gaps for safe and effective use.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters ('source' and 'overwrite') thoroughly. The description adds minimal value beyond implying the source can be a file path or JSON string, which is partly covered in the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('import') and resource ('persona'), specifying it can be from a file path or JSON string. However, it doesn't distinguish this tool from its many siblings (e.g., 'create_element', 'edit_element'), which might also involve persona manipulation, leaving some ambiguity about its unique role.

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 like 'create_element' or 'edit_element'. It lacks context about prerequisites (e.g., file format requirements) or exclusions, leaving the agent to infer usage based on the name alone.

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

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