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.
64 lines • 1.78 kB
JavaScript
import { z } from 'zod';
import { BaseTool } from './tool.js';
/**
* Tool for deleting a roll template.
*/
export class DeleteTemplateTool extends BaseTool {
/**
* Creates a new DeleteTemplateTool 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 'delete_template';
}
/**
* Gets the description of the tool.
* @returns The tool description.
*/
getToolDescription() {
return 'Delete a roll template by ID.';
}
/**
* Gets the input schema for the tool.
* @returns The input schema.
*/
getInputSchema() {
return z.object({
id: z.string().describe('The ID of the template to delete'),
});
}
/**
* Gets the output schema for the tool.
* @returns The output schema.
*/
getOutputSchema() {
return z.object({
success: z.boolean().describe('Whether the deletion was successful'),
});
}
/**
* Implements the tool execution logic.
* @param args The validated tool arguments.
* @returns The tool result.
*/
async executeImpl(args) {
const { id } = args;
try {
// Call the template service to delete the template
await this.templateService.deleteTemplate(id);
return { success: true };
}
catch (error) {
throw new Error(`Failed to delete template: ${error instanceof Error ? error.message : String(error)}`);
}
}
}
//# sourceMappingURL=delete-template-tool.js.map