foundryvtt-mcp 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +23 -12
  2. package/dist/diagnostics/client.d.ts +8 -4
  3. package/dist/diagnostics/client.d.ts.map +1 -1
  4. package/dist/diagnostics/client.js +8 -3
  5. package/dist/diagnostics/client.js.map +1 -1
  6. package/dist/foundry/auth.d.ts.map +1 -1
  7. package/dist/foundry/auth.js +9 -0
  8. package/dist/foundry/auth.js.map +1 -1
  9. package/dist/foundry/client.d.ts +127 -6
  10. package/dist/foundry/client.d.ts.map +1 -1
  11. package/dist/foundry/client.js +261 -38
  12. package/dist/foundry/client.js.map +1 -1
  13. package/dist/foundry/dice-formula.d.ts +79 -0
  14. package/dist/foundry/dice-formula.d.ts.map +1 -0
  15. package/dist/foundry/dice-formula.js +154 -0
  16. package/dist/foundry/dice-formula.js.map +1 -0
  17. package/dist/foundry/types.d.ts +11 -1
  18. package/dist/foundry/types.d.ts.map +1 -1
  19. package/dist/foundry/world-cache.d.ts +22 -0
  20. package/dist/foundry/world-cache.d.ts.map +1 -1
  21. package/dist/foundry/world-cache.js +56 -0
  22. package/dist/foundry/world-cache.js.map +1 -1
  23. package/dist/tools/definitions.d.ts +9 -0
  24. package/dist/tools/definitions.d.ts.map +1 -1
  25. package/dist/tools/definitions.js +77 -54
  26. package/dist/tools/definitions.js.map +1 -1
  27. package/dist/tools/handlers/combat-mutations.d.ts +14 -0
  28. package/dist/tools/handlers/combat-mutations.d.ts.map +1 -1
  29. package/dist/tools/handlers/combat-mutations.js +33 -4
  30. package/dist/tools/handlers/combat-mutations.js.map +1 -1
  31. package/dist/tools/handlers/combat-order.d.ts +69 -0
  32. package/dist/tools/handlers/combat-order.d.ts.map +1 -0
  33. package/dist/tools/handlers/combat-order.js +94 -0
  34. package/dist/tools/handlers/combat-order.js.map +1 -0
  35. package/dist/tools/handlers/combat.d.ts.map +1 -1
  36. package/dist/tools/handlers/combat.js +5 -2
  37. package/dist/tools/handlers/combat.js.map +1 -1
  38. package/dist/tools/handlers/diagnostics.d.ts +25 -0
  39. package/dist/tools/handlers/diagnostics.d.ts.map +1 -1
  40. package/dist/tools/handlers/diagnostics.js +152 -38
  41. package/dist/tools/handlers/diagnostics.js.map +1 -1
  42. package/dist/tools/handlers/dice.d.ts +1 -1
  43. package/dist/tools/handlers/dice.d.ts.map +1 -1
  44. package/dist/tools/handlers/dice.js +2 -1
  45. package/dist/tools/handlers/dice.js.map +1 -1
  46. package/dist/tools/handlers/resources.d.ts.map +1 -1
  47. package/dist/tools/handlers/resources.js +16 -1
  48. package/dist/tools/handlers/resources.js.map +1 -1
  49. package/package.json +3 -3
@@ -4,13 +4,35 @@
4
4
  * This module contains all tool schema definitions organized by category.
5
5
  * Tools are separated into logical groups for better maintainability.
6
6
  */
7
+ /**
8
+ * Shared write-safety clause appended to every mutation tool description.
9
+ *
10
+ * Both halves are enforced in code by `assertWriteable()`
11
+ * (`src/foundry/client.ts`): the `FOUNDRY_WRITE_ENABLED` opt-in (default
12
+ * `false`, see `src/config/index.ts`) and a live authenticated Socket.IO
13
+ * session. Foundry itself enforces the GM/owner permission (ADR-010).
14
+ */
15
+ const WRITE_GATE = 'WRITE: mutates the live world. Requires FOUNDRY_WRITE_ENABLED=true (default false) and an active Socket.IO connection, and is refused otherwise; Foundry additionally enforces GM/owner permission on the document.';
16
+ /**
17
+ * Extra clause for destructive tools (data removal that this server cannot undo).
18
+ */
19
+ const CONFIRM_FIRST = 'DESTRUCTIVE and not undoable from this server: confirm the exact target with the user before calling.';
20
+ /**
21
+ * Canonical `roll_dice` description.
22
+ *
23
+ * Exported so `RollDiceTool` (`src/tools/handlers/dice.ts`) can reuse the exact
24
+ * same string instead of keeping a second copy that silently drifts: the
25
+ * registry class is what *executes* the tool while `getAllTools()` is what is
26
+ * *listed*, so a divergence would be invisible.
27
+ */
28
+ export const ROLL_DICE_DESCRIPTION = 'Roll dice and return the total with a per-term breakdown. Dice terms and whole numbers joined by + or -, with whitespace allowed anywhere ("1d20+5", "1d20 + 5", "1d20+5+3", "2d6 + 1d4", "3d6"; a count-less "d20" means one die), always work and every term counts towards the total - that is the portable grammar, safe on either transport. Multiplication and Foundry modifier syntax such as "4d6kh3" or "1d20r1" are rejected on both transports, with an error naming the offending character and its position, never dropped from the total in silence. Parentheses are the one difference: with FOUNDRY_API_KEY set the formula goes to FoundryVTT\'s own Roll engine, which evaluates them, while the default Socket.IO transport rolls locally and rejects them by name - and a REST roll that cannot reach the server falls back to that same local roller, so a parenthesised formula can still fail there. Prefer the expanded form when it matters. Use when: the user asks for a check, save, attack, damage, or any random result.';
7
29
  /**
8
30
  * Dice rolling tool definitions
9
31
  */
