manage_concentration
Track and manage D&D 5e spell concentration, including setting concentration, checking saves after damage, and ending concentration with proper DC calculations.
Instructions
Manage D&D 5e concentration on spells. Operations: set (begin concentrating), get (query state), check (roll save after damage), break (end concentration). DC = max(10, damage/2). Supports advantage/disadvantage on saves.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| characterId | No | ||
| operation | No | ||
| spellName | No | ||
| targets | No | ||
| duration | No | ||
| reason | No | ||
| damage | No | ||
| conSaveModifier | No | ||
| rollMode | No | ||
| manualRoll | No | ||
| manualRolls | No |
Implementation Reference
- src/modules/magic.ts:183-198 (handler)Main handler function for the manage_concentration tool. Dispatches to operation-specific handlers (set, get, break, check) based on input.operation. Returns ASCII-formatted result string.export function manageConcentration(input: ManageConcentrationInput): string { switch (input.operation) { case 'set': return handleSetConcentration(input); case 'get': return handleGetConcentration(input); case 'break': return handleBreakConcentration(input); case 'check': return handleCheckConcentration(input); default: // TypeScript exhaustiveness check const _exhaustive: never = input; throw new Error(`Unknown operation: ${(_exhaustive as { operation: string }).operation}`); } }
- src/modules/magic.ts:109-120 (schema)Zod schema defining the input for manage_concentration tool as a discriminated union of four operations: set (begin concentration), get (query state), break (end concentration), check (save after damage)./** * Combined schema for all manage_concentration operations. * Supports: set, get, break, check */ export const manageConcentrationSchema = z.union([ setOperationSchema, getOperationSchema, breakOperationSchema, checkOperationSchema, ]); export type ManageConcentrationInput = z.infer<typeof manageConcentrationSchema>;
- src/registry.ts:960-978 (registration)Tool registration in the central registry. Defines name, description, converts Zod schema to JSON Schema for MCP, and provides an async wrapper handler that parses input with manageConcentrationSchema and calls the main manageConcentration function.manage_concentration: { name: 'manage_concentration', description: 'Manage D&D 5e concentration on spells. Operations: set (begin concentrating), get (query state), check (roll save after damage), break (end concentration). DC = max(10, damage/2). Supports advantage/disadvantage on saves.', inputSchema: toJsonSchema(manageConcentrationSchema), handler: async (args) => { try { const validated = manageConcentrationSchema.parse(args); const result = manageConcentration(validated); return success(result); } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } }, },