list_elements
Retrieve available elements by type to manage AI personas, skills, templates, agents, memories, or ensembles within the DollhouseMCP server.
Instructions
List all available elements of a specific type
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | The element type to list |
Implementation Reference
- Core handler logic for the list_elements tool. Scans the filesystem portfolio directory for the specified element type, filters files by type-specific extension, excludes test elements, and handles filesystem errors (missing dir, permissions, etc.) by returning empty list or throwing appropriately.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); } }
- src/server/tools/ElementTools.ts:77-94 (registration)Tool registration and schema definition for list_elements. Registers the tool with MCP server, defines input schema requiring 'type' parameter (enum from ElementType), and provides handler that delegates to server.listElements(type). This is returned by 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) },
- src/server/ServerSetup.ts:52-53 (registration)Global tool registration where ElementTools (including list_elements) are registered with the ToolRegistry during server setup.// Register element tools (new generic tools for all element types) this.toolRegistry.registerMany(getElementTools(instance));