@pipeworx/mcp-thecocktaildb 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 +227 -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-thecocktaildb
|
|
2
|
+
|
|
3
|
+
TheCocktailDB MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 846+ 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
|
+
"thecocktaildb": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/thecocktaildb/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 846+ 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 Thecocktaildb 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-thecocktaildb",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TheCocktailDB MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "thecocktaildb"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-thecocktaildb"
|
|
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/thecocktaildb",
|
|
4
|
+
"title": "Thecocktaildb",
|
|
5
|
+
"description": "TheCocktailDB MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/thecocktaildb",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-thecocktaildb",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/thecocktaildb/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
* TheCocktailDB MCP.
|
|
21
|
+
*
|
|
22
|
+
* Cocktail & drink recipe database — search by name, look up full recipes,
|
|
23
|
+
* filter by ingredient/category/glass/alcoholic content, and list options.
|
|
24
|
+
* Keyless (uses TheCocktailDB's public test API key "1").
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const BASE = 'https://www.thecocktaildb.com/api/json/v1/1';
|
|
29
|
+
const UA = 'pipeworx/1.0 (+https://pipeworx.io)';
|
|
30
|
+
|
|
31
|
+
const LIST_TYPES: Record<string, { param: string; field: string }> = {
|
|
32
|
+
categories: { param: 'c', field: 'strCategory' },
|
|
33
|
+
glasses: { param: 'g', field: 'strGlass' },
|
|
34
|
+
ingredients: { param: 'i', field: 'strIngredient1' },
|
|
35
|
+
alcoholic: { param: 'a', field: 'strAlcoholic' },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const tools: McpToolExport['tools'] = [
|
|
39
|
+
{
|
|
40
|
+
name: 'search_cocktails',
|
|
41
|
+
description:
|
|
42
|
+
'Search cocktails/drinks by name (or partial name) in TheCocktailDB. Returns matching drinks with category, glass, ingredients (name + measure), thumbnail, and a short instruction preview. Keyless.',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
name: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Drink name or partial name, e.g. "margarita", "mojito", "gin".',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ['name'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'get_cocktail',
|
|
56
|
+
description:
|
|
57
|
+
'Get the full recipe for a single cocktail by its TheCocktailDB id (idDrink). Returns complete instructions, all ingredients with measures, glass, tags, and IBA classification. Keyless.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
id: { type: 'string', description: 'TheCocktailDB drink id (idDrink), e.g. "11007".' },
|
|
62
|
+
},
|
|
63
|
+
required: ['id'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'filter_cocktails',
|
|
68
|
+
description:
|
|
69
|
+
'Filter cocktails by exactly ONE criterion: ingredient, category, alcoholic content, or glass. Returns a light list of matching drinks (id, name, thumbnail). Provide only one filter; priority is ingredient > category > alcoholic > glass. Keyless.',
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
ingredient: { type: 'string', description: 'Ingredient name, e.g. "Vodka", "Gin", "Lime".' },
|
|
74
|
+
category: { type: 'string', description: 'Category, e.g. "Ordinary Drink", "Cocktail".' },
|
|
75
|
+
alcoholic: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'Alcoholic content, e.g. "Alcoholic" or "Non_Alcoholic".',
|
|
78
|
+
},
|
|
79
|
+
glass: { type: 'string', description: 'Glass type, e.g. "Cocktail glass", "Highball glass".' },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'list_options',
|
|
85
|
+
description:
|
|
86
|
+
'List the available filter values for a given type. Use these to discover valid inputs for filter_cocktails. Keyless.',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
type: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
description: 'One of: "categories", "glasses", "ingredients", "alcoholic".',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
required: ['type'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
101
|
+
try {
|
|
102
|
+
switch (name) {
|
|
103
|
+
case 'search_cocktails':
|
|
104
|
+
return searchCocktails(args);
|
|
105
|
+
case 'get_cocktail':
|
|
106
|
+
return getCocktail(args);
|
|
107
|
+
case 'filter_cocktails':
|
|
108
|
+
return filterCocktails(args);
|
|
109
|
+
case 'list_options':
|
|
110
|
+
return listOptions(args);
|
|
111
|
+
default:
|
|
112
|
+
return { error: `Unknown tool: ${name}` };
|
|
113
|
+
}
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return { error: e instanceof Error ? e.message : String(e) };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type RawDrink = Record<string, unknown>;
|
|
120
|
+
|
|
121
|
+
function str(v: unknown): string | null {
|
|
122
|
+
return typeof v === 'string' && v.trim() ? v.trim() : null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Zip strIngredientN + strMeasureN into a clean ingredients array. */
|
|
126
|
+
function ingredients(raw: RawDrink): Array<{ name: string; measure: string | null }> {
|
|
127
|
+
const out: Array<{ name: string; measure: string | null }> = [];
|
|
128
|
+
for (let i = 1; i <= 15; i++) {
|
|
129
|
+
const name = str(raw[`strIngredient${i}`]);
|
|
130
|
+
if (!name) continue;
|
|
131
|
+
out.push({ name, measure: str(raw[`strMeasure${i}`]) });
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function compactDrink(raw: RawDrink, opts: { full?: boolean } = {}): Record<string, unknown> {
|
|
137
|
+
const instructions = str(raw.strInstructions);
|
|
138
|
+
const drink: Record<string, unknown> = {
|
|
139
|
+
id: raw.idDrink ?? null,
|
|
140
|
+
name: raw.strDrink ?? null,
|
|
141
|
+
category: raw.strCategory ?? null,
|
|
142
|
+
alcoholic: raw.strAlcoholic ?? null,
|
|
143
|
+
glass: raw.strGlass ?? null,
|
|
144
|
+
thumbnail: raw.strDrinkThumb ?? null,
|
|
145
|
+
ingredients: ingredients(raw),
|
|
146
|
+
instructions:
|
|
147
|
+
opts.full || !instructions || instructions.length <= 500
|
|
148
|
+
? instructions
|
|
149
|
+
: `${instructions.slice(0, 500)}…`,
|
|
150
|
+
};
|
|
151
|
+
if (opts.full) {
|
|
152
|
+
const tags = str(raw.strTags);
|
|
153
|
+
drink.tags = tags ? tags.split(',').map((t) => t.trim()).filter(Boolean) : [];
|
|
154
|
+
const iba = str(raw.strIBA);
|
|
155
|
+
if (iba) drink.iba = iba;
|
|
156
|
+
}
|
|
157
|
+
return drink;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function fetchJson(url: string): Promise<{ drinks: RawDrink[] | null } | { error: string }> {
|
|
161
|
+
const res = await fetch(url, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
162
|
+
if (!res.ok) return { error: `thecocktaildb: ${res.status} ${(await res.text()).slice(0, 200)}` };
|
|
163
|
+
const data = (await res.json()) as { drinks?: RawDrink[] | null };
|
|
164
|
+
return { drinks: Array.isArray(data.drinks) ? data.drinks : null };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function searchCocktails(args: Record<string, unknown>): Promise<unknown> {
|
|
168
|
+
const name = typeof args.name === 'string' ? args.name.trim() : '';
|
|
169
|
+
if (!name) return { error: 'provide a drink name', name: args.name ?? null };
|
|
170
|
+
|
|
171
|
+
const data = await fetchJson(`${BASE}/search.php?s=${encodeURIComponent(name)}`);
|
|
172
|
+
if ('error' in data) return data;
|
|
173
|
+
const drinks = data.drinks ?? [];
|
|
174
|
+
const cocktails = drinks.slice(0, 25).map((d) => compactDrink(d));
|
|
175
|
+
return { count: cocktails.length, cocktails };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function getCocktail(args: Record<string, unknown>): Promise<unknown> {
|
|
179
|
+
const id = typeof args.id === 'string' ? args.id.trim() : '';
|
|
180
|
+
if (!id) return { error: 'provide a drink id', id: args.id ?? null };
|
|
181
|
+
|
|
182
|
+
const data = await fetchJson(`${BASE}/lookup.php?i=${encodeURIComponent(id)}`);
|
|
183
|
+
if ('error' in data) return data;
|
|
184
|
+
const drinks = data.drinks ?? [];
|
|
185
|
+
if (drinks.length === 0) return { error: 'cocktail not found', id };
|
|
186
|
+
return compactDrink(drinks[0], { full: true });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function filterCocktails(args: Record<string, unknown>): Promise<unknown> {
|
|
190
|
+
const ingredient = typeof args.ingredient === 'string' ? args.ingredient.trim() : '';
|
|
191
|
+
const category = typeof args.category === 'string' ? args.category.trim() : '';
|
|
192
|
+
const alcoholic = typeof args.alcoholic === 'string' ? args.alcoholic.trim() : '';
|
|
193
|
+
const glass = typeof args.glass === 'string' ? args.glass.trim() : '';
|
|
194
|
+
|
|
195
|
+
let qs: string;
|
|
196
|
+
if (ingredient) qs = `i=${encodeURIComponent(ingredient)}`;
|
|
197
|
+
else if (category) qs = `c=${encodeURIComponent(category)}`;
|
|
198
|
+
else if (alcoholic) qs = `a=${encodeURIComponent(alcoholic)}`;
|
|
199
|
+
else if (glass) qs = `g=${encodeURIComponent(glass)}`;
|
|
200
|
+
else return { error: 'provide one of: ingredient, category, alcoholic, glass' };
|
|
201
|
+
|
|
202
|
+
const data = await fetchJson(`${BASE}/filter.php?${qs}`);
|
|
203
|
+
if ('error' in data) return data;
|
|
204
|
+
const drinks = data.drinks ?? [];
|
|
205
|
+
const cocktails = drinks.slice(0, 50).map((d) => ({
|
|
206
|
+
id: d.idDrink ?? null,
|
|
207
|
+
name: d.strDrink ?? null,
|
|
208
|
+
thumbnail: d.strDrinkThumb ?? null,
|
|
209
|
+
}));
|
|
210
|
+
return { count: cocktails.length, cocktails };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function listOptions(args: Record<string, unknown>): Promise<unknown> {
|
|
214
|
+
const type = typeof args.type === 'string' ? args.type.trim().toLowerCase() : '';
|
|
215
|
+
const spec = LIST_TYPES[type];
|
|
216
|
+
if (!spec) {
|
|
217
|
+
return { error: `provide a valid type: ${Object.keys(LIST_TYPES).join(', ')}`, type: args.type ?? null };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const data = await fetchJson(`${BASE}/list.php?${spec.param}=list`);
|
|
221
|
+
if ('error' in data) return data;
|
|
222
|
+
const drinks = data.drinks ?? [];
|
|
223
|
+
const values = drinks.map((d) => d[spec.field]).filter((v): v is string => typeof v === 'string' && v.trim() !== '');
|
|
224
|
+
return { type, count: values.length, values };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
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
|
+
}
|