run-dmcp 0.3.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.
@@ -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;