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.

66 lines 1.88 kB
import { z } from 'zod'; import { BaseTool } from './tool.js'; /** * Tool for listing roll templates. */ export class ListTemplateTool extends BaseTool { /** * Creates a new ListTemplateTool 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 'list_templates'; } /** * Gets the description of the tool. * @returns The tool description. */ getToolDescription() { return 'List all available roll templates.'; } /** * Gets the input schema for the tool. * @returns The input schema. */ getInputSchema() { return z.object({}).strict(); } /** * Gets the output schema for the tool. * @returns The output schema. */ getOutputSchema() { return z.object({ templates: z.array(z.object({ id: z.string().describe('The ID of the template'), name: z.string().describe('The name of the template'), description: z.string().describe('The description of the template'), })), }); } /** * Implements the tool execution logic. * @param args The validated tool arguments. * @returns The tool result. */ async executeImpl(_args) { // Call the template service to list templates const templates = await this.templateService.listTemplates(); return { templates: templates.map(template => ({ id: template.id, name: template.name, description: template.description, })), }; } } //# sourceMappingURL=list-templates-tool.js.map