Skip to main content
Glama
MealDB MCP Server

MealDB MCP Server

README.md
# MealDB MCP Server

A **Model Context Protocol (MCP)** server that provides AI assistants with access to the [**TheMealDB**](https://www.themealdb.com/) API for recipe and meal information. This server enables AI assistants to search for recipes, get detailed meal information, browse categories, and explore ingredients.

๐Ÿ• **Hey Vibe Coders!** Ever have the problem where your partner asks you, *"What do you want to eat?"* and you just stare blankly? No more endless scrolling through delivery apps or decision paralysis! Let AI help you discover your next meal! ๐Ÿค–โœจ

 ๐ŸŒŸ **Powered by [TheMealDB](https://www.themealdb.com/)** - An open, crowd-sourced database of recipes from around the world!  
๐Ÿ’ก *Enjoying this product? Consider reaching out to [TheMealDB team](https://www.themealdb.com/api.php) to set up a production API for enhanced features and production usecases!* 

## ๐Ÿฝ๏ธ Features

- ๐Ÿ” **Meal Search** - Search for meals by name
- ๐Ÿ“‹ **Meal Details** - Get complete recipe details including ingredients and instructions  
- ๐ŸŽฒ **Random Meals** - Get random meal suggestions for when you're feeling adventurous
- ๐Ÿ“‚ **Category Browsing** - Explore meal categories and discover new cuisines
- ๐Ÿฅ• **Ingredient Search** - Find meals by specific ingredients you have on hand
- ๐ŸŒ **Comprehensive Data** - Access to thousands of recipes from around the world

## ๐Ÿš€ Quick Start

### Prerequisites

- **Node.js 18+** 
- **npm** or **yarn**
- A compatible **MCP client** (like Cursor with MCP support)
- **Docker & Docker Compose** *(optional, for containerized deployment)*

### ๐Ÿ’ป Local Installation *(Recommended)*

1. **Clone this repository**
   ```bash
   git clone <your-repo-url>
   cd mealdb-mcp
   ```

2. **Install dependencies**
   ```bash
   npm install
   ```

3. **Build the server**
   ```bash
   npm run build
   ```

4. **Start the server**
   ```bash
   npm start
   ```

The server will start and listen for MCP requests via stdio.

### ๐Ÿณ Docker Installation *(Optional)*

For a containerized setup *(requires Docker Desktop)*:

**Production deployment:**
```bash
npm run docker:prod
```

**Development with hot reload:**
```bash
npm run docker:dev
```

> โš ๏ธ **Note:** If you get a *"'docker-compose' is not recognized"* error, Docker isn't installed. Use the local installation method above instead.

## โš™๏ธ Configuration

### For Cursor IDE

The server includes a `.cursor/mcp.json` configuration file that allows Cursor to automatically discover and use the MealDB server:

```json
{
  "mcpServers": {
    "mealdb-server": {
      "command": "node",
      "args": ["build/index.js"],
      "env": {
        "NODE_ENV": "development"
      }
    }
  }
}
```

### For Other MCP Clients

Configure your MCP client to connect to this server using:
- **Command:** `node`
- **Arguments:** `["path/to/mealdb-mcp/build/index.js"]`
- **Working Directory:** `path/to/mealdb-mcp`

## ๐Ÿ› ๏ธ Available Tools

### ๐Ÿ” `search_meals`
Search for meals by name.

**Parameters:**
- `query` *(string)*: Name of the meal to search for

**Example:**
```json
{
  "name": "search_meals",
  "arguments": {
    "query": "chicken"
  }
}
```

### ๐Ÿ“‹ `get_meal_details`
Get detailed information about a specific meal by ID.

**Parameters:**
- `mealId` *(string)*: The ID of the meal to get details for

**Example:**
```json
{
  "name": "get_meal_details",
  "arguments": {
    "mealId": "52772"
  }
}
```

### ๐ŸŽฒ `get_random_meal`
Get a random meal suggestion.

**Parameters:** *None*

**Example:**
```json
{
  "name": "get_random_meal",
  "arguments": {}
}
```

### ๐Ÿ“‚ `list_categories`
Get all available meal categories.

**Parameters:** *None*

**Example:**
```json
{
  "name": "list_categories",
  "arguments": {}
}
```

### ๐Ÿฅ• `search_by_ingredient`
Find meals that contain a specific ingredient.

**Parameters:**
- `ingredient` *(string)*: Name of the ingredient to search for

**Example:**
```json
{
  "name": "search_by_ingredient",
  "arguments": {
    "ingredient": "chicken"
  }
}
```

## ๐Ÿ’ฌ Usage Examples

Here are some example queries you can ask an AI assistant using this MCP server:

- *"Find me some chicken recipes"*
- *"Get details for meal ID 52772"*
- *"Give me a random meal suggestion"*
- *"What meal categories are available?"*
- *"Find meals that contain tomatoes"*
- *"Show me Italian recipes"*
- *"What are some vegetarian options?"*

## ๐Ÿ—๏ธ Development

### Project Structure

```
mealdb-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ index.ts          # Main MCP server implementation
โ”œโ”€โ”€ build/                # Compiled JavaScript output
โ”œโ”€โ”€ .cursor/
โ”‚   โ””โ”€โ”€ mcp.json         # Cursor IDE configuration
โ”œโ”€โ”€ package.json         # Project dependencies and scripts
โ”œโ”€โ”€ tsconfig.json        # TypeScript configuration
โ””โ”€โ”€ README.md           # This file
```

### Available Scripts

**Local Development:**
- `npm run build` - Compile TypeScript to JavaScript
- `npm run watch` - Watch for changes and recompile
- `npm start` - Start the MCP server
- `npm run prepare` - Build the project *(runs automatically on install)*

**Docker Commands:**
- `npm run docker:build` - Build Docker image
- `npm run docker:run` - Run container from built image
- `npm run docker:dev` - Start development environment with hot reload
- `npm run docker:prod` - Start production environment
- `npm run docker:stop` - Stop all containers
- `npm run docker:logs` - View container logs
- `npm run docker:clean` - Clean up containers and images

### API Information

This server uses the **free tier** of [TheMealDB API](https://www.themealdb.com/api.php) which provides:

- โœ… Meal search by name
- โœ… Meal details by ID
- โœ… Random meal suggestions
- โœ… Category listings
- โœ… Ingredient-based filtering
- โœ… Area/cuisine filtering

> **Note:** This server only uses free API endpoints. Premium features are not implemented.

## ๐Ÿณ Docker Deployment

### Container Features

- ๐Ÿ—๏ธ **Multi-stage build** for optimized production images
- ๐Ÿ”’ **Non-root user** for enhanced security
- ๐Ÿ’“ **Health checks** for container monitoring
- ๐Ÿ”๏ธ **Alpine Linux** base for minimal image size
- ๐Ÿ”„ **Development mode** with hot reload support

### Production Deployment

```bash
# Build and start in production mode
docker-compose up -d

# View logs
docker-compose logs -f mealdb-mcp-server

# Stop services
docker-compose down
```

### Development Deployment

```bash
# Start development environment with hot reload
docker-compose -f docker-compose.dev.yml up

# Or use the npm script
npm run docker:dev
```

### Environment Variables

Configure the container using environment variables:

```bash
NODE_ENV=production          # Environment mode
PORT=3000                   # Server port
```

## ๐Ÿ”’ Security

- ๐Ÿ  The server runs locally and doesn't expose any network ports
- ๐ŸŒ All API calls are made to the public TheMealDB API
- ๐Ÿ” No sensitive data is stored or transmitted
- ๐Ÿ”— Uses secure HTTPS connections to external APIs

## ๐Ÿค Contributing

1. ๐Ÿด Fork the repository
2. ๐ŸŒฟ Create a feature branch
3. โœ๏ธ Make your changes
4. ๐Ÿงช Test thoroughly
5. ๐Ÿ“ค Submit a pull request

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- [TheMealDB](https://www.themealdb.com/) for providing the free recipe API
- [Model Context Protocol](https://modelcontextprotocol.io/) for the standardized AI-assistant communication protocol
- [Anthropic](https://www.anthropic.com/) for developing MCP

## ๐Ÿ“ž Support & Help

### ๐Ÿ†˜ Need Help?

We're here to help you get the most out of your MealDB MCP Server! If you encounter any issues or have questions, here are your options:

**๐Ÿ“ง Get Support:**
- ๐Ÿ› **Found a bug?** Open an issue in our [GitHub repository](https://github.com/your-repo/mealdb-mcp)
- ๐Ÿ’ก **Have a feature request?** We'd love to hear your ideas!
- โ“ **Need help with setup?** Check our troubleshooting guide below or ask for help

**๐Ÿ”— Useful Links:**
- ๐Ÿ“– [TheMealDB API Documentation](https://www.themealdb.com/api.php)
- ๐Ÿ  [TheMealDB Website](https://www.themealdb.com/)
- ๐Ÿ“‹ [Model Context Protocol Documentation](https://modelcontextprotocol.io/)

### Common Issues & Solutions

**๐Ÿšจ "'docker-compose' is not recognized" Error:**

If you see this error when running `npm run docker:prod`, it means Docker isn't installed on your system. You have two options:

1. **Install Docker Desktop** *(recommended for containerized deployment)*:
   - Download from https://www.docker.com/products/docker-desktop/
   - Install and restart your computer
   - Verify with `docker --version` and `docker compose version`

2. **Run locally without Docker** *(simpler setup)*:
   ```bash
   npm install
   npm run build
   npm start
   ```

**๐Ÿ”ง Build or Runtime Issues:**

1. โœ… Check that Node.js 18+ is installed (`node --version`)
2. โœ… Ensure all dependencies are installed (`npm install`)
3. โœ… Verify the build completed successfully (`npm run build`)
4. โœ… Check that your MCP client is configured correctly
5. โœ… Make sure you're in the correct directory
6. โœ… Try clearing node_modules and reinstalling: `rm -rf node_modules package-lock.json && npm install`

**Still having trouble?** Don't hesitate to reach out - we're happy to help! ๐Ÿค

---

**Happy Cooking! ๐Ÿณ**

**Made with โค๏ธ by Traves Theberge**