UNPKG

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.

35 lines 1.09 kB
import { RandomTable } from '../domain/index.js'; import { v4 as uuidv4 } from 'uuid'; /** * Use case for creating a new random table. */ export class CreateTableUseCase { /** * Creates a new CreateTableUseCase instance. * @param repository The table repository to use. */ constructor(repository) { this.repository = repository; } /** * Executes the use case. * @param name Table name. * @param description Optional description. * @param entries Optional initial entries. * @returns The ID of the created table. */ async execute(name, description = '', entries = []) { // Validate inputs if (!name) { throw new Error('Table name is required'); } // Generate a unique ID for the table const id = uuidv4(); // Create the table const table = new RandomTable(id, name, description, entries); // Save the table to the repository await this.repository.save(table); return id; } } //# sourceMappingURL=create-table-use-case.js.map