run-dmcp 0.2.0 → 0.4.0

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 (59) hide show
  1. package/README.md +51 -13
  2. package/dist/bin/run-dmcp.js +1 -1
  3. package/dist/db/schema.js +170 -18
  4. package/dist/http/server.js +22 -1
  5. package/dist/index.d.ts +34 -2
  6. package/dist/index.js +86 -2
  7. package/dist/mcp-server.d.ts +1 -1
  8. package/dist/mcp-server.js +1 -1
  9. package/dist/register/resources.js +2 -2
  10. package/dist/rpg/index.d.ts +0 -16
  11. package/dist/rpg/index.js +4 -22
  12. package/dist/rpg/server.d.ts +16 -0
  13. package/dist/rpg/server.js +22 -0
  14. package/dist/schemas/index.d.ts +62 -62
  15. package/dist/server.d.ts +1 -0
  16. package/dist/server.js +20 -0
  17. package/dist/timeline/changes.d.ts +8 -0
  18. package/dist/timeline/changes.js +8 -0
  19. package/dist/timeline/export.d.ts +10 -0
  20. package/dist/timeline/export.js +10 -0
  21. package/dist/timeline/irreversible.d.ts +2 -0
  22. package/dist/timeline/replay.d.ts +22 -0
  23. package/dist/timeline/replay.js +22 -0
  24. package/dist/timeline/schema.js +2 -0
  25. package/dist/tools/audio.js +13 -9
  26. package/dist/tools/game.js +33 -1
  27. package/dist/tools/images.js +17 -10
  28. package/dist/tools/resource.d.ts +2 -2
  29. package/dist/tools/time.js +18 -3
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/utils/media-path.d.ts +52 -0
  32. package/dist/utils/media-path.js +106 -0
  33. package/dist/utils/output-schemas.d.ts +63 -63
  34. package/dist/utils/output-schemas.js +1 -1
  35. package/package.json +14 -2
  36. package/dist/register/abilities.d.ts +0 -2
  37. package/dist/register/abilities.js +0 -165
  38. package/dist/register/combat.d.ts +0 -2
  39. package/dist/register/combat.js +0 -207
  40. package/dist/register/mcp-prompts.d.ts +0 -2
  41. package/dist/register/mcp-prompts.js +0 -684
  42. package/dist/register/quests.d.ts +0 -2
  43. package/dist/register/quests.js +0 -118
  44. package/dist/register/status.d.ts +0 -2
  45. package/dist/register/status.js +0 -130
  46. package/dist/register/tables.d.ts +0 -2
  47. package/dist/register/tables.js +0 -146
  48. package/dist/tools/ability.d.ts +0 -48
  49. package/dist/tools/ability.js +0 -238
  50. package/dist/tools/combat.d.ts +0 -13
  51. package/dist/tools/combat.js +0 -195
  52. package/dist/tools/dice.d.ts +0 -23
  53. package/dist/tools/dice.js +0 -111
  54. package/dist/tools/quest.d.ts +0 -34
  55. package/dist/tools/quest.js +0 -164
  56. package/dist/tools/status.d.ts +0 -36
  57. package/dist/tools/status.js +0 -218
  58. package/dist/tools/tables.d.ts +0 -33
  59. package/dist/tools/tables.js +0 -209