10
32
  export const diceTools = [
11
33
  {
12
34
  name: 'roll_dice',
13
- description: 'Roll dice using standard RPG notation (e.g., 1d20, 3d6+4)',
35
+ description: ROLL_DICE_DESCRIPTION,
14
36
  inputSchema: {
15
37
  type: 'object',
16
38
  properties: {
@@ -33,7 +55,7 @@ export const diceTools = [
33
55
  export const actorTools = [
34
56
  {
35
57
  name: 'search_actors',
36
- description: 'Search for actors (characters, NPCs) in FoundryVTT',
58
+ description: "Search actors (player characters, NPCs) by name, optionally filtered by type. Returns a summary line per match: name, type, level and current/max HP. Use when: checking whether an actor exists, or getting a quick roster with HP. Do not use when: you already have the actorId and want that actor's ability scores - use get_actor_details; or you need the actorId itself, which this tool does not print - read the foundry://actors resource, whose JSON lists up to the first 100 actors with their _id (not exhaustive in larger worlds).",
37
59
  inputSchema: {
38
60
  type: 'object',
39
61
  properties: {
@@ -55,7 +77,7 @@ export const actorTools = [
55
77
  },
56
78
  {
57
79
  name: 'get_actor_details',
58
- description: 'Get detailed information about a specific actor',
80
+ description: 'Get details for one actor by id: type, level, current/max HP, AC and ability scores; no biography or description text is returned (the description line always reads "No description available."). Use when: you have an actorId and need its current HP or ability scores - notably as the read-before-write step for update_actor_attributes. Do not use when: you only have a name - run search_actors first; or you need the ids of items the actor owns, which this tool does not return (no tool in this server lists owned-item ids - ask the user for the itemId).',
59
81
  inputSchema: {
60
82
  type: 'object',
61
83
  properties: {
@@ -77,11 +99,8 @@ export const actorTools = [
77
99
  export const actorMutationTools = [
78
100
  {
79
101
  name: 'update_actor_attributes',
80
- description: "Update attributes on an actor's system data. The patch keys are dot-paths into actor.system " +
81
- '(e.g. "attributes.hp.value", "attributes.hp.temp", "currency.gp", "resources.primary.value", ' +
82
- '"spells.spell1.value", "attributes.exhaustion"). Returns the post-update value for every patched ' +
83
- 'path. Validates HP <= max + temp, spell slots <= max, and exhaustion within 0-10 (2024) or 0-6 (2014). ' +
84
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
102
+ description: 'Update fields on an actor\'s system data. Patch keys are dot-paths into actor.system (e.g. "attributes.hp.value", "attributes.hp.temp", "currency.gp", "resources.primary.value", "spells.spell1.value", "attributes.exhaustion") and values are absolute target values, never relative deltas. Validates HP <= max + temp, spell slots <= max, and exhaustion within 0-10 (2024) or 0-6 (2014), and returns the post-update value for every patched path. Use when: applying damage or healing, spending a spell slot or resource, or adjusting currency on a known actorId. Do not use when: changing an item the actor owns (use update_actor_item) or only reading current values (use get_actor_details). ' +
103
+ WRITE_GATE,
85
104
  inputSchema: {
86
105
  type: 'object',
87
106
  properties: {
@@ -108,7 +127,7 @@ export const actorMutationTools = [
108
127
  export const itemTools = [
109
128
  {
110
129
  name: 'search_items',
111
- description: 'Search for items in FoundryVTT',
130
+ description: 'Search item documents in the world by name, optionally filtered by type. Returns name, type and rarity per match (rarity shows "Common" when the system records none); price is not available and always prints "Unknown price", and the rarity filter is ignored unless the REST API module is configured (FOUNDRY_API_KEY). Item ids are not printed - read the foundry://items resource, whose JSON lists up to the first 100 items with their _id (not exhaustive in larger worlds). Use when: checking whether an item exists in the world. Do not use when: searching compendium packs (use search_compendium) or listing what one actor carries (this searches world items, not owned items).',
112
131
  inputSchema: {
113
132
  type: 'object',
114
133
  properties: {
@@ -122,7 +141,7 @@ export const itemTools = [
122
141
  },
123
142
  rarity: {
124
143
  type: 'string',
125
- description: 'Item rarity filter (common, uncommon, rare, etc.)',
144
+ description: 'Item rarity filter (common, uncommon, rare, etc.). Applied only in REST API mode (FOUNDRY_API_KEY); ignored on the default Socket.IO path.',
126
145
  },
127
146
  limit: {
128
147
  type: 'number',
@@ -139,7 +158,7 @@ export const itemTools = [
139
158
  export const compendiumTools = [
140
159
  {
141
160
  name: 'search_compendium',
142
- description: 'Search FoundryVTT compendium packs by name and metadata. Searches all enabled compendiums by default; the compendiumId filter scopes to one pack. Requires the REST API module (FOUNDRY_API_KEY).',
161
+ description: 'Search FoundryVTT compendium packs by name and metadata; searches all enabled packs unless compendiumId scopes it to one pack. Use when: looking up spells, monsters, or equipment that are not yet present in the world. Do not use when: the document already exists in the world - use search_items or search_world. Requires the REST API module (FOUNDRY_API_KEY); without it the search returns no results instead of failing.',
143
162
  inputSchema: {
144
163
  type: 'object',
145
164
  properties: {
@@ -197,7 +216,8 @@ export const compendiumTools = [
197
216
  export const itemMutationTools = [
198
217
  {
199
218
  name: 'create_actor_item',
200
- description: 'Create an item on an actor from an inline item document (requires FOUNDRY_WRITE_ENABLED + active Socket.IO connection). Compendium-source create is not yet supported over Socket.IO (see issue #159). Canonical target: D&D 5e v4+ activity schema.',
219
+ description: 'Create an item on an actor from an inline item document (type, name, system). Use when: adding a new weapon, spell, feature, or piece of equipment to a known actorId. Do not use when: editing an item the actor already owns - use update_actor_item. Replacing an item is not atomic: create the replacement first and delete the old one second, so a mid-sequence failure leaves the actor with a duplicate rather than nothing. Compendium-source create is not yet supported over Socket.IO (see issue #159). Canonical target: D&D 5e v4+ activity schema. ' +
220
+ WRITE_GATE,
201
221
  inputSchema: {
202
222
  type: 'object',
203
223
  properties: {
@@ -207,12 +227,12 @@ export const itemMutationTools = [
207
227
  },
208
228
  source: {
209
229
  type: 'object',
210
- description: 'Item source: { type: "compendium", compendiumId, itemId } to copy a compendium entry, or { type: "inline", item: { type, name, system } } to create directly',
230
+ description: 'Item source. Use { type: "inline", item: { type, name, system } } to create the item directly. The { type: "compendium", compendiumId, itemId } shape is accepted by the schema but rejected at call time - compendium-source create is not yet supported over Socket.IO.',
211
231
  properties: {
212
232
  type: {
213
233
  type: 'string',
214
234
  enum: ['compendium', 'inline'],
215
- description: 'Source kind',
235
+ description: 'Source kind. Only "inline" is functional today; "compendium" is rejected at call time.',
216
236
  },
217
237
  compendiumId: {
218
238
  type: 'string',
@@ -235,7 +255,8 @@ export const itemMutationTools = [
235
255
  },
236
256
  {
237
257
  name: 'update_actor_item',
238
- description: "Apply a JSON merge patch to an item's system data on an actor (requires FOUNDRY_WRITE_ENABLED + active Socket.IO connection). Supports nested paths such as activities.{id}.consumption.targets. Canonical target: D&D 5e v4+ activity schema.",
258
+ description: "Apply a JSON merge patch to an item's system data on an actor: nested paths such as activities.{id}.consumption.targets are supported, values are absolute (arrays replace, null deletes). Use when: changing fields on an item the actor already owns, given actorId + itemId. Do not use when: adding a new item (create_actor_item) or removing one (delete_actor_item). Canonical target: D&D 5e v4+ activity schema. " +
259
+ WRITE_GATE,
239
260
  inputSchema: {
240
261
  type: 'object',
241
262
  properties: {
@@ -257,7 +278,10 @@ export const itemMutationTools = [
257
278
  },
258
279
  {
259
280
  name: 'delete_actor_item',
260
- description: 'Delete an item owned by an actor (requires FOUNDRY_WRITE_ENABLED + active Socket.IO connection). Canonical target: D&D 5e v4+ activity schema.',
281
+ description: "Permanently remove an item owned by an actor. Use when: the user explicitly asks to delete or discard a specific owned item, and has given you the itemId - no tool in this server lists owned-item ids, so never guess one. Do not use when: only the item's data needs to change - use update_actor_item. In a replacement or migration flow, run create_actor_item first and this second: the two calls are not atomic, and failing after the delete loses the item. Echo the actorId and itemId back to the user and get their confirmation before calling. " +
282
+ CONFIRM_FIRST +
283
+ ' ' +
284
+ WRITE_GATE,
261
285
  inputSchema: {
262
286
  type: 'object',
263
287
  properties: {
@@ -280,7 +304,7 @@ export const itemMutationTools = [
280
304
  export const sceneTools = [
281
305
  {
282
306
  name: 'get_scene_info',
283
- description: 'Get information about the current or specified scene',
307
+ description: "Get details of the active scene, or of a specific scene by id: name, scene id, active/navigation flags, pixel dimensions, padding and lighting (global light, darkness); no description text is returned unless a module has set a description flag on the scene (the description line otherwise reads 'No description available.'). Use when: you need the sceneId or the scene's pixel extents. Do not use when: looking a scene up by name (use search_world), or you need grid size or token coordinates - this tool returns neither.",
284
308
  inputSchema: {
285
309
  type: 'object',
286
310
  properties: {
@@ -298,7 +322,7 @@ export const sceneTools = [
298
322
  export const generationTools = [
299
323
  {
300
324
  name: 'generate_npc',
301
- description: 'Generate a random NPC with stats and background',
325
+ description: 'Generate a random NPC (name, race, class, HP, ability scores, background) as text. Use when: the user needs a throwaway NPC on the spot. Do not use when: the NPC must exist in FoundryVTT - this creates no documents, and the result still has to be entered into the world by hand.',
302
326
  inputSchema: {
303
327
  type: 'object',
304
328
  properties: {
@@ -322,7 +346,7 @@ export const generationTools = [
322
346
  },
323
347
  {
324
348
  name: 'generate_loot',
325
- description: 'Generate random loot for encounters',
349
+ description: "Generate random treasure for an encounter as text. Only the currency amounts vary: they scale with the challenge rating, while the item list is fixed (a Healing Potion and a Silver Ring) and the treasureType argument is accepted but not used. Use when: the user wants a quick coin total for an encounter. Do not use when: the loot should end up in an actor's inventory - this creates no documents; use create_actor_item for that.",
326
350
  inputSchema: {
327
351
  type: 'object',
328
352
  properties: {
@@ -334,14 +358,14 @@ export const generationTools = [
334
358
  },
335
359
  treasureType: {
336
360
  type: 'string',
337
- description: 'Type of treasure (hoard, individual, etc.)',
361
+ description: 'Type of treasure (hoard, individual, etc.). Accepted but not used - the generated result is the same whichever value is passed.',
338
362
  },
339
363
  },
340
364
  },
341
365
  },
342
366
  {
343
367
  name: 'lookup_rule',
344
- description: 'Look up game rules and mechanics',
368
+ description: 'Stub: builds a templated placeholder from the query and consults no rules source, so the text it returns carries no rules content. No tool in this server looks rules up.',
345
369
  inputSchema: {
346
370
  type: 'object',
347
371
  properties: {
@@ -364,7 +388,7 @@ export const generationTools = [
364
388
  export const diagnosticsTools = [
365
389
  {
366
390
  name: 'get_recent_logs',
367
- description: 'Get recent log entries from FoundryVTT',
391
+ description: 'Get recent FoundryVTT server log entries, optionally filtered by level or since a timestamp. Use when: investigating an error or recent server behaviour. Do not use when: you have a specific term to look for - use search_logs. Requires the REST API module (FOUNDRY_API_KEY); fails without it.',
368
392
  inputSchema: {
369
393
  type: 'object',
370
394
  properties: {
@@ -389,7 +413,7 @@ export const diagnosticsTools = [
389
413
  },
390
414
  {
391
415
  name: 'search_logs',
392
- description: 'Search through FoundryVTT logs',
416
+ description: 'Search the FoundryVTT server logs for a query string and list the matching entries. Use when: hunting a specific error message, stack trace, or module name. Do not use when: you just want the latest entries - use get_recent_logs. The reported match count is the server\'s total for the query, while limit caps how many of those entries are rendered (default 50, hard cap 1000). Level filtering accepts info, warn and error; "debug" is not a level this log store records, so it is reported back as unsupported and no level filter is applied. Requires the REST API module (FOUNDRY_API_KEY); fails without it.',
393
417
  inputSchema: {
394
418
  type: 'object',
395
419
  properties: {
@@ -399,12 +423,12 @@ export const diagnosticsTools = [
399
423
  },
400
424
  level: {
401
425
  type: 'string',
402
- description: 'Log level filter',
426
+ description: 'Log level filter; "debug" is not recorded by this log store and is not applied',
403
427
  enum: ['debug', 'info', 'warn', 'error'],
404
428
  },
405
429
  limit: {
406
430
  type: 'number',
407
- description: 'Maximum number of results',
431
+ description: 'Maximum number of matched entries to render (capped at 1000)',
408
432
  default: 50,
409
433
  },
410
434
  },
@@ -413,7 +437,7 @@ export const diagnosticsTools = [
413
437
  },
414
438
  {
415
439
  name: 'get_system_health',
416
- description: 'Get system health and performance metrics',
440
+ description: "Get the FoundryVTT server's health report: the overall status (healthy, warning, or critical), FoundryVTT and game-system versions, world id and uptime, active/total user counts with the number of GMs, active/installed module counts, connected clients, heap and RSS memory, and the log buffer size with recent error/warning counts and error rate. CPU and disk are not reported - the diagnostics response models no such fields - and the uptime and memory lines are omitted when the server does not supply them. Use when: you want the server's own view of its health. Do not use when: you also want connection and world status - use get_health_status. Requires the REST API module (FOUNDRY_API_KEY); fails without it.",
417
441
  inputSchema: {
418
442
  type: 'object',
419
443
  properties: {},
@@ -421,7 +445,7 @@ export const diagnosticsTools = [
421
445
  },
422
446
  {
423
447
  name: 'diagnose_errors',
424
- description: 'Stub: returns raw logs without analysis. Full diagnostic logic is tracked in #133 and not yet implemented.',
448
+ description: 'Stub: returns a fixed "no errors detected" summary regardless of input; real diagnostic logic is not implemented, so the summary reflects nothing about the server. For actual log content use get_recent_logs.',
425
449
  inputSchema: {
426
450
  type: 'object',
427
451
  properties: {
@@ -434,7 +458,7 @@ export const diagnosticsTools = [
434
458
  },
435
459
  {
436
460
  name: 'get_health_status',
437
- description: 'Get comprehensive health status of FoundryVTT server',
461
+ description: "Get a combined health report: MCP-to-FoundryVTT connection state, world title/system/core version, and the server's health status with its active/total user counts, uptime, heap memory and recent error/warning counts. The world section is prefixed with a stale marker when the cached snapshot stopped following live document changes - typically a dropped connection, whose missed updates are never replayed - and refresh_world_data resyncs it. The connection line is a live read of the socket on the default Socket.IO transport, so it follows a link that drops or comes back in both directions; with FOUNDRY_API_KEY set there is no socket and it reports the outcome of the last REST request instead, not a live probe, so a server that went away between requests still reads as connected until the next request fails. Uptime and memory are omitted when the server does not report them; CPU, disk and playtime are not reported at all. Degrades gracefully - sections that need the REST API module (FOUNDRY_API_KEY) report as unavailable rather than failing. Use when: first checking which world is loaded and whether the server reports itself healthy.",
438
462
  inputSchema: {
439
463
  type: 'object',
440
464
  properties: {},
@@ -447,7 +471,7 @@ export const diagnosticsTools = [
447
471
  export const combatTools = [
448
472
  {
449
473
  name: 'get_combat_state',
450
- description: 'Get the current active combat state including initiative order, HP, and AC',
474
+ description: "Get the active combat encounter: initiative order with each combatant's name, initiative, HP and AC, plus the current round and which combatant is up. Use when: reporting whose turn it is, or checking whether a combat is already running before start_combat. Do not use when: you need a combatantId for set_initiative - this prints names and ordinals, not ids; read the foundry://combat resource, whose JSON includes each combatant's _id and lists combatants in this same initiative order, so the Nth entry printed here is that resource's combatants[N-1] and combat.turn indexes it directly.",
451
475
  inputSchema: {
452
476
  type: 'object',
453
477
  properties: {},
@@ -464,9 +488,8 @@ export const combatTools = [
464
488
  export const combatMutationTools = [
465
489
  {
466
490
  name: 'next_turn',
467
- description: 'Advance the active combat to the next turn, wrapping to the next round after the last combatant. ' +
468
- 'When skipDefeated is true, defeated combatants are skipped. ' +
469
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
491
+ description: 'Advance the active combat to the next turn, wrapping to the next round after the last combatant. When skipDefeated is true, defeated combatants are skipped. Use when: the current combatant has finished their turn. Do not use when: only reporting the turn order - use get_combat_state. ' +
492
+ WRITE_GATE,
470
493
  inputSchema: {
471
494
  type: 'object',
472
495
  properties: {
@@ -479,8 +502,10 @@ export const combatMutationTools = [
479
502
  },
480
503
  {
481
504
  name: 'end_combat',
482
- description: 'End (delete) the active combat encounter. ' +
483
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
505
+ description: 'End the active combat encounter by deleting its Combat document, discarding the initiative order and round count. Use when: the fight is over and the user asks to end the encounter. ' +
506
+ CONFIRM_FIRST +
507
+ ' ' +
508
+ WRITE_GATE,
484
509
  inputSchema: {
485
510
  type: 'object',
486
511
  properties: {},
@@ -488,8 +513,8 @@ export const combatMutationTools = [
488
513
  },
489
514
  {
490
515
  name: 'set_initiative',
491
- description: "Set a combatant's initiative in the active combat. " +
492
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
516
+ description: "Set a combatant's initiative in the active combat (or in combatId when given), reordering the turn order. When that reorder moves the combatant who is currently acting to a different position, the encounter's turn index is rewritten to follow them - whoever was up stays up, and the result says so - rather than leaving the marker on whoever slid into the old slot. That follow-up applies only to the active combat: a combatId naming some other encounter still records the initiative, but its turn order is not readable here and is left alone. Use when: an initiative roll needs to be recorded or corrected for a known combatantId. Do not use when: simply moving on to the next combatant - use next_turn. " +
517
+ WRITE_GATE,
493
518
  inputSchema: {
494
519
  type: 'object',
495
520
  properties: {
@@ -511,10 +536,8 @@ export const combatMutationTools = [
511
536
  },
512
537
  {
513
538
  name: 'start_combat',
514
- description: 'Start a new combat encounter, seeding combatants from tokens. ' +
515
- 'Provide explicit tokenIds, or omit them to seed every token on the scene. ' +
516
- 'Defaults to the active scene when sceneId is omitted. ' +
517
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection (GM permission).',
539
+ description: 'Start a new combat encounter, seeding combatants from tokens: pass explicit tokenIds, or omit them to seed every token on the scene. Defaults to the active scene when sceneId is omitted. Use when: a fight begins and no combat is running. Do not use when: a combat is already active - check get_combat_state first, since this always creates an additional encounter. ' +
540
+ WRITE_GATE,
518
541
  inputSchema: {
519
542
  type: 'object',
520
543
  properties: {
@@ -541,9 +564,8 @@ export const combatMutationTools = [
541
564
  export const tokenMutationTools = [
542
565
  {
543
566
  name: 'move_token',
544
- description: 'Move a token to new x/y pixel coordinates on its scene. ' +
545
- 'The token is located across scenes by id (optionally scoped with sceneId). ' +
546
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
567
+ description: "Move a token to new x/y pixel coordinates on its scene; the token is located across scenes by id, optionally scoped with sceneId. Coordinates are absolute pixels, not grid squares and not offsets. Use when: repositioning a token to a position the user has given you. Do not use when: you would have to guess the destination - no tool in this server reports a token's current position or the scene grid size, so ask the user for the target coordinates rather than inferring them. " +
568
+ WRITE_GATE,
547
569
  inputSchema: {
548
570
  type: 'object',
549
571
  properties: {
@@ -569,9 +591,9 @@ export const tokenMutationTools = [
569
591
  },
570
592
  {
571
593
  name: 'apply_status_effect',
572
- description: "Apply or remove a status condition (e.g. 'prone', 'stunned') on a token's actor. " +
573
- 'Set active=false to remove. Matches by status id, so re-applying or clearing-when-absent is a no-op. ' +
574
- 'Requires FOUNDRY_WRITE_ENABLED=true and an active Socket.IO connection.',
594
+ description: 'Apply or remove a status condition (e.g. "prone", "stunned") on a token\'s actor. Set active=false to remove. Matches by status id, so re-applying or clearing-when-absent is a no-op. Use when: a condition is gained or lost. Do not use when: changing numeric state such as HP or exhaustion - use update_actor_attributes. ' +
595
+ WRITE_GATE +
596
+ ' Exception: the no-op cases (applying an already-present status, or clearing an absent one) report success without attempting a write, so they also return normally while writes are disabled.',
575
597
  inputSchema: {
576
598
  type: 'object',
577
599
  properties: {
@@ -603,7 +625,7 @@ export const tokenMutationTools = [
603
625
  export const chatTools = [
604
626
  {
605
627
  name: 'get_chat_messages',
606
- description: 'Get recent chat messages from the game',
628
+ description: 'Get the most recent chat messages from the game log. Use when: you need recent in-game context - what players said, or roll results that already happened.',
607
629
  inputSchema: {
608
630
  type: 'object',
609
631
  properties: {
@@ -624,7 +646,7 @@ export const chatTools = [
624
646
  export const userTools = [
625
647
  {
626
648
  name: 'get_users',
627
- description: 'Get the list of users with their online status and roles',
649
+ description: "List the world's users with their roles and online status. Online status is live while the Socket.IO connection is up: FoundryVTT's userActivity broadcasts are applied to the cached presence list as users connect and disconnect. It stops tracking if that connection drops and the missed changes are not replayed - get_health_status shows the snapshot as stale, and refresh_world_data resyncs it. Use when: you need to know which user holds the GM role, or who is connected right now.",
628
650
  inputSchema: {
629
651
  type: 'object',
630
652
  properties: {},
@@ -637,7 +659,7 @@ export const userTools = [
637
659
  export const journalTools = [
638
660
  {
639
661
  name: 'search_journals',
640
- description: 'Search journal entries by name or content',
662
+ description: 'Search journal entries by name and page content. Use when: looking for notes, lore, or handouts by keyword. Do not use when: you already have the journalId - use get_journal.',
641
663
  inputSchema: {
642
664
  type: 'object',
643
665
  properties: {
@@ -656,7 +678,7 @@ export const journalTools = [
656
678
  },
657
679
  {
658
680
  name: 'get_journal',
659
- description: 'Get a specific journal entry with its pages',
681
+ description: 'Get one journal entry by id with the text of its pages. Page bodies are HTML-stripped and each is truncated to its first 500 characters, marked with a trailing "...", so long pages come back partial. Use when: you have a journalId and need the text of its pages. Do not use when: you only have a title or keyword - run search_journals first.',
660
682
  inputSchema: {
661
683
  type: 'object',
662
684
  properties: {
@@ -675,7 +697,8 @@ export const journalTools = [
675
697
  export const journalMutationTools = [
676
698
  {
677
699
  name: 'create_journal_entry',
678
- description: 'Create a new journal entry with one or more text pages (requires FOUNDRY_WRITE_ENABLED=true + active Socket.IO connection). Defaults to GM-only visibility — pass visibility to let players read it.',
700
+ description: 'Create a new journal entry with one or more text pages, optionally filed under a folder. Defaults to GM-only visibility - pass visibility to let players read it. Use when: recording session notes, lore, or a handout in the world. Do not use when: adding text to an existing entry - this always creates a new one. ' +
701
+ WRITE_GATE,
679
702
  inputSchema: {
680
703
  type: 'object',
681
704
  properties: {
@@ -722,7 +745,7 @@ export const journalMutationTools = [
722
745
  export const worldTools = [
723
746
  {
724
747
  name: 'search_world',
725
- description: 'Search across all collections (actors, items, scenes, journals) by name',
748
+ description: 'Search across all collections (actors, items, scenes, journals) by name, grouped by collection. Use when: you do not know which collection holds what you are looking for. Do not use when: you already know the collection - use search_actors, search_items, or search_journals. Of those, only search_journals prints document ids; for actor and item ids read the foundry://actors and foundry://items resources, each of which lists up to the first 100 documents (not exhaustive in larger worlds).',
726
749
  inputSchema: {
727
750
  type: 'object',
728
751
  properties: {
@@ -741,7 +764,7 @@ export const worldTools = [
741
764
  },
742
765
  {
743
766
  name: 'get_world_summary',
744
- description: 'Get world metadata and collection counts',
767
+ description: 'Get world metadata (title, game system, core version) and per-collection document counts. Use when: orienting yourself in an unfamiliar world, or confirming the game system before system-specific edits.',
745
768
  inputSchema: {
746
769
  type: 'object',
747
770
  properties: {},
@@ -749,7 +772,7 @@ export const worldTools = [
749
772
  },
750
773
  {
751
774
  name: 'refresh_world_data',
752
- description: 'Force re-fetch of world data from the FoundryVTT server',
775
+ description: 'Force a re-fetch of the cached world data from the FoundryVTT server. Reads are normally served from a cache that follows live document changes for as long as the connection holds, so this is rarely needed. Use when: the connection dropped and came back - the cache stopped following changes while it was down and nothing replays them, so it stays a point-in-time copy until this runs, and get_health_status flags it as stale until then; or a read still looks stale after an out-of-band change - notably edits to unlinked (synthetic) token actors, which the live update feed does not cover. Refreshes the cache only; it does not modify the world.',
753
776
  inputSchema: {
754
777
  type: 'object',
755
778
  properties: {},
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2DAA2D;QACxE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sCAAsC;iBACpD;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0CAA0C;iBACxD;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qCAAqC;oBAClD,OAAO,EAAE,EAAE;iBACZ;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,iDAAiD;QAC9D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE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AAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpF,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,8DAA8D;QAC9D,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -15,6 +15,10 @@ import type { WorldCombat } from '../../foundry/types.js';
15
15
  * Advances to the next combatant in order; wrapping past the last combatant
16
16
  * rolls over to turn 0 of the next round.
17
17
  *
18
+ * `Combat#turn` is an index into the **initiative-sorted** turn order (see
19
+ * `combat-order.ts`), *not* into the stored/creation order of
20
+ * `combat.combatants` — the same order `get_combat_state` renders (#214).
21
+ *
18
22
  * When `skipDefeated` is true, `defeated` combatants are skipped — mirroring
19
23
  * Foundry's `Combat#nextTurn`/`nextRound` with the `skipDefeated` setting. If
20
24
  * every combatant is defeated, the round still advances (turn 0), matching
@@ -54,6 +58,16 @@ export declare function handleEndCombat(_args: Record<string, unknown>, foundryC
54
58
  * Sets a combatant's initiative in the active combat (FR-018).
55
59
  *
56
60
  * `combatId` defaults to the active combat when omitted.
61
+ *
62
+ * Writing an initiative re-sorts the turn order underneath the stored
63
+ * `Combat#turn`, which indexes that order (#214) — so a different combatant can
64
+ * slide under the stored index. FoundryVTT's `Combat#setupTurns` re-finds the
65
+ * combatant that was acting and re-points `turn` at its new index; this handler
66
+ * mirrors that, so the MCP and Foundry never disagree about whose turn it is
67
+ * after an initiative correction. The re-anchor is skipped when there is
68
+ * nothing to anchor: no combatant is acting yet (round-0 setup, `turn` null, or
69
+ * a stale index), the acting combatant's index is unchanged, or the write
70
+ * targets a combat other than the active one (the only one readable here).
57
71
  */
58
72
  export declare function handleSetInitiative(args: {
59
73
  combatantId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"combat-mutations.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/combat-mutations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAUtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,YAAY,UAAQ,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAwBjC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,EAChC,aAAa,EAAE,aAAa;;;;;GA4B7B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,aAAa,EAAE,aAAa;;;;;GAqB7B;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACpE,aAAa,EAAE,aAAa;;;;;GAqC7B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/C,aAAa,EAAE,aAAa;;;;;GAyD7B"}
1
+ {"version":3,"file":"combat-mutations.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/combat-mutations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAetE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,YAAY,UAAQ,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAwBjC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,EAChC,aAAa,EAAE,aAAa;;;;;GA4B7B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,aAAa,EAAE,aAAa;;;;;GAqB7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACpE,aAAa,EAAE,aAAa;;;;;GAqD7B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/C,aAAa,EAAE,aAAa;;;;;GAyD7B"}
@@ -8,6 +8,7 @@
8
8
  * protocol), and the connected user needs GM/owner permission.
9
9
  */
10
10
  import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
11
+ import { getCurrentCombatant, getTurnOrder, turnIndexAfterInitiativeChange, } from './combat-order.js';
11
12
  import { withToolError } from './utils.js';
12
13
  /**
13
14
  * Computes the next `{ turn, round }` for an active combat.
@@ -15,6 +16,10 @@ import { withToolError } from './utils.js';
15
16
  * Advances to the next combatant in order; wrapping past the last combatant
16
17
  * rolls over to turn 0 of the next round.
17
18
  *
19
+ * `Combat#turn` is an index into the **initiative-sorted** turn order (see
20
+ * `combat-order.ts`), *not* into the stored/creation order of
21
+ * `combat.combatants` — the same order `get_combat_state` renders (#214).
22
+ *
18
23
  * When `skipDefeated` is true, `defeated` combatants are skipped — mirroring
19
24
  * Foundry's `Combat#nextTurn`/`nextRound` with the `skipDefeated` setting. If
20
25
  * every combatant is defeated, the round still advances (turn 0), matching
@@ -23,7 +28,7 @@ import { withToolError } from './utils.js';
23
28
  * @throws if the combat has no combatants (cannot advance an empty encounter).
24
29
  */
25
30
  export function computeNextTurn(combat, skipDefeated = false) {
26
- const combatants = combat.combatants;
31
+ const combatants = getTurnOrder(combat);
27
32
  const n = combatants.length;
28
33
  if (n === 0) {
29
34
  throw new Error('Cannot advance turn: active combat has no combatants');
@@ -60,7 +65,7 @@ export async function handleNextTurn(args, foundryClient) {
60
65
  return withToolError('advance combat turn', async () => {
61
66
  const { turn, round } = computeNextTurn(combat, skipDefeated);
62
67
  await foundryClient.updateCombat(combat._id, { turn, round });
63
- const current = combat.combatants[turn];
68
+ const current = getTurnOrder(combat)[turn];
64
69
  const currentName = current ? current.name : 'unknown';
65
70
  return {
66
71
  content: [
@@ -101,6 +106,16 @@ The active combat encounter has been removed.`,
101
106
  * Sets a combatant's initiative in the active combat (FR-018).
102
107
  *
103
108
  * `combatId` defaults to the active combat when omitted.
109
+ *
110
+ * Writing an initiative re-sorts the turn order underneath the stored
111
+ * `Combat#turn`, which indexes that order (#214) — so a different combatant can
112
+ * slide under the stored index. FoundryVTT's `Combat#setupTurns` re-finds the
113
+ * combatant that was acting and re-points `turn` at its new index; this handler
114
+ * mirrors that, so the MCP and Foundry never disagree about whose turn it is
115
+ * after an initiative correction. The re-anchor is skipped when there is
116
+ * nothing to anchor: no combatant is acting yet (round-0 setup, `turn` null, or
117
+ * a stale index), the acting combatant's index is unchanged, or the write
118
+ * targets a combat other than the active one (the only one readable here).
104
119
  */
105
120
  export async function handleSetInitiative(args, foundryClient) {
106
121
  const { combatantId, initiative, combatId } = args;
@@ -110,12 +125,26 @@ export async function handleSetInitiative(args, foundryClient) {
110
125
  if (typeof initiative !== 'number' || !Number.isFinite(initiative)) {
111
126
  throw new McpError(ErrorCode.InvalidParams, 'initiative is required and must be a finite number');
112
127
  }
113
- const resolvedCombatId = combatId ?? foundryClient.getCombatState()?._id;
128
+ const activeCombat = foundryClient.getCombatState();
129
+ const resolvedCombatId = combatId ?? activeCombat?._id;
114
130
  if (!resolvedCombatId) {
115
131
  throw new McpError(ErrorCode.InvalidRequest, 'No active combat and no combatId provided; cannot set initiative.');
116
132
  }
133
+ // Only the active combat is readable from the world-data cache, so only its
134
+ // turn order can be recomputed. Capture who is acting BEFORE the write.
135
+ const combat = activeCombat?._id === resolvedCombatId ? activeCombat : undefined;
136
+ const acting = combat ? getCurrentCombatant(combat) : undefined;
117
137
  return withToolError('set combatant initiative', async () => {
118
138
  await foundryClient.setCombatantInitiative(resolvedCombatId, combatantId, initiative);
139
+ let reanchored = '';
140
+ if (combat && acting) {
141
+ const turn = turnIndexAfterInitiativeChange(combat, { combatantId, initiative }, acting._id);
142
+ if (turn !== undefined && turn !== combat.turn) {
143
+ await foundryClient.updateCombat(resolvedCombatId, { turn });
144
+ reanchored = `
145
+ **Still acting:** ${acting.name} (turn ${turn + 1} of ${combat.combatants.length})`;
146
+ }
147
+ }
119
148
  return {
120
149
  content: [
121
150
  {
@@ -123,7 +152,7 @@ export async function handleSetInitiative(args, foundryClient) {
123
152
  text: `⚔️ **Initiative Set**
124
153
  **Combat:** ${resolvedCombatId}
125
154
  **Combatant:** ${combatantId}
126
- **Initiative:** ${initiative}`,
155
+ **Initiative:** ${initiative}${reanchored}`,
127
156
  },
128
157
  ],
129
158
  };
@@ -1 +1 @@
1
- {"version":3,"file":"combat-mutations.js","sourceRoot":"","sources":["../../../src/tools/handlers/combat-mutations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CA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