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.
53 lines • 1.89 kB
JavaScript
/**
* Implementation of the TableService interface.
*/
export class TableServiceImpl {
/**
* Creates a new TableServiceImpl instance.
* @param createTableUseCase The use case for creating tables.
* @param getTableUseCase The use case for getting tables.
* @param listTablesUseCase The use case for listing tables.
* @param updateTableUseCase The use case for updating tables.
*/
constructor(createTableUseCase, getTableUseCase, listTablesUseCase, updateTableUseCase) {
this.createTableUseCase = createTableUseCase;
this.getTableUseCase = getTableUseCase;
this.listTablesUseCase = listTablesUseCase;
this.updateTableUseCase = updateTableUseCase;
}
/**
* Creates a new table.
* @param name Table name.
* @param description Optional description.
* @param entries Optional initial entries.
* @returns The ID of the created table.
*/
async createTable(name, description, entries) {
return await this.createTableUseCase.execute(name, description, entries);
}
/**
* Gets a table by its ID.
* @param id The ID of the table to get.
* @returns The table, or null if not found.
*/
async getTable(id) {
return await this.getTableUseCase.execute(id);
}
/**
* Updates an existing table.
* @param id The ID of the table to update.
* @param updates Object containing the updates to apply.
*/
async updateTable(id, updates) {
await this.updateTableUseCase.execute(id, updates);
}
/**
* Lists tables based on optional filter criteria.
* @param filter Optional filter criteria.
* @returns An array of tables matching the filter.
*/
async listTables(filter) {
return await this.listTablesUseCase.execute(filter);
}
}
//# sourceMappingURL=table-service-impl.js.map