@pipeworx/mcp-dnd5e 1.0.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.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/package.json +18 -0
- package/src/index.ts +237 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# mcp-dnd5e
|
|
2
|
+
|
|
3
|
+
MCP server for D&D 5th Edition spells, monsters, and classes via [dnd5eapi.co](https://www.dnd5eapi.co). No authentication required.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | Description |
|
|
8
|
+
|------|-------------|
|
|
9
|
+
| `get_spell` | Get full details for a D&D 5e spell by index name |
|
|
10
|
+
| `get_monster` | Get full details for a D&D 5e monster by index name |
|
|
11
|
+
| `get_class` | Get details for a D&D 5e character class by index name |
|
|
12
|
+
| `list_spells` | List all available D&D 5e spells |
|
|
13
|
+
|
|
14
|
+
## Quickstart via Pipeworx Gateway
|
|
15
|
+
|
|
16
|
+
Call any tool through the hosted gateway with zero setup:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
curl -X POST https://gateway.pipeworx.io/mcp \
|
|
20
|
+
-H "Content-Type: application/json" \
|
|
21
|
+
-d '{
|
|
22
|
+
"jsonrpc": "2.0",
|
|
23
|
+
"id": 1,
|
|
24
|
+
"method": "tools/call",
|
|
25
|
+
"params": {
|
|
26
|
+
"name": "dnd5e_get_spell",
|
|
27
|
+
"arguments": { "index": "fireball" }
|
|
28
|
+
}
|
|
29
|
+
}'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-dnd5e",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for D&D 5th Edition spells, monsters, and classes via dnd5eapi.co",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": ["src"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "dnd5e", "dnd", "dungeons-and-dragons", "rpg"],
|
|
13
|
+
"author": "Pipeworx <hello@pipeworx.io>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D&D 5e MCP — wraps the D&D 5th Edition API (free, no auth)
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* - get_spell: Get details for a D&D 5e spell by index name
|
|
6
|
+
* - get_monster: Get details for a D&D 5e monster by index name
|
|
7
|
+
* - get_class: Get details for a D&D 5e class by index name
|
|
8
|
+
* - list_spells: List all available spells
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface McpToolDefinition {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: 'object';
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface McpToolExport {
|
|
22
|
+
tools: McpToolDefinition[];
|
|
23
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const BASE_URL = 'https://www.dnd5eapi.co/api/2014';
|
|
27
|
+
|
|
28
|
+
type RawApiRef = {
|
|
29
|
+
index: string;
|
|
30
|
+
name: string;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RawSpell = {
|
|
35
|
+
index: string;
|
|
36
|
+
name: string;
|
|
37
|
+
desc: string[];
|
|
38
|
+
higher_level?: string[];
|
|
39
|
+
range: string;
|
|
40
|
+
components: string[];
|
|
41
|
+
material?: string;
|
|
42
|
+
ritual: boolean;
|
|
43
|
+
duration: string;
|
|
44
|
+
concentration: boolean;
|
|
45
|
+
casting_time: string;
|
|
46
|
+
level: number;
|
|
47
|
+
school: RawApiRef;
|
|
48
|
+
classes: RawApiRef[];
|
|
49
|
+
subclasses: RawApiRef[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type RawMonster = {
|
|
53
|
+
index: string;
|
|
54
|
+
name: string;
|
|
55
|
+
size: string;
|
|
56
|
+
type: string;
|
|
57
|
+
alignment: string;
|
|
58
|
+
armor_class: Array<{ value: number; type: string }>;
|
|
59
|
+
hit_points: number;
|
|
60
|
+
hit_dice: string;
|
|
61
|
+
speed: Record<string, string>;
|
|
62
|
+
strength: number;
|
|
63
|
+
dexterity: number;
|
|
64
|
+
constitution: number;
|
|
65
|
+
intelligence: number;
|
|
66
|
+
wisdom: number;
|
|
67
|
+
charisma: number;
|
|
68
|
+
challenge_rating: number;
|
|
69
|
+
xp: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type RawClass = {
|
|
73
|
+
index: string;
|
|
74
|
+
name: string;
|
|
75
|
+
hit_die: number;
|
|
76
|
+
proficiency_choices: unknown[];
|
|
77
|
+
proficiencies: RawApiRef[];
|
|
78
|
+
saving_throws: RawApiRef[];
|
|
79
|
+
starting_equipment: unknown[];
|
|
80
|
+
class_levels: string;
|
|
81
|
+
subclasses: RawApiRef[];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type RawListResponse = {
|
|
85
|
+
count: number;
|
|
86
|
+
results: RawApiRef[];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const tools: McpToolExport['tools'] = [
|
|
90
|
+
{
|
|
91
|
+
name: 'get_spell',
|
|
92
|
+
description:
|
|
93
|
+
'Get full details for a D&D 5e spell by its index name (e.g. "fireball", "magic-missile", "cure-wounds").',
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
index: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Spell index name in kebab-case (e.g. "fireball", "magic-missile").',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
required: ['index'],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'get_monster',
|
|
107
|
+
description:
|
|
108
|
+
'Get full details for a D&D 5e monster by its index name (e.g. "aboleth", "dragon-red-adult", "goblin").',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {
|
|
112
|
+
index: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
description: 'Monster index name in kebab-case (e.g. "goblin", "dragon-red-adult").',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
required: ['index'],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'get_class',
|
|
122
|
+
description:
|
|
123
|
+
'Get details for a D&D 5e character class by its index name (e.g. "barbarian", "wizard", "rogue").',
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
properties: {
|
|
127
|
+
index: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
description: 'Class index name in lowercase (e.g. "wizard", "fighter", "cleric").',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
required: ['index'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'list_spells',
|
|
137
|
+
description: 'List all available D&D 5e spells with their index names.',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
146
|
+
switch (name) {
|
|
147
|
+
case 'get_spell':
|
|
148
|
+
return getSpell(args.index as string);
|
|
149
|
+
case 'get_monster':
|
|
150
|
+
return getMonster(args.index as string);
|
|
151
|
+
case 'get_class':
|
|
152
|
+
return getClass(args.index as string);
|
|
153
|
+
case 'list_spells':
|
|
154
|
+
return listSpells();
|
|
155
|
+
default:
|
|
156
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function getSpell(index: string) {
|
|
161
|
+
const res = await fetch(`${BASE_URL}/spells/${encodeURIComponent(index)}`);
|
|
162
|
+
if (!res.ok) throw new Error(`D&D 5e API error: ${res.status}`);
|
|
163
|
+
|
|
164
|
+
const data = (await res.json()) as RawSpell;
|
|
165
|
+
return {
|
|
166
|
+
index: data.index,
|
|
167
|
+
name: data.name,
|
|
168
|
+
level: data.level,
|
|
169
|
+
school: data.school.name,
|
|
170
|
+
casting_time: data.casting_time,
|
|
171
|
+
range: data.range,
|
|
172
|
+
duration: data.duration,
|
|
173
|
+
concentration: data.concentration,
|
|
174
|
+
ritual: data.ritual,
|
|
175
|
+
components: data.components,
|
|
176
|
+
material: data.material,
|
|
177
|
+
description: data.desc,
|
|
178
|
+
higher_level: data.higher_level,
|
|
179
|
+
classes: data.classes.map((c) => c.name),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function getMonster(index: string) {
|
|
184
|
+
const res = await fetch(`${BASE_URL}/monsters/${encodeURIComponent(index)}`);
|
|
185
|
+
if (!res.ok) throw new Error(`D&D 5e API error: ${res.status}`);
|
|
186
|
+
|
|
187
|
+
const data = (await res.json()) as RawMonster;
|
|
188
|
+
return {
|
|
189
|
+
index: data.index,
|
|
190
|
+
name: data.name,
|
|
191
|
+
size: data.size,
|
|
192
|
+
type: data.type,
|
|
193
|
+
alignment: data.alignment,
|
|
194
|
+
armor_class: data.armor_class,
|
|
195
|
+
hit_points: data.hit_points,
|
|
196
|
+
hit_dice: data.hit_dice,
|
|
197
|
+
speed: data.speed,
|
|
198
|
+
ability_scores: {
|
|
199
|
+
str: data.strength,
|
|
200
|
+
dex: data.dexterity,
|
|
201
|
+
con: data.constitution,
|
|
202
|
+
int: data.intelligence,
|
|
203
|
+
wis: data.wisdom,
|
|
204
|
+
cha: data.charisma,
|
|
205
|
+
},
|
|
206
|
+
challenge_rating: data.challenge_rating,
|
|
207
|
+
xp: data.xp,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function getClass(index: string) {
|
|
212
|
+
const res = await fetch(`${BASE_URL}/classes/${encodeURIComponent(index)}`);
|
|
213
|
+
if (!res.ok) throw new Error(`D&D 5e API error: ${res.status}`);
|
|
214
|
+
|
|
215
|
+
const data = (await res.json()) as RawClass;
|
|
216
|
+
return {
|
|
217
|
+
index: data.index,
|
|
218
|
+
name: data.name,
|
|
219
|
+
hit_die: data.hit_die,
|
|
220
|
+
saving_throws: data.saving_throws.map((s) => s.name),
|
|
221
|
+
proficiencies: data.proficiencies.map((p) => p.name),
|
|
222
|
+
subclasses: data.subclasses.map((s) => s.name),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function listSpells() {
|
|
227
|
+
const res = await fetch(`${BASE_URL}/spells`);
|
|
228
|
+
if (!res.ok) throw new Error(`D&D 5e API error: ${res.status}`);
|
|
229
|
+
|
|
230
|
+
const data = (await res.json()) as RawListResponse;
|
|
231
|
+
return {
|
|
232
|
+
count: data.count,
|
|
233
|
+
spells: data.results.map((s) => ({ index: s.index, name: s.name })),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default { tools, callTool } satisfies McpToolExport;
|