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.

71 lines 2.37 kB
import { z } from 'zod'; import { BaseTool } from './tool.js'; /** * Tool for creating a new roll template. */ export class CreateTemplateTool extends BaseTool { /** * Creates a new CreateTemplateTool instance. * @param templateService The template service to use. */ constructor(templateService) { super(); this.templateService = templateService; } /** * Gets the name of the tool. * @returns The tool name. */ getToolName() { return 'create_template'; } /** * Gets the description of the tool. * @returns The tool description. */ getToolDescription() { return 'Create a new roll template. Templates can include references to tables using the format {{reference-title::table-id::table-name::roll-number::separator}}.'; } /** * Gets the input schema for the tool. * @returns The input schema. */ getInputSchema() { return z.object({ name: z.string().describe('Template name'), description: z.string().optional().describe('Optional description'), template: z .string() .describe('The template string. Can include references to tables in the format {{reference-title::table-id::table-name::roll-number::separator}}.'), }); } /** * Gets the output schema for the tool. * @returns The output schema. */ getOutputSchema() { return z.object({ templateId: z.string().describe('The ID of the created template'), name: z.string().describe('The name of the template'), description: z.string().describe('The description of the template'), template: z.string().describe('The template string'), }); } /** * Implements the tool execution logic. * @param args The validated tool arguments. * @returns The tool result. */ async executeImpl(args) { const { name, description = '', template } = args; // Call the template service to create the template const templateId = await this.templateService.createTemplate(name, description, template); return { templateId, name, description, template, }; } } //# sourceMappingURL=create-template-tool.js.map