/**
* @fileoverview Tool definitions for FoundryVTT MCP Server
*
* This module contains all tool schema definitions organized by category.
* Tools are separated into logical groups for better maintainability.
*/
/**
* Dice rolling tool definitions
*/
export const diceTools = [
{
name: 'roll_dice',
description: 'Roll dice using standard RPG notation (e.g., 1d20, 3d6+4)',
inputSchema: {
type: 'object',
properties: {
formula: {
type: 'string',
description: 'Dice formula (e.g., "1d20+5", "3d6")',
},
reason: {
type: 'string',
description: 'Optional reason for the roll',
},
},
required: ['formula'],
},
},
];
/**
* Actor management tool definitions
*/
export const actorTools = [
{
name: 'search_actors',
description: 'Search for actors (characters, NPCs) in FoundryVTT',
inputSchema: {
type: 'object',
properties: {
query: {
type: 'string',
description: 'Search query for actor names',
},
type: {
type: 'string',
description: 'Actor type filter (character, npc, etc.)',
},
limit: {
type: 'number',
description: 'Maximum number of results to return',
default: 10,
},
},
},
},
{
name: 'get_actor_details',
description: 'Get detailed information about a specific actor',
inputSchema: {
type: 'object',
properties: {
actorId: {
type: 'string',
description: 'The ID of the actor to retrieve',
},
},
required: ['actorId'],
},
},
];
/**
* Item management tool definitions
*/
export const itemTools = [
{
name: 'search_items',
description: 'Search for items in FoundryVTT',
inputSchema: {
type: 'object',
properties: {
query: {
type: 'string',
description: 'Search query for item names',
},
type: {
type: 'string',
description: 'Item type filter (weapon, armor, consumable, etc.)',
},
rarity: {
type: 'string',
description: 'Item rarity filter (common, uncommon, rare, etc.)',
},
limit: {
type: 'number',
description: 'Maximum number of results to return',
default: 10,
},
},
},
},
];
/**
* Scene management tool definitions
*/
export const sceneTools = [
{
name: 'get_scene_info',
description: 'Get information about the current or specified scene',
inputSchema: {
type: 'object',
properties: {
sceneId: {
type: 'string',
description: 'Optional scene ID. If not provided, returns current scene',
},
},
},
},
];
/**
* Content generation tool definitions
*/
export const generationTools = [
{
name: 'generate_npc',
description: 'Generate a random NPC with stats and background',
inputSchema: {
type: 'object',
properties: {
level: {
type: 'number',
description: 'Character level (1-20)',
minimum: 1,
maximum: 20,
default: 1,
},
race: {
type: 'string',
description: 'Character race (optional)',
},
class: {
type: 'string',
description: 'Character class (optional)',
},
},
},
},
{
name: 'generate_loot',
description: 'Generate random loot for encounters',
inputSchema: {
type: 'object',
properties: {
challengeRating: {
type: 'number',
description: 'Challenge rating for loot generation',
minimum: 0,
maximum: 30,
},
treasureType: {
type: 'string',
description: 'Type of treasure (hoard, individual, etc.)',
},
},
},
},
{
name: 'lookup_rule',
description: 'Look up game rules and mechanics',
inputSchema: {
type: 'object',
properties: {
query: {
type: 'string',
description: 'Rule or mechanic to look up',
},
system: {
type: 'string',
description: 'Game system (D&D 5e, Pathfinder, etc.)',
},
},
required: ['query'],
},
},
];
/**
* Diagnostics and logging tool definitions
*/
export const diagnosticsTools = [
{
name: 'get_recent_logs',
description: 'Get recent log entries from FoundryVTT',
inputSchema: {
type: 'object',
properties: {
limit: {
type: 'number',
description: 'Number of log entries to retrieve',
default: 20,
minimum: 1,
maximum: 100,
},
level: {
type: 'string',
description: 'Log level filter (debug, info, warn, error)',
enum: ['debug', 'info', 'warn', 'error'],
},
since: {
type: 'string',
description: 'Get logs since this timestamp (ISO format)',
},
},
},
},
{
name: 'search_logs',
description: 'Search through FoundryVTT logs',
inputSchema: {
type: 'object',
properties: {
query: {
type: 'string',
description: 'Search query for log contents',
},
level: {
type: 'string',
description: 'Log level filter',
enum: ['debug', 'info', 'warn', 'error'],
},
limit: {
type: 'number',
description: 'Maximum number of results',
default: 50,
},
},
required: ['query'],
},
},
{
name: 'get_system_health',
description: 'Get system health and performance metrics',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'diagnose_errors',
description: 'Diagnose and analyze system errors',
inputSchema: {
type: 'object',
properties: {
category: {
type: 'string',
description: 'Error category to focus on',
},
},
},
},
{
name: 'get_health_status',
description: 'Get comprehensive health status of FoundryVTT server',
inputSchema: {
type: 'object',
properties: {},
},
},
];
/**
* Get all tool definitions combined
*/
export function getAllTools() {
return [
...diceTools,
...actorTools,
...itemTools,
...sceneTools,
...generationTools,
...diagnosticsTools,
];
}
/**
* Get modernized tool definitions from registry (when available)
*/
export async function getModernizedTools() {
try {
const { toolRegistry } = await import('./registry.js');
const modernTools = toolRegistry.getToolDefinitions();
// Filter out tools that have been modernized to avoid duplicates
const modernToolNames = new Set(modernTools.map(tool => tool.name));
const legacyTools = getAllTools().filter(tool => !modernToolNames.has(tool.name));
return [
...modernTools,
...legacyTools,
];
} catch (error) {
// Fallback to legacy definitions if registry is not available
return getAllTools();
}
}