UNPKG

mcp-open-food-facts

Version:

MCP server to use Open Food Facts API

137 lines (101 loc) • 3.14 kB
# MCP Open Food Facts Server ![Version](https://img.shields.io/badge/version-1.0.0-blue.svg) ![License](https://img.shields.io/badge/license-MIT-green.svg) ![TypeScript](https://img.shields.io/badge/TypeScript-5.0.4-blue.svg) ![Node.js](https://img.shields.io/badge/Node.js-18.x-green.svg) [SPANISH VERSION](README_ES.md) An MCP (Model Context Protocol) server that provides access to the Open Food Facts API, enabling searches and queries for nutritional information of food products. ## šŸš€ Features - Product search by name - Product search by barcode - Detailed product information retrieval - MCP protocol integration - TypeScript support ## šŸ“‹ Prerequisites - Node.js (version 18 or higher) - npm or yarn - TypeScript ## šŸ”§ Installation 1. Clone the repository: ```bash git clone https://github.com/PayCode-Studio/mcp-open-food-facts cd mcp-open-food-facts ``` 2. Install dependencies: ```bash npm install # or yarn install ``` ## šŸš€ Usage ### Development To run the server in development mode: ```bash npm run dev # or yarn dev ``` ### Production To build and run in production: ```bash npm run build npm start # or yarn build yarn start ``` ## šŸ“¦ Project Structure ``` mcp-open-food-facts/ ā”œā”€ā”€ src/ │ ā”œā”€ā”€ index.ts # Application entry point │ ā”œā”€ā”€ services/ # Application services │ │ └── open-food-facts.services.ts │ └── types/ # TypeScript type definitions │ ā”œā”€ā”€ mcp.type.ts │ └── open-food-facts.type.ts ā”œā”€ā”€ dist/ # Compiled code ā”œā”€ā”€ package.json ā”œā”€ā”€ tsconfig.json └── README.md ``` ## šŸ” API ### Product Search #### Search by Name ```typescript const products = await searchProduct("coca cola"); ``` #### Search by Barcode ```typescript const product = await getProductByBarcode("5449000000996"); ``` ### Response The API returns detailed information about products, including: - Nutritional information - Ingredients - Allergens - Brand - Categories - Ecoscore score - And more... ## šŸ¤ Contribution 1. Fork the project 2. Create a branch for your feature (`git checkout -b feature/AmazingFeature`) 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request ## šŸ“ License This project is under the ISC License. See the `LICENSE` file for more details. ## ✨ Author **cisco_juan** - *Initial Work* - [cisco_juan](https://github.com/cisco_juan) ## šŸ™ Thanks - [Open Food Facts](https://world.openfoodfacts.org/) for providing the API - [Model Context Protocol](https://github.com/modelcontextprotocol) for the MCP framework - All contributors who participate in this project ## šŸ“ž Support If you have any questions or problems, please: 1. Check existing issues 2. Open a new issue if necessary 3. Contact the maintenance team --- Made with ā¤ļø by the community of developers