random-tables-mcp
Version:
An MCP (Model Context Protocol) server for managing and rolling on random-table assets used in tabletop RPGs. Create, update, and roll on random tables with support for nested tables, weighted entries, and range-based results.
55 lines (54 loc) • 1.77 kB
TypeScript
import { RandomTable } from '../../../domain/index.js';
import { TableRepository } from '../../../ports/index.js';
/**
* File-based implementation of the TableRepository interface.
* Stores tables as JSON files in a specified directory.
*/
export declare class FileTableRepository implements TableRepository {
private dataDir;
/**
* Creates a new FileTableRepository instance.
* @param dataDir The directory where table files will be stored.
*/
constructor(dataDir: string);
/**
* Initializes the repository by ensuring the data directory exists.
*/
initialize(): Promise<void>;
/**
* Gets the file path for a table ID.
* @param id The table ID.
* @returns The file path.
*/
private getFilePath;
/**
* Saves a table to the repository.
* @param table The table to save.
* @returns The ID of the saved table.
*/
save(table: RandomTable): Promise<string>;
/**
* Gets a table by its ID.
* @param id The ID of the table to get.
* @returns The table, or null if not found.
*/
getById(id: string): Promise<RandomTable | null>;
/**
* Updates an existing table.
* @param table The updated table.
* @throws Error if the table does not exist.
*/
update(table: RandomTable): Promise<void>;
/**
* Lists tables based on optional filter criteria.
* @param filter Optional filter criteria.
* @returns An array of tables matching the filter.
*/
list(filter?: Record<string, unknown>): Promise<RandomTable[]>;
/**
* Deletes a table by its ID.
* @param id The ID of the table to delete.
* @throws Error if the table does not exist.
*/
delete(id: string): Promise<void>;
}