@pipeworx/mcp-recipes 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 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,38 @@
1
+ # mcp-recipes
2
+
3
+ Recipes MCP — wraps TheMealDB API (free tier, no auth)
4
+
5
+ Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+ | `search_meals` | Search for recipes by meal name. Returns a list of matching meals. |
12
+ | `get_meal` | Get the full recipe for a meal by its TheMealDB ID, including ingredients and instructions. |
13
+ | `random_meal` | Get a random meal recipe. |
14
+ | `meals_by_ingredient` | Find meals that use a specific ingredient (e.g., "chicken", "garlic", "pasta"). |
15
+
16
+ ## Quick Start
17
+
18
+ Add to your MCP client config:
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "recipes": {
24
+ "url": "https://gateway.pipeworx.io/recipes/mcp"
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ Or use the CLI:
31
+
32
+ ```bash
33
+ npx pipeworx use recipes
34
+ ```
35
+
36
+ ## License
37
+
38
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-recipes",
3
+ "version": "0.1.0",
4
+ "description": "Recipes MCP — wraps TheMealDB API (free tier, no auth)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "recipes"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-recipes"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/recipes",
4
+ "title": "recipes",
5
+ "description": "Recipes MCP — wraps TheMealDB API (free tier, no auth)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/recipes",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-recipes",
10
+ "source": "github"
11
+ },
12
+ "packages": [
13
+ {
14
+ "registryType": "npm",
15
+ "identifier": "@pipeworx/mcp-recipes",
16
+ "version": "0.1.0"
17
+ }
18
+ ],
19
+ "remotes": [
20
+ {
21
+ "type": "streamable-http",
22
+ "url": "https://gateway.pipeworx.io/recipes/mcp"
23
+ }
24
+ ]
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,199 @@
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
+ }
15
+
16
+ /**
17
+ * Recipes MCP — wraps TheMealDB API (free tier, no auth)
18
+ *
19
+ * Tools:
20
+ * - search_meals: search recipes by name
21
+ * - get_meal: full recipe details by meal ID
22
+ * - random_meal: get a random recipe
23
+ * - meals_by_ingredient: find meals that use a specific ingredient
24
+ */
25
+
26
+
27
+ const BASE_URL = 'https://www.themealdb.com/api/json/v1/1';
28
+
29
+ type RawMeal = {
30
+ idMeal: string;
31
+ strMeal: string;
32
+ strCategory?: string;
33
+ strArea?: string;
34
+ strInstructions?: string;
35
+ strMealThumb?: string;
36
+ strYoutube?: string;
37
+ strSource?: string;
38
+ strTags?: string;
39
+ [key: string]: string | undefined;
40
+ };
41
+
42
+ type SlimMeal = {
43
+ idMeal: string;
44
+ strMeal: string;
45
+ strMealThumb?: string;
46
+ };
47
+
48
+ const tools: McpToolExport['tools'] = [
49
+ {
50
+ name: 'search_meals',
51
+ description: 'Search for recipes by meal name. Returns a list of matching meals.',
52
+ inputSchema: {
53
+ type: 'object',
54
+ properties: {
55
+ query: { type: 'string', description: 'Meal name or partial name to search for' },
56
+ },
57
+ required: ['query'],
58
+ },
59
+ },
60
+ {
61
+ name: 'get_meal',
62
+ description: 'Get the full recipe for a meal by its TheMealDB ID, including ingredients and instructions.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ id: { type: 'string', description: 'TheMealDB meal ID (e.g., "52772")' },
67
+ },
68
+ required: ['id'],
69
+ },
70
+ },
71
+ {
72
+ name: 'random_meal',
73
+ description: 'Get a random meal recipe.',
74
+ inputSchema: {
75
+ type: 'object',
76
+ properties: {},
77
+ },
78
+ },
79
+ {
80
+ name: 'meals_by_ingredient',
81
+ description: 'Find meals that use a specific ingredient (e.g., "chicken", "garlic", "pasta").',
82
+ inputSchema: {
83
+ type: 'object',
84
+ properties: {
85
+ ingredient: { type: 'string', description: 'Ingredient name to filter by' },
86
+ },
87
+ required: ['ingredient'],
88
+ },
89
+ },
90
+ ];
91
+
92
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
93
+ switch (name) {
94
+ case 'search_meals':
95
+ return searchMeals(args.query as string);
96
+ case 'get_meal':
97
+ return getMeal(args.id as string);
98
+ case 'random_meal':
99
+ return randomMeal();
100
+ case 'meals_by_ingredient':
101
+ return mealsByIngredient(args.ingredient as string);
102
+ default:
103
+ throw new Error(`Unknown tool: ${name}`);
104
+ }
105
+ }
106
+
107
+ function extractIngredients(meal: RawMeal): { ingredient: string; measure: string }[] {
108
+ const ingredients: { ingredient: string; measure: string }[] = [];
109
+ for (let i = 1; i <= 20; i++) {
110
+ const ingredient = meal[`strIngredient${i}`]?.trim();
111
+ const measure = meal[`strMeasure${i}`]?.trim();
112
+ if (ingredient) {
113
+ ingredients.push({ ingredient, measure: measure ?? '' });
114
+ }
115
+ }
116
+ return ingredients;
117
+ }
118
+
119
+ function formatFullMeal(meal: RawMeal) {
120
+ return {
121
+ id: meal.idMeal,
122
+ name: meal.strMeal,
123
+ category: meal.strCategory ?? null,
124
+ area: meal.strArea ?? null,
125
+ instructions: meal.strInstructions ?? null,
126
+ thumbnail_url: meal.strMealThumb ?? null,
127
+ youtube_url: meal.strYoutube ?? null,
128
+ source_url: meal.strSource ?? null,
129
+ tags: meal.strTags ? meal.strTags.split(',').map((t) => t.trim()).filter(Boolean) : [],
130
+ ingredients: extractIngredients(meal),
131
+ };
132
+ }
133
+
134
+ function formatSlimMeal(meal: SlimMeal) {
135
+ return {
136
+ id: meal.idMeal,
137
+ name: meal.strMeal,
138
+ thumbnail_url: meal.strMealThumb ?? null,
139
+ };
140
+ }
141
+
142
+ async function searchMeals(query: string) {
143
+ const res = await fetch(
144
+ `${BASE_URL}/search.php?s=${encodeURIComponent(query)}`,
145
+ );
146
+ if (!res.ok) throw new Error(`TheMealDB error: ${res.status}`);
147
+
148
+ const data = (await res.json()) as { meals: RawMeal[] | null };
149
+ if (!data.meals) return { meals: [], total: 0 };
150
+
151
+ return {
152
+ total: data.meals.length,
153
+ meals: data.meals.map(formatFullMeal),
154
+ };
155
+ }
156
+
157
+ async function getMeal(id: string) {
158
+ const res = await fetch(
159
+ `${BASE_URL}/lookup.php?i=${encodeURIComponent(id)}`,
160
+ );
161
+ if (!res.ok) throw new Error(`TheMealDB error: ${res.status}`);
162
+
163
+ const data = (await res.json()) as { meals: RawMeal[] | null };
164
+ if (!data.meals || data.meals.length === 0) {
165
+ throw new Error(`Meal not found for ID: "${id}"`);
166
+ }
167
+
168
+ return formatFullMeal(data.meals[0]);
169
+ }
170
+
171
+ async function randomMeal() {
172
+ const res = await fetch(`${BASE_URL}/random.php`);
173
+ if (!res.ok) throw new Error(`TheMealDB error: ${res.status}`);
174
+
175
+ const data = (await res.json()) as { meals: RawMeal[] | null };
176
+ if (!data.meals || data.meals.length === 0) {
177
+ throw new Error('Failed to retrieve a random meal');
178
+ }
179
+
180
+ return formatFullMeal(data.meals[0]);
181
+ }
182
+
183
+ async function mealsByIngredient(ingredient: string) {
184
+ const res = await fetch(
185
+ `${BASE_URL}/filter.php?i=${encodeURIComponent(ingredient)}`,
186
+ );
187
+ if (!res.ok) throw new Error(`TheMealDB error: ${res.status}`);
188
+
189
+ const data = (await res.json()) as { meals: SlimMeal[] | null };
190
+ if (!data.meals) return { ingredient, meals: [], total: 0 };
191
+
192
+ return {
193
+ ingredient,
194
+ total: data.meals.length,
195
+ meals: data.meals.map(formatSlimMeal),
196
+ };
197
+ }
198
+
199
+ export default { tools, callTool } 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
+ }