This project is part of the Model Context Protocol (MCP) ecosystem and provides tools for integrating with external sources and managing specific domain models. It is designed to demonstrate how to build an MCP server that scrapes products from Mercado Livre, with strong data validation to ensure reliability.
| An integration that enables MCP tools to scrape product data, such as prices and availability, directly from Mercado Livre. |
|
- Features
- Architecture
- Installation
- MCP Server Configuration in VSCode
- MCP Server Output in VSCode
- Contribution
- License
- get-produtos: Fetch basic product information.
- Input validation using Zod.
- Integration with the Mercado Livre API using
fetch(infrastructure layer).
The project follows a layered architecture inspired by Domain-Driven Design (DDD) patterns:
-
Domain (
src/domain): Defines interfaces and types that represent data structures (e.g.,Mercado Livre). -
Infrastructure (
src/infrastructure): Implements external services, such asMercadoLivreApiService, responsible for making HTTP calls to the Mercado Livre API. -
Application (
src/application): Contains business logic inMercadoLivreService, which processes and formats data from the infrastructure. -
Interface (
src/interface): Includes controllers (MercadoLivreToolsController) that register tools in the MCP server, define validation schemas, and return results. -
Entry Point (
src/main.ts): Initializes theMcpServer, configures the transport (StdioServerTransport), instantiates services and controllers, and starts listening on stdio.
The folder structure is as follows:
src/
├── domain/
│ └── models/ # Domain interfaces
├── infrastructure/
│ └── services/ # External API implementations (Mercado Livre)
├── application/
│ └── services/ # Business logic and data formatting
├── interface/
│ └── controllers/ # MCP tool registration and validation
└── main.ts # Server entry point
build/ # Compiled JavaScript code
.vscode/ # Contains the mcp.json file, MCP Server config
git clone git@github.com:newerton/mcp-mercado-livre.git
cd mcp-mercado-livre
npm install
npm run build- Press
Ctrl+Shift+Pand select "MCP: List Servers" - Select "products" and then "Start Server"
- Press
Ctrl+Shift+Pand select "MCP: List Servers" - Select "products" and then "Show Output"
Pull requests are welcome! Feel free to open issues and discuss improvements.
This project is licensed under the MIT license - see the LICENSE file for details.