Skip to main content
Glama
DollhouseMCP

DollhouseMCP

Official

list_elements

Retrieve available elements by type to manage AI personas, skills, templates, agents, memories, or ensembles in DollhouseMCP.

Instructions

List all available elements of a specific type

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesThe element type to list

Implementation Reference

  • Core handler logic that lists elements of a given type by scanning the filesystem directory, filtering by type-specific file extension, excluding test elements, and handling various filesystem errors gracefully.
    public async listElements(type: ElementType): Promise<string[]> {
      const elementDir = this.getElementDir(type);
      const fileExtension = ELEMENT_FILE_EXTENSIONS[type] || DEFAULT_ELEMENT_FILE_EXTENSION;
    
      try {
        const files = await fs.readdir(elementDir);
        // Filter for correct file extension based on element type and exclude test elements
        return files
          .filter(file => file.endsWith(fileExtension))
          .filter(file => !this.isTestElement(file));
      } catch (error) {
        const err = error as NodeJS.ErrnoException;
        
        if (err.code === 'ENOENT') {
          // Directory doesn't exist yet - this is expected for new installations
          logger.debug(`[PortfolioManager] Element directory doesn't exist yet: ${elementDir}`);
          return [];
        }
        
        if (err.code === 'EACCES' || err.code === 'EPERM') {
          // Permission denied - log but return empty array
          ErrorHandler.logError('PortfolioManager.listElements', error, { elementDir });
          return [];
        }
        
        if (err.code === 'ENOTDIR') {
          // Path exists but is not a directory
          ErrorHandler.logError('PortfolioManager.listElements', error, { elementDir });
          throw ErrorHandler.createError(`Path is not a directory: ${elementDir}`, ErrorCategory.SYSTEM_ERROR);
        }
        
        // For any other errors, throw with context
        ErrorHandler.logError('PortfolioManager.listElements', error, { elementDir });
        throw ErrorHandler.wrapError(error, 'Failed to list elements', ErrorCategory.SYSTEM_ERROR);
      }
    }
  • Tool schema definition including input validation schema for 'type' parameter constrained to valid ElementType enum values.
    tool: {
      name: "list_elements",
      description: "List all available elements of a specific type",
      inputSchema: {
        type: "object",
        properties: {
          type: {
            type: "string",
            description: "The element type to list",
            enum: Object.values(ElementType),
          },
        },
        required: ["type"],
      },
    },
  • Registers the element tools (including list_elements) from ElementTools into the central ToolRegistry during server setup.
    // Register element tools (new generic tools for all element types)
    this.toolRegistry.registerMany(getElementTools(instance));
  • Defines and prepares the list_elements tool definition and thin handler (delegating to server.listElements) for registration in getElementTools().
    {
      tool: {
        name: "list_elements",
        description: "List all available elements of a specific type",
        inputSchema: {
          type: "object",
          properties: {
            type: {
              type: "string",
              description: "The element type to list",
              enum: Object.values(ElementType),
            },
          },
          required: ["type"],
        },
      },
      handler: (args: ListElementsArgs) => server.listElements(args.type)
    },
  • Helper method used by listElements to filter out test and dangerous files from the listing.
    public isTestElement(filename: string): boolean {
      // Dangerous test patterns that should never appear in production
      const dangerousPatterns = [
        /^bin-sh/i,
        /^rm-rf/i,
        /^nc-e-bin/i,
        /^python-c-import/i,
        /^curl.*evil/i,
        /^wget.*malicious/i,
        /^eval-/i,
        /^exec-/i,
        /^bash-c-/i,
        /^sh-c-/i,
        /^powershell-/i,
        /^cmd-c-/i,
        /shell-injection/i
      ];
      
      // Common test patterns
      const testPatterns = [
        /^test-/i,
        /^memory-test-/i,
        /^yaml-test/i,
        /^perf-test-/i,
        /^stability-test-/i,
        /^roundtrip-test/i,
        /test-persona/i,
        /test-skill/i,
        /test-template/i,
        /test-agent/i,
        /\.test\./,
        /__test__/,
        /test-data/,
        /penetration-test/i,
        /metadata-test/i,
        /testpersona\d+/i  // Generated test personas with timestamps
      ];
      
      // Check dangerous patterns first
      if (dangerousPatterns.some(pattern => pattern.test(filename))) {
        logger.warn(`[PortfolioManager] Filtered dangerous test element: ${filename}`);
        return true;
      }
      
      // Check common test patterns
      return testPatterns.some(pattern => pattern.test(filename));
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it 'lists' elements, implying a read-only operation, but doesn't disclose behavioral traits like whether it returns all elements or paginates, what the output format is, or any rate limits. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence that gets straight to the point without unnecessary words. It's appropriately sized for a simple tool, though it could be more informative without sacrificing brevity.

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 'elements' are, how results are returned, or any limitations. For a tool in a context with many siblings, more detail is needed to ensure proper usage.

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?

The description adds minimal meaning beyond the input schema, which has 100% coverage and includes an enum for the 'type' parameter. It implies filtering by type but doesn't provide additional context like default behaviors or examples. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

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 'List all available elements of a specific type' clearly states the verb ('List') and resource ('elements'), but it's vague about what 'elements' are and doesn't distinguish this tool from sibling tools like 'get_active_elements' or 'search_collection'. The purpose is understandable but lacks specificity compared to alternatives.

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 such as 'get_active_elements' (which might list only active ones) or 'search_collection' (which might offer filtering). There's no mention of prerequisites, exclusions, or comparative context with sibling tools.

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

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