loading…
Search for a command to run...
loading…
Provides tools for managing a product catalog, including functions to list, add, and retrieve product statistics. It enables AI agents to perform inventory oper
Provides tools for managing a product catalog, including functions to list, add, and retrieve product statistics. It enables AI agents to perform inventory operations and data analysis through a standardized interface.
Реализация тестового задания:
.
├── app
│ ├── agent
│ │ ├── graph.py
│ │ ├── mcp_client.py
│ │ ├── mock_llm.py
│ │ └── tools.py
│ ├── main.py
│ └── schemas.py
├── mcp_server
│ ├── data/products.json
│ └── server.py
├── tests
│ ├── test_agent.py
│ ├── test_api.py
│ └── test_mcp_server.py
├── Dockerfile
├── docker-compose.yml
└── requirements.txt
В mcp_server/server.py реализованы tools:
list_products(category: str | None = None)get_product(product_id: int)add_product(name: str, price: float, category: str, in_stock: bool = True)get_statistics()Особенности:
stdio@mcp.toolValueError, если товар не найденanalyze: mock LLM (rule-based) разбирает запрос и формирует action + params.execute: вызывает MCP tools через stdio-клиент + custom tools.respond: формирует финальный текст пользователю.Custom tools:
calculate_discountformat_products, format_statistics)POST /api/v1/agent/queryGET /healthПример запроса:
curl -X POST "http://localhost:8000/api/v1/agent/query" \
-H "Content-Type: application/json" \
-d '{"query":"Покажи все продукты в категории Электроника"}'
docker compose up --build
API будет доступен на http://localhost:8000.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
pytest -q
Покрытие требований тестами:
tests/test_mcp_server.py:ValueErrortests/test_agent.py:tests/test_api.py:POST /api/v1/agent/queryПокажи все продукты в категории ЭлектроникаКакая средняя цена продуктов?Добавь новый продукт: Мышка, цена 1500, категория ЭлектроникаПосчитай скидку 15% на товар с ID 1Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"product-management-mcp-server": {
"command": "npx",
"args": []
}
}
}