@pipeworx/mcp-merriam-webster 0.1.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 +55 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +220 -0
- package/tsconfig.json +14 -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,55 @@
|
|
|
1
|
+
# mcp-merriam-webster
|
|
2
|
+
|
|
3
|
+
Merriam-Webster MCP — wraps the Merriam-Webster Collegiate Dictionary and
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 764+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"merriam-webster": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/merriam-webster/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 764+ data sources:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"pipeworx": {
|
|
32
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Using with ask_pipeworx
|
|
39
|
+
|
|
40
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
ask_pipeworx({ question: "your question about Merriam Webster data" })
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
47
|
+
|
|
48
|
+
## More
|
|
49
|
+
|
|
50
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
51
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-merriam-webster",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Merriam-Webster MCP — wraps the Merriam-Webster Collegiate Dictionary and",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "merriam-webster"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-merriam-webster"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/merriam-webster",
|
|
4
|
+
"title": "Merriam Webster",
|
|
5
|
+
"description": "Merriam-Webster MCP — wraps the Merriam-Webster Collegiate Dictionary and",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/merriam-webster",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-merriam-webster",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/merriam-webster/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
meter?: { credits: number };
|
|
15
|
+
cost?: Record<string, unknown>;
|
|
16
|
+
provider?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Merriam-Webster MCP — wraps the Merriam-Webster Collegiate Dictionary and
|
|
21
|
+
* Collegiate Thesaurus APIs (dictionaryapi.com).
|
|
22
|
+
*
|
|
23
|
+
* The authoritative American English dictionary and thesaurus. Look up word
|
|
24
|
+
* definitions, part of speech, pronunciation, and etymology, or find synonyms
|
|
25
|
+
* and antonyms. When a word isn't found, Merriam-Webster returns close spelling
|
|
26
|
+
* suggestions instead.
|
|
27
|
+
*
|
|
28
|
+
* Tools:
|
|
29
|
+
* - define: definitions, part of speech, pronunciation, etymology for a word
|
|
30
|
+
* - thesaurus: synonyms, antonyms, part of speech, short definitions for a word
|
|
31
|
+
*
|
|
32
|
+
* Dual key model: pass your own Merriam-Webster keys via _apiKey in the form
|
|
33
|
+
* DICT_KEY:THES_KEY for higher limits, or omit it to use the shared Pipeworx
|
|
34
|
+
* keys. Auth: key supplied as the `key` query param.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const BASE_URL = 'https://www.dictionaryapi.com/api/v3/references/collegiate/json';
|
|
39
|
+
const THESAURUS_BASE_URL = 'https://www.dictionaryapi.com/api/v3/references/thesaurus/json';
|
|
40
|
+
|
|
41
|
+
const tools: McpToolExport['tools'] = [
|
|
42
|
+
{
|
|
43
|
+
name: 'define',
|
|
44
|
+
description:
|
|
45
|
+
'Look up a word in the Merriam-Webster dictionary — the authoritative American English dictionary. Returns word definitions (short definitions), part of speech (noun, verb, adjective, etc.), pronunciation, and etymology (word origin). When the word is not found, returns close spelling suggestions instead. Example: define({ word: "ephemeral" })',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object' as const,
|
|
48
|
+
properties: {
|
|
49
|
+
word: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'The word to look up, e.g. "ephemeral", "serendipity", "run"',
|
|
52
|
+
},
|
|
53
|
+
_apiKey: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description:
|
|
56
|
+
'Optional — your own Merriam-Webster keys as DICT_KEY:THES_KEY for higher limits; omit to use the shared Pipeworx key.',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['word'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'thesaurus',
|
|
64
|
+
description:
|
|
65
|
+
'Look up a word in the Merriam-Webster thesaurus — the authoritative American English thesaurus. Returns synonyms and antonyms grouped by sense, along with part of speech (noun, verb, adjective, etc.) and short definitions. When the word is not found, returns close spelling suggestions instead. Example: thesaurus({ word: "happy" })',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object' as const,
|
|
68
|
+
properties: {
|
|
69
|
+
word: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'The word to look up, e.g. "happy", "fast", "destroy"',
|
|
72
|
+
},
|
|
73
|
+
_apiKey: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description:
|
|
76
|
+
'Optional — your own Merriam-Webster keys as DICT_KEY:THES_KEY for higher limits; omit to use the shared Pipeworx key.',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ['word'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
85
|
+
const combined = args._apiKey as string | undefined;
|
|
86
|
+
delete args._apiKey;
|
|
87
|
+
|
|
88
|
+
const [dictKey, thesKey] = (combined || '').split(':');
|
|
89
|
+
|
|
90
|
+
switch (name) {
|
|
91
|
+
case 'define':
|
|
92
|
+
return define(args.word as string, dictKey);
|
|
93
|
+
case 'thesaurus':
|
|
94
|
+
return thesaurus(args.word as string, thesKey);
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Merriam-Webster entry shape (only the fields we surface).
|
|
101
|
+
interface MwEntry {
|
|
102
|
+
meta?: { id?: string; stems?: string[]; offensive?: boolean };
|
|
103
|
+
fl?: string; // functional label = part of speech
|
|
104
|
+
hwi?: { prs?: Array<{ mw?: string }> }; // headword info → pronunciations
|
|
105
|
+
shortdef?: string[];
|
|
106
|
+
et?: Array<[string, string]>; // etymology
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function define(word: string, apiKey: string) {
|
|
110
|
+
if (!apiKey) {
|
|
111
|
+
return {
|
|
112
|
+
error: 'api_key_required',
|
|
113
|
+
message: 'No Merriam-Webster dictionary key available.',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!word) {
|
|
118
|
+
throw new Error('Merriam-Webster define requires a `word` argument, e.g. define({ word: "ephemeral" }).');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const url = `${BASE_URL}/${encodeURIComponent(word)}?key=${encodeURIComponent(apiKey)}`;
|
|
122
|
+
const res = await fetch(url);
|
|
123
|
+
if (!res.ok) {
|
|
124
|
+
const text = await res.text();
|
|
125
|
+
return { error: res.status, message: text };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const data = (await res.json()) as unknown[];
|
|
129
|
+
|
|
130
|
+
// M-W response quirk: the endpoint returns EITHER
|
|
131
|
+
// (a) an array of entry objects when the word is found,
|
|
132
|
+
// (b) an array of plain STRING suggestions when it isn't (close matches), or
|
|
133
|
+
// (c) an empty array.
|
|
134
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
135
|
+
return { word, found: false, suggestions: [] as string[] };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (typeof data[0] === 'string') {
|
|
139
|
+
return { word, found: false, suggestions: data as string[] };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const entries = data as MwEntry[];
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
word,
|
|
146
|
+
found: true,
|
|
147
|
+
entries: entries.map((e) => ({
|
|
148
|
+
id: e.meta?.id,
|
|
149
|
+
part_of_speech: e.fl,
|
|
150
|
+
pronunciation: e.hwi?.prs?.[0]?.mw,
|
|
151
|
+
definitions: e.shortdef || [],
|
|
152
|
+
stems: e.meta?.stems,
|
|
153
|
+
etymology: Array.isArray(e.et)
|
|
154
|
+
? e.et
|
|
155
|
+
.map((x) => x[1])
|
|
156
|
+
.join(' ')
|
|
157
|
+
.replace(/\{[^}]+\}/g, '')
|
|
158
|
+
: undefined,
|
|
159
|
+
offensive: e.meta?.offensive,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Merriam-Webster thesaurus entry shape (only the fields we surface).
|
|
165
|
+
interface MwThesaurusEntry {
|
|
166
|
+
meta?: { id?: string; syns?: string[][]; ants?: string[][] };
|
|
167
|
+
fl?: string; // functional label = part of speech
|
|
168
|
+
shortdef?: string[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function thesaurus(word: string, apiKey: string) {
|
|
172
|
+
if (!apiKey) {
|
|
173
|
+
return {
|
|
174
|
+
error: 'api_key_required',
|
|
175
|
+
message: 'No Merriam-Webster thesaurus key available.',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!word) {
|
|
180
|
+
throw new Error('Merriam-Webster thesaurus requires a `word` argument, e.g. thesaurus({ word: "happy" }).');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const url = `${THESAURUS_BASE_URL}/${encodeURIComponent(word)}?key=${encodeURIComponent(apiKey)}`;
|
|
184
|
+
const res = await fetch(url);
|
|
185
|
+
if (!res.ok) {
|
|
186
|
+
const text = await res.text();
|
|
187
|
+
return { error: res.status, message: text };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const data = (await res.json()) as unknown[];
|
|
191
|
+
|
|
192
|
+
// Same response quirk as define: the endpoint returns EITHER
|
|
193
|
+
// (a) an array of entry objects when the word is found,
|
|
194
|
+
// (b) an array of plain STRING suggestions when it isn't (close matches), or
|
|
195
|
+
// (c) an empty array.
|
|
196
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
197
|
+
return { word, found: false, suggestions: [] as string[] };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (typeof data[0] === 'string') {
|
|
201
|
+
return { word, found: false, suggestions: data as string[] };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const entries = data as MwThesaurusEntry[];
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
word,
|
|
208
|
+
found: true,
|
|
209
|
+
entries: entries.map((e) => ({
|
|
210
|
+
id: e.meta?.id,
|
|
211
|
+
part_of_speech: e.fl,
|
|
212
|
+
definitions: e.shortdef || [],
|
|
213
|
+
// meta.syns / meta.ants are arrays-of-arrays of strings — flatten them.
|
|
214
|
+
synonyms: (e.meta?.syns || []).flat(),
|
|
215
|
+
antonyms: (e.meta?.ants || []).flat(),
|
|
216
|
+
})),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|