agroagent
AgroAgent
面向智利农业领域的AI代理,采用基于**模型上下文协议(MCP)**的代理架构构建。不同于单体后端,四个独立的MCP服务器暴露专用工具,由编排器通过Anthropic SDK的代理循环进行协调。
架构
apps/
web/ Next.js 16 + TypeScript + Tailwind v4 + Recharts
orchestrator/ FastAPI -- MCP host + agent loop (Anthropic SDK) + rutas REST de dashboard
mcp-servers/
mcp-weather/ tool: get_weather_forecast (Open-Meteo)
mcp-prices/ tool: get_commodity_price (datos abiertos ODEPA)
mcp-db/ tools: get_farmer_history, register_planting (PostgreSQL/SQLAlchemy async)
mcp-rag/ tool: search_sag_documents (RAG sobre normativa SAG -- Pinecone + Voyage AI)
packages/
shared-types/ Modelos Pydantic compartidos entre orchestrator y mcp-servers编排器作为MCP客户端连接到4个服务器,将其工具目录聚合为一个整体,并暴露:
POST /chat—— 对话端点(Claude根据上下文决定使用哪些工具)GET /weather、GET /farmers/{id}/history、GET /prices/trend—— 面向仪表板的确定性REST路由,直接调用工具而不经过LLM
项目的价值不在于单独暴露每个数据源,而在于让代理交叉关联这些数据:例如,将农户的种植历史与其所在区域的天气预报以及当前产品价格关联起来,从而提出具体决策建议,并在适当时引用对应的SAG决议。
Related MCP server: leafengines-mcp-server
技术栈
后端:Python 3.12+、FastAPI、
mcpSDK(v2)、SQLAlchemy异步 + asyncpg、Pinecone、Voyage AI、Anthropic SDK、uv(monorepo工作区)前端:Next.js(App Router)、TypeScript、Tailwind CSS v4、Recharts、pnpm
数据:PostgreSQL(Docker)、Open-Meteo API、ODEPA(CKAN数据存储API)、SAG规范文档
环境要求
Python 3.12+ 和
uvNode 20+ 和
pnpmDocker(用于PostgreSQL)
API密钥:Anthropic、Pinecone、Voyage AI
配置
# Backend (Python workspace completo)
uv sync --all-packages
# Frontend
cd apps/web && pnpm install && cd ../..
# Base de datos
docker compose up -d postgres创建 apps/web/.env.local:
NEXT_PUBLIC_ORCHESTRATOR_URL=http://localhost:3001启动项目(6个进程)
# Terminal 1
uv run --package mcp-weather uvicorn mcp_weather.app:app --reload --port 4001
# Terminal 2
uv run --package mcp-prices uvicorn mcp_prices.app:app --reload --port 4002
# Terminal 3 (ajusta el puerto de Postgres si no usas el 5432 por defecto)
DATABASE_URL="postgresql+asyncpg://agroagent:agroagent@localhost:5432/agroagent" \
uv run --package mcp-db uvicorn mcp_db.app:app --reload --port 4004
# Terminal 4
PINECONE_API_KEY="..." VOYAGE_API_KEY="..." \
uv run --package mcp-rag uvicorn mcp_rag.app:app --reload --port 4005
# Terminal 5
ANTHROPIC_API_KEY="..." \
uv run --package orchestrator uvicorn orchestrator.app:app --reload --port 3001
# Terminal 6
cd apps/web && pnpm dev前端位于 http://localhost:3000。
架构决策
MCP传输:streamable-HTTP,而非stdio——每个MCP服务器都是独立服务,拥有自己的端口/容器,更贴近真实的微服务部署。
后端采用Python/FastAPI而非NestJS/TypeScript:这是基于市场需求做出的审慎决策,同时展示多语言灵活性(前端仍使用TS/React)。
RAG:分块处理遵循智利法律决议的编号结构(
2.1、3.1.1等),而非按固定字符数切分;每个块的元数据包含决议编号,以便代理能够引用来源。REST路由与代理分离:仪表板不经过LLM获取确定性数据(天气、历史记录、价格)——避免不必要的成本和延迟;两层复用相同的底层MCP工具。
已知限制 / 待办事项
无身份验证:
farmer_id显式传递,没有用户会话。没有用于创建新农户的路由(
POST /farmers)——测试记录为手动插入。mcp-rag不支持无文本层的扫描版PDF(需要OCR)。没有针对单个服务的
Dockerfile——docker-compose.yml仅覆盖PostgreSQL。mcp-db中的作物名称未与mcp-prices中ODEPA的产品名称进行标准化对齐。
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server enabling AI agents to manage Bitrix24 features via standardized protocol
MCP server connecting AI agents to non-custodial staking data across 130+ networks.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server that provides real-time access to Brazilian agricultural data, including commodity prices, crop estimates, climate information, and deforestation rates. It integrates data from 19 public sources like CEPEA, CONAB, and IBGE to enable LLMs to analyze the Brazilian agribusiness sector.14150 PyPI28MIT
- AlicenseNot gradedqualityCmaintenanceAgricultural intelligence MCP server providing soil analysis, crop recommendations, weather forecasts, and environmental impact assessment.5MIT
- AlicenseNot gradedqualityBmaintenanceEU Crop Intelligence MCP Server — Yield forecasts, weather analysis, and phenology models for 15 countries. AI agent-native, multi-source intelligence (NASA POWER, Eurostat, Open-Meteo).MIT
- AlicenseAqualityDmaintenanceMCP Server for accessing 36 Brazilian public data sources and 1 agent, enabling AI agents to query government data on economy, legislation, transparency, judiciary, elections, environment, health, and more.6MIT