MCP Inventario
Enables inventory management through MongoDB with tools for creating, listing, searching, updating, and deleting items and categories. Supports natural language interactions via Groq AI integration.
README
📦 MCP Inventario - Sistema Modular
Sistema de inventario implementado como servidor MCP (Model Context Protocol) con arquitectura modular y soporte para múltiples bases de datos.
🚀 Inicio Rápido
Instalación
npm install
Configurar MongoDB
Asegúrate de tener MongoDB corriendo en localhost:27017, o configura la variable de entorno:
export MONGODB_URI="mongodb://localhost:27017/inventario"
Ejecutar el Servidor MCP
node index.js
Probar con el Cliente de Pruebas
node test-client.js
Chat con Groq (Requiere API Key)
export GROQ_API_KEY="tu-api-key"
node chat-groq.js
📁 Archivos Principales
✅ Archivos que DEBES USAR
| Archivo | Propósito |
|---|---|
index.js |
Servidor principal modular - Punto de entrada del servidor MCP |
test-client.js |
Cliente de pruebas para probar las herramientas MCP |
chat-groq.js |
Chat interactivo usando Groq AI + herramientas MCP |
src/ |
Directorio con toda la lógica modular del proyecto |
⚠️ Archivo OBSOLETO (No usar)
| Archivo | Estado |
|---|---|
mcp-server.js |
OBSOLETO - Reemplazado por index.js + estructura modular en src/ |
Nota:
mcp-server.jsse mantiene solo como referencia. Toda la funcionalidad está ahora en la estructura modular.
🏗️ Estructura del Proyecto
experiments-mcp/
├── index.js ✅ Servidor principal (USA ESTE)
├── chat-groq.js ✅ Chat con Groq AI
├── test-client.js ✅ Cliente de pruebas
├── mcp-server.js ⚠️ OBSOLETO (no usar)
│
└── src/
├── database/ # Gestión de base de datos
│ ├── db.js # Clase Database (multi-conexión)
│ ├── models/ # Modelos Mongoose
│ └── examples/ # Ejemplos de uso
│
├── handlers/ # Lógica de negocio
│ ├── index.js # Router de handlers
│ ├── item.handler.js # Operaciones de items
│ └── categoria.handler.js
│
├── tools/ # Definiciones MCP
│ └── index.js # Registro de herramientas
│
├── server/ # Configuración servidor
│ ├── index.js # Setup del servidor MCP
│ └── config.js # Configuración
│
└── mockups/ # Datos de prueba
├── categorias.mc.js
└── items.mc.js
🛠️ Herramientas Disponibles
- listar_items - Lista items con filtro opcional por categoría
- buscar_item - Busca items por nombre
- contar_items - Cuenta items y calcula totales
- crear_items - Crea uno o más items
- eliminar_item - Elimina un item por ID
- actualizar_item - Actualiza un item existente
- listar_categorias - Lista todas las categorías
📚 Documentación
- ARCHITECTURE.md - Documentación detallada de la arquitectura
- Ver ejemplos en
src/database/examples/
🔄 Migración desde la versión anterior
Si estabas usando mcp-server.js:
-
Cambiar referencias: Actualiza cualquier script o configuración que apunte a
mcp-server.jspara que useindex.js -
Funcionalidad idéntica: Todas las herramientas funcionan igual, solo el código está mejor organizado
-
Beneficios:
- ✅ Código más organizado y fácil de mantener
- ✅ Separación de responsabilidades
- ✅ Más fácil agregar nuevas herramientas
- ✅ Soporte para múltiples bases de datos
- ✅ Mejor para testing
🧪 Testing
Probar todas las herramientas
node test-client.js
Probar con chat interactivo
export GROQ_API_KEY="tu-clave"
node chat-groq.js
Ejemplo de conversación:
💬 Tú: Lista todos los items de electrónica
🤖 Groq: Aquí están los items de electrónica:
- Laptop Dell (5 unidades) - $800
- Mouse Logitech (15 unidades) - $25
...
🔐 Variables de Entorno
# MongoDB (opcional, default: mongodb://localhost:27017/inventario)
export MONGODB_URI="mongodb://localhost:27017/inventario"
# Groq API (solo para chat-groq.js)
export GROQ_API_KEY="tu-api-key"
🆘 Troubleshooting
Error: "Cannot connect to MongoDB"
- Verifica que MongoDB esté corriendo:
mongosh - Verifica la URI de conexión
Error: "GROQ_API_KEY not found"
- Solo necesario para
chat-groq.js - Obtén tu API key en: https://console.groq.com
Error: "Module not found"
npm install
📖 Más Información
- Arquitectura completa: Ver ARCHITECTURE.md
- Ejemplos de múltiples conexiones: Ver
src/database/examples/multi-connection-example.js
📝 Licencia
MIT
¿Dudas? Revisa la documentación de arquitectura o los ejemplos en src/database/examples/.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.