@dollhousemcp/mcp-server
Version:
DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.
88 lines • 3.92 kB
TypeScript
/**
* FIX: DMCP-SEC-006 - Security audit suppression
* This file contains only helper utilities for element operations.
* No audit logging is required - logging happens in the calling handlers.
* @security-audit-suppress DMCP-SEC-006
*/
import { ElementType } from '../../portfolio/PortfolioManager.js';
export declare function findElementFlexibly<T extends {
metadata?: {
name?: string;
};
}>(name: string, elementList: T[]): T | undefined;
export declare function sanitizeMetadata(metadata: Record<string, any> | undefined): Record<string, any>;
export declare function collectGatekeeperAuthoringErrors(input: Record<string, unknown> | undefined, metadata?: unknown): string[];
export declare function formatGatekeeperValidationMessage(errors: string[]): string;
export declare function normalizeElementTypeInput(rawType: string | null | undefined): {
type: ElementType | null;
aliasUsed: boolean;
};
export declare function formatValidElementTypesList(): string;
export declare function getElementTypeLabel(type: ElementType, options?: {
plural?: boolean;
}): string;
export declare function getElementFilename(type: ElementType, name: string): string;
export interface ElementManagerOperations<T> {
list?: () => Promise<T[]>;
find?: (predicate: (candidate: T) => boolean) => Promise<T | undefined>;
load?: (filePath: string) => Promise<T>;
}
/**
* Known metadata properties for each element type.
* Used by both `detectUnknownMetadataProperties()` (create/edit warnings)
* and `editElement()` (field routing to metadata vs element object).
*
* IMPORTANT: Both camelCase and snake_case variants must be listed where
* applicable, since LLMs may send either form. The lookup uses exact
* string matching via `Set.has()`.
*
* @example
* // Common properties shared across all types:
* 'name', 'description', 'author', 'version', 'tags', 'gatekeeper'
*
* @example
* // Type-specific properties (only valid for that element type):
* Agent: 'goal', 'activates', 'tools', 'autonomy', 'resilience'
* Skill: 'domains', 'category', 'prerequisites'
* Ensemble: 'elements', 'activationStrategy', 'activation_strategy'
*/
export declare const KNOWN_METADATA_PROPERTIES: Record<ElementType, Set<string>>;
/**
* Result of checking metadata for unknown properties.
*/
export interface UnknownPropertyWarning {
property: string;
suggestion?: string;
message: string;
}
/**
* Validate a gatekeeper policy in element metadata.
* Returns warnings (not throws) for invalid policy structures,
* so LLMs get immediate feedback about malformed policies.
*
* @param metadata - The metadata object containing the gatekeeper policy
* @returns Array of warnings for invalid policy structure (empty if valid)
*/
export declare function validateGatekeeperPolicy(metadata: Record<string, unknown>): UnknownPropertyWarning[];
export declare function detectUnknownMetadataProperties(elementType: ElementType, metadata: Record<string, unknown> | undefined): UnknownPropertyWarning[];
/**
* Format unknown property warnings for MCP response.
* Returns a warning block that can be prepended to success messages.
*/
export declare function formatUnknownPropertyWarnings(warnings: UnknownPropertyWarning[]): string;
/**
* Format element resolution warnings for MCP response.
* Surfaces disambiguation and not-found info from resolveElementTypes()
* so the user can fix missing element_type fields.
*
* Follows the same pattern as formatUnknownPropertyWarnings().
*/
export declare function formatElementResolutionWarnings(result: {
ambiguous: Array<{
element_name: string;
found_in: string[];
}>;
notFound: string[];
}): string;
export declare function resolveElementByName<T>(manager: ElementManagerOperations<T> | null | undefined, type: ElementType, name: string): Promise<T | undefined>;
//# sourceMappingURL=helpers.d.ts.map