@@ -1,165 +0,0 @@
1
- import { z } from "zod";
2
- import * as abilityTools from "../tools/ability.js";
3
- import { LIMITS } from "../utils/validation.js";
4
- import { ANNOTATIONS } from "../utils/tool-annotations.js";
5
- export function registerAbilityTools(server) {
6
- server.registerTool("create_ability", {
7
- description: "Create an ability template or character-owned ability",
8
- inputSchema: {
9
- gameId: z.string().max(100).describe("The game ID"),
10
- ownerType: z.enum(["template", "character"]).describe("'template' for reusable, 'character' for owned"),
11
- ownerId: z.string().max(100).optional().describe("Character ID if ownerType is 'character'"),
12
- name: z.string().min(1).max(LIMITS.NAME_MAX).describe("Ability name"),
13
- description: z.string().max(LIMITS.DESCRIPTION_MAX).optional().describe("Ability description"),
14
- category: z.string().max(100).optional().describe("Category (e.g., 'spell', 'skill', 'power')"),
15
- cost: z.record(z.number()).optional().describe("Resource costs (e.g., {mana: 10, stamina: 5})"),
16
- cooldown: z.number().optional().describe("Cooldown in rounds"),
17
- effects: z.array(z.string().max(LIMITS.DESCRIPTION_MAX)).max(LIMITS.ARRAY_MAX).optional().describe("Effect descriptions"),
18
- requirements: z.record(z.number()).optional().describe("Requirements (e.g., {level: 5, strength: 10})"),
19
- tags: z.array(z.string().max(LIMITS.NAME_MAX)).max(LIMITS.ARRAY_MAX).optional().describe("Tags for categorization"),
20
- },
21
- annotations: ANNOTATIONS.CREATE,
22
- }, async (params) => {
23
- const ability = abilityTools.createAbility(params);
24
- return {
25
- content: [{ type: "text", text: JSON.stringify(ability, null, 2) }],
26
- };
27
- });
28
- server.registerTool("get_ability", {
29
- description: "Get an ability by ID",
30
- inputSchema: {
31
- abilityId: z.string().max(100).describe("The ability ID"),
32
- },
33
- annotations: ANNOTATIONS.READ_ONLY,
34
- }, async ({ abilityId }) => {
35
- const ability = abilityTools.getAbility(abilityId);
36
- if (!ability) {
37
- return {
38
- content: [{ type: "text", text: "Ability not found" }],
39
- isError: true,
40
- };
41
- }
42
- return {
43
- content: [{ type: "text", text: JSON.stringify(ability, null, 2) }],
44
- };
45
- });
46
- server.registerTool("update_ability", {
47
- description: "Update an ability's details",
48
- inputSchema: {
49
- abilityId: z.string().max(100).describe("The ability ID"),
50
- name: z.string().max(LIMITS.NAME_MAX).optional().describe("New name"),
51
- description: z.string().max(LIMITS.DESCRIPTION_MAX).optional().describe("New description"),
52
- category: z.string().max(100).nullable().optional().describe("New category"),
53
- cost: z.record(z.number()).optional().describe("New cost"),
54
- cooldown: z.number().nullable().optional().describe("New cooldown"),
55
- effects: z.array(z.string().max(LIMITS.DESCRIPTION_MAX)).max(LIMITS.ARRAY_MAX).optional().describe("New effects"),
56
- requirements: z.record(z.number()).optional().describe("New requirements"),
57
- tags: z.array(z.string().max(LIMITS.NAME_MAX)).max(LIMITS.ARRAY_MAX).optional().describe("New tags"),
58
- },
59
- annotations: ANNOTATIONS.UPDATE,
60
- }, async ({ abilityId, ...updates }) => {
61
- const ability = abilityTools.updateAbility(abilityId, updates);
62
- if (!ability) {
63
- return {
64
- content: [{ type: "text", text: "Ability not found" }],
65
- isError: true,
66
- };
67
- }
68
- return {
69
- content: [{ type: "text", text: JSON.stringify(ability, null, 2) }],
70
- };
71
- });
72
- server.registerTool("delete_ability", {
73
- description: "Delete an ability",
74
- inputSchema: {
75
- abilityId: z.string().max(100).describe("The ability ID"),
76
- },
77
- annotations: ANNOTATIONS.DESTRUCTIVE,
78
- }, async ({ abilityId }) => {
79
- const success = abilityTools.deleteAbility(abilityId);
80
- return {
81
- content: [{ type: "text", text: success ? "Ability deleted" : "Ability not found" }],
82
- isError: !success,
83
- };
84
- });
85
- server.registerTool("list_abilities", {
86
- description: "List abilities with optional filters",
87
- inputSchema: {
88
- gameId: z.string().max(100).describe("The game ID"),
89
- ownerType: z.enum(["template", "character"]).optional().describe("Filter by owner type"),
90
- ownerId: z.string().max(100).optional().describe("Filter by owner ID"),
91
- category: z.string().max(100).optional().describe("Filter by category"),
92
- },
93
- annotations: ANNOTATIONS.READ_ONLY,
94
- }, async ({ gameId, ...filter }) => {
95
- const abilities = abilityTools.listAbilities(gameId, filter);
96
- return {
97
- content: [{ type: "text", text: JSON.stringify(abilities, null, 2) }],
98
- };
99
- });
100
- server.registerTool("learn_ability", {
101
- description: "Copy a template ability to a character",
102
- inputSchema: {
103
- templateId: z.string().max(100).describe("The template ability ID"),
104
- characterId: z.string().max(100).describe("The character ID to learn the ability"),
105
- },
106
- annotations: ANNOTATIONS.CREATE,
107
- }, async ({ templateId, characterId }) => {
108
- const ability = abilityTools.learnAbility(templateId, characterId);
109
- if (!ability) {
110
- return {
111
- content: [{ type: "text", text: "Template not found or is not a template" }],
112
- isError: true,
113
- };
114
- }
115
- return {
116
- content: [{ type: "text", text: JSON.stringify(ability, null, 2) }],
117
- };
118
- });
119
- server.registerTool("use_ability", {
120
- description: "Use an ability (checks cooldown, sets new cooldown)",
121
- inputSchema: {
122
- abilityId: z.string().max(100).describe("The ability ID"),
123
- characterId: z.string().max(100).describe("The character using the ability"),
124
- },
125
- annotations: ANNOTATIONS.UPDATE,
126
- }, async ({ abilityId, characterId }) => {
127
- const result = abilityTools.useAbility(abilityId, characterId);
128
- return {
129
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
130
- isError: !result.success,
131
- };
132
- });
133
- server.registerTool("tick_ability_cooldowns", {
134
- description: "Reduce all ability cooldowns (call at end of round)",
135
- inputSchema: {
136
- gameId: z.string().max(100).describe("The game ID"),
137
- amount: z.number().optional().describe("Rounds to tick (default: 1)"),
138
- },
139
- annotations: ANNOTATIONS.UPDATE,
140
- }, async ({ gameId, amount }) => {
141
- const updated = abilityTools.tickCooldowns(gameId, amount);
142
- return {
143
- content: [{ type: "text", text: JSON.stringify({ updatedCount: updated.length, abilities: updated }, null, 2) }],
144
- };
145
- });
146
- server.registerTool("check_ability_requirements", {
147
- description: "Check if a character meets an ability's requirements",
148
- inputSchema: {
149
- abilityId: z.string().max(100).describe("The ability ID"),
150
- characterId: z.string().max(100).describe("The character ID"),
151
- },
152
- annotations: ANNOTATIONS.READ_ONLY,
153
- }, async ({ abilityId, characterId }) => {
154
- const result = abilityTools.checkRequirements(abilityId, characterId);
155
- if (!result) {
156
- return {
157
- content: [{ type: "text", text: "Ability or character not found" }],
158
- isError: true,
159
- };
160
- }
161
- return {
162
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
163
- };
164
- });
165
- }
@@ -1,2 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerCombatTools(server: McpServer): void;
@@ -1,207 +0,0 @@
1
- import { z } from "zod";
2
- import * as combatTools from "../tools/combat.js";
3
- import * as diceTools from "../tools/dice.js";
4
- import { LIMITS } from "../utils/validation.js";
5
- import { ANNOTATIONS } from "../utils/tool-annotations.js";
6
- export function registerCombatTools(server) {
7
- // ============================================================================
8
- // DICE & CHECK TOOLS
9
- // ============================================================================
10
- server.registerTool("roll", {
11
- description: "Roll dice using standard notation",
12
- inputSchema: {
13
- expression: z.string().max(100).describe("Dice expression (e.g., '2d6+3', '1d20', '4d6-2')"),
14
- },
15
- annotations: ANNOTATIONS.READ_ONLY,
16
- }, async ({ expression }) => {
17
- try {
18
- const result = diceTools.roll(expression);
19
- return {
20
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
21
- };
22
- }
23
- catch (error) {
24
- return {
25
- content: [{ type: "text", text: error.message }],
26
- isError: true,
27
- };
28
- }
29
- });
30
- server.registerTool("check", {
31
- description: "Perform a skill or ability check",
32
- inputSchema: {
33
- gameId: z.string().max(100).describe("The game ID"),
34
- characterId: z.string().max(100).describe("The character making the check"),
35
- skill: z.string().max(100).optional().describe("Skill to use"),
36
- attribute: z.string().max(100).optional().describe("Attribute to use"),
37
- difficulty: z.number().describe("Difficulty threshold"),
38
- bonusModifier: z.number().optional().describe("Additional modifier"),
39
- },
40
- annotations: ANNOTATIONS.READ_ONLY,
41
- }, async (params) => {
42
- try {
43
- const result = diceTools.check(params);
44
- return {
45
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
46
- };
47
- }
48
- catch (error) {
49
- return {
50
- content: [{ type: "text", text: error.message }],
51
- isError: true,
52
- };
53
- }
54
- });
55
- server.registerTool("contest", {
56
- description: "Opposed check between two characters",
57
- inputSchema: {
58
- gameId: z.string().max(100).describe("The game ID"),
59
- attackerId: z.string().max(100).describe("First character ID"),
60
- defenderId: z.string().max(100).describe("Second character ID"),
61
- attackerSkill: z.string().max(100).optional().describe("Skill for first character"),
62
- defenderSkill: z.string().max(100).optional().describe("Skill for second character"),
63
- attackerAttribute: z.string().max(100).optional().describe("Attribute for first character"),
64
- defenderAttribute: z.string().max(100).optional().describe("Attribute for second character"),
65
- },
66
- annotations: ANNOTATIONS.READ_ONLY,
67
- }, async (params) => {
68
- try {
69
- const result = diceTools.contest(params);
70
- return {
71
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
72
- };
73
- }
74
- catch (error) {
75
- return {
76
- content: [{ type: "text", text: error.message }],
77
- isError: true,
78
- };
79
- }
80
- });
81
- // ============================================================================
82
- // COMBAT TOOLS
83
- // ============================================================================
84
- server.registerTool("start_combat", {
85
- description: "Initialize a combat encounter",
86
- inputSchema: {
87
- gameId: z.string().max(100).describe("The game ID"),
88
- locationId: z.string().max(100).describe("Location where combat occurs"),
89
- participantIds: z.array(z.string().max(100)).max(LIMITS.ARRAY_MAX).describe("Character IDs of all combatants"),
90
- },
91
- annotations: ANNOTATIONS.CREATE,
92
- }, async (params) => {
93
- const combat = combatTools.startCombat(params);
94
- return {
95
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
96
- };
97
- });
98
- server.registerTool("get_combat", {
99
- description: "Get current combat state",
100
- inputSchema: {
101
- combatId: z.string().max(100).describe("The combat ID"),
102
- },
103
- annotations: ANNOTATIONS.READ_ONLY,
104
- }, async ({ combatId }) => {
105
- const combat = combatTools.getCombat(combatId);
106
- if (!combat) {
107
- return {
108
- content: [{ type: "text", text: "Combat not found" }],
109
- isError: true,
110
- };
111
- }
112
- return {
113
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
114
- };
115
- });
116
- server.registerTool("get_active_combat", {
117
- description: "Get the active combat for a game",
118
- inputSchema: {
119
- gameId: z.string().max(100).describe("The game ID"),
120
- },
121
- annotations: ANNOTATIONS.READ_ONLY,
122
- }, async ({ gameId }) => {
123
- const combat = combatTools.getActiveCombat(gameId);
124
- if (!combat) {
125
- return {
126
- content: [{ type: "text", text: "No active combat" }],
127
- };
128
- }
129
- return {
130
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
131
- };
132
- });
133
- server.registerTool("next_turn", {
134
- description: "Advance to the next combatant's turn",
135
- inputSchema: {
136
- combatId: z.string().max(100).describe("The combat ID"),
137
- },
138
- annotations: ANNOTATIONS.UPDATE,
139
- }, async ({ combatId }) => {
140
- const combat = combatTools.nextTurn(combatId);
141
- if (!combat) {
142
- return {
143
- content: [{ type: "text", text: "Combat not found or ended" }],
144
- isError: true,
145
- };
146
- }
147
- return {
148
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
149
- };
150
- });
151
- server.registerTool("add_combat_log", {
152
- description: "Add an entry to the combat log",
153
- inputSchema: {
154
- combatId: z.string().max(100).describe("The combat ID"),
155
- entry: z.string().max(LIMITS.DESCRIPTION_MAX).describe("Log entry text"),
156
- },
157
- annotations: ANNOTATIONS.UPDATE,
158
- }, async ({ combatId, entry }) => {
159
- const combat = combatTools.addCombatLog(combatId, entry);
160
- if (!combat) {
161
- return {
162
- content: [{ type: "text", text: "Combat not found" }],
163
- isError: true,
164
- };
165
- }
166
- return {
167
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
168
- };
169
- });
170
- server.registerTool("remove_combatant", {
171
- description: "Remove a character from combat (defeated, fled, etc.)",
172
- inputSchema: {
173
- combatId: z.string().max(100).describe("The combat ID"),
174
- characterId: z.string().max(100).describe("The character to remove"),
175
- },
176
- annotations: ANNOTATIONS.DESTRUCTIVE,
177
- }, async ({ combatId, characterId }) => {
178
- const combat = combatTools.removeParticipant(combatId, characterId);
179
- if (!combat) {
180
- return {
181
- content: [{ type: "text", text: "Combat not found" }],
182
- isError: true,
183
- };
184
- }
185
- return {
186
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
187
- };
188
- });
189
- server.registerTool("end_combat", {
190
- description: "End a combat encounter",
191
- inputSchema: {
192
- combatId: z.string().max(100).describe("The combat ID"),
193
- },
194
- annotations: ANNOTATIONS.UPDATE,
195
- }, async ({ combatId }) => {
196
- const combat = combatTools.endCombat(combatId);
197
- if (!combat) {
198
- return {
199
- content: [{ type: "text", text: "Combat not found" }],
200
- isError: true,
201
- };
202
- }
203
- return {
204
- content: [{ type: "text", text: JSON.stringify(combat, null, 2) }],
205
- };
206
- });
207
- }
@@ -1,2 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- export declare function registerMcpPrompts(server: McpServer): void;