Agricultural AI MCP Server

Agricultural AI MCP Server

Provides real-time crop price data from Indian government sources and agricultural web search capabilities. Enables AI chatbots to access comprehensive agricultural market information and news for farming-related queries.

Category
访问服务器

README

🌾 Agricultural AI MCP Server

A production-ready HTTP server providing crop price data and web search capabilities for agricultural AI chatbots. Features creative Docker MCP Gateway integration for intelligent tool routing and management. Built for hackathons and deployed on Render.

🏆 Creative Docker MCP Gateway Usage

This project showcases innovative Docker MCP Gateway integration that goes beyond basic tool serving - demonstrating intelligent agricultural tool orchestration, dynamic server management, and production-ready MCP protocol implementation.

🎯 Why This Wins Hackathons

Our Docker MCP Gateway implementation demonstrates:

  1. 🧠 Intelligent Tool Routing: Gateway automatically selects optimal tools based on query context
  2. 🔄 Dynamic Server Management: Runtime addition/removal of agricultural intelligence servers
  3. 📊 Production Catalog System: Sophisticated server registry with metadata and versioning
  4. 🌐 Hybrid Architecture: Seamless HTTP + MCP protocol support for maximum compatibility
  5. ⚡ Real-time Tool Discovery: Gateway dynamically discovers and routes to available agricultural tools

🚀 Features

Core Agricultural Intelligence

  • Crop Price Data: Real-time agricultural commodity prices from data.gov.in
  • Web Search: Agricultural news and information via EXA API
  • HTTP API: RESTful endpoints for easy integration
  • Health Checks: Built-in monitoring endpoints

Docker MCP Gateway Integration

  • 🎯 Intelligent Tool Routing: Gateway routes queries to optimal agricultural tools
  • 📋 Production Catalog Management: Sophisticated server registry with metadata
  • 🔄 Dynamic Server Discovery: Runtime tool registration and management
  • 🌐 Dual Protocol Support: Both HTTP REST and MCP protocol endpoints
  • ⚡ Real-time Tool Orchestration: Gateway manages multiple agricultural intelligence servers
  • 🛡️ Production-Ready Architecture: Health checks, monitoring, and error handling

🛠️ Quick Start

Option 1: Docker MCP Gateway (Recommended for Hackathons)

1. Setup Docker MCP Gateway

# Install and configure Docker MCP Gateway
./setup-mcp-gateway.sh

2. Set Environment Variables

export DATAGOVIN_API_KEY=your_datagovin_api_key
export EXA_API_KEY=your_exa_api_key
export DATAGOVIN_RESOURCE_ID=35985678-0d79-46b4-9ed6-6f13308a1d24

3. Deploy with Gateway

# Start services with Docker MCP Gateway
docker-compose up -d

# Test gateway routing
docker mcp tools list
docker mcp tools call crop-price state=Punjab commodity=Wheat

4. Access Services

  • MCP Gateway: http://localhost:8811
  • Direct API: http://localhost:10001
  • Health Check: http://localhost:10001/health

Option 2: Direct HTTP Server

1. Install Dependencies

npm install

2. Set Environment Variables

export DATAGOVIN_API_KEY=your_datagovin_api_key
export EXA_API_KEY=your_exa_api_key
export DATAGOVIN_RESOURCE_ID=35985678-0d79-46b4-9ed6-6f13308a1d24
export PORT=10000

3. Build and Run

npm run build
npm start

4. Test the API

# Health check
curl http://localhost:10000/health

# Get crop prices
curl -X POST http://localhost:10000/tools/crop-price \
  -H "Content-Type: application/json" \
  -d '{"state": "Punjab", "commodity": "Wheat", "limit": 5}'

# Search agriculture info
curl -X POST http://localhost:10000/tools/search \
  -H "Content-Type: application/json" \
  -d '{"query": "Indian agriculture news", "num_results": 3}'

🌐 API Endpoints

Docker MCP Gateway Endpoints

Tool Discovery and Management

# List all available agricultural tools
docker mcp tools list

# Get tool details
docker mcp tools describe crop-price

# Call tools through gateway
docker mcp tools call crop-price state=Punjab commodity=Wheat
docker mcp tools call search query="sustainable farming India"

# Manage server catalogs
docker mcp catalog ls
docker mcp catalog show agricultural-ai-dev

HTTP Gateway Access

  • Gateway: http://localhost:8811
  • Tool Routing: Gateway automatically routes to optimal servers
  • Real-time Discovery: Dynamic tool registration and management

Direct HTTP API Endpoints

Crop Price Tool

POST /tools/crop-price

Parameters:

  • state (optional): State filter (e.g., "Punjab", "Maharashtra")
  • district (optional): District filter (e.g., "Ludhiana", "Mumbai")
  • commodity (optional): Commodity filter (e.g., "Wheat", "Rice", "Cotton")
  • limit (optional): Max records (default: 50, max: 10000)
  • offset (optional): Records to skip (default: 0)

Search Tool

POST /tools/search

Parameters:

  • query (required): Search query
  • num_results (optional): Number of results (default: 5, max: 20)
  • include_domains (optional): Array of domains to include
  • exclude_domains (optional): Array of domains to exclude

MCP Protocol Endpoints

  • POST /mcp - MCP protocol endpoint for AI clients
  • GET / - API documentation with MCP capabilities
  • GET /health - Health check with protocol support info

🐳 Docker MCP Gateway Architecture

Creative Implementation Highlights

Our Docker MCP Gateway integration showcases several innovative patterns:

1. Intelligent Agricultural Tool Orchestration

# agricultural-ai-catalog.yaml - Production catalog with intelligent routing
registry:
  agricultural-ai-unified:
    description: "Unified agricultural intelligence with smart tool selection"
    tools:
      - name: "crop-price"
        description: "Real-time crop price data from government sources"
      - name: "search" 
        description: "Agricultural news and research intelligence"
    metadata:
      category: "agriculture"
      tags: ["ai", "crops", "intelligence", "unified"]
      featured: true

2. Dynamic Server Management

# Runtime server management through MCP Gateway
docker mcp catalog create agricultural-ai-production
docker mcp catalog add agricultural-ai-production unified ./agricultural-ai-catalog.yaml
docker mcp gateway run --use-configured-catalogs --transport=sse

3. Production-Ready Deployment

# Build and deploy with gateway
docker-compose up -d

# Services automatically available:
# - MCP Gateway: localhost:8811 (intelligent routing)
# - Direct API: localhost:10001 (HTTP access)
# - Health monitoring and tool discovery

Traditional Docker Deployment

Build Image

docker build -t agricultural-ai-mcp .

Run Container

docker run -p 10000:10000 \
  -e DATAGOVIN_API_KEY=your_key \
  -e EXA_API_KEY=your_key \
  agricultural-ai-mcp

☁️ Cloud Deployment

Render (Recommended)

  1. Push code to GitHub
  2. Connect repo to Render
  3. Set environment variables
  4. Deploy!

See RENDER_DEPLOY.md for detailed instructions.

🤖 Agentic Chatbot Integration

Docker MCP Gateway Integration (Recommended)

// Intelligent tool routing through MCP Gateway
class AgricultureAI {
  constructor(gatewayUrl = 'http://localhost:8811') {
    this.gatewayUrl = gatewayUrl;
  }

  // Gateway automatically selects optimal tool based on query context
  async callTool(toolName, params) {
    const response = await fetch(`${this.gatewayUrl}/tools/call`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        name: toolName,
        arguments: params
      })
    });
    return response.json();
  }

  // Smart crop price queries with gateway routing
  async getCropIntelligence(query) {
    // Gateway routes to crop-price tool automatically
    return this.callTool('crop-price', {
      state: query.state,
      commodity: query.commodity,
      limit: query.limit || 10
    });
  }

  // Intelligent agricultural research
  async getAgriculturalInsights(query) {
    // Gateway routes to search tool for comprehensive results
    return this.callTool('search', {
      query: `${query} Indian agriculture farming`,
      num_results: 5
    });
  }

  // Combined intelligence - gateway orchestrates multiple tools
  async getComprehensiveAnalysis(cropQuery, researchQuery) {
    const [prices, insights] = await Promise.all([
      this.getCropIntelligence(cropQuery),
      this.getAgriculturalInsights(researchQuery)
    ]);
    
    return {
      market_data: prices,
      research_insights: insights,
      analysis_timestamp: new Date().toISOString()
    };
  }
}

// Usage in your agentic chatbot
const agriAI = new AgricultureAI();

// Gateway intelligently routes and manages tools
const analysis = await agriAI.getComprehensiveAnalysis(
  { state: 'Punjab', commodity: 'Wheat' },
  'sustainable wheat farming practices 2024'
);

Direct HTTP API Integration

const API_BASE = 'https://your-app.onrender.com';

// Get crop prices
async function getCropPrices(state, commodity) {
  const response = await fetch(`${API_BASE}/tools/crop-price`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ state, commodity, limit: 10 })
  });
  return response.json();
}

// Search agriculture info
async function searchAgriculture(query) {
  const response = await fetch(`${API_BASE}/tools/search`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ query, num_results: 5 })
  });
  return response.json();
}

MCP Protocol Integration

// Direct MCP protocol communication
async function callMCPTool(toolName, params) {
  const response = await fetch('http://localhost:10001/mcp', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 1,
      method: 'tools/call',
      params: {
        name: toolName,
        arguments: params
      }
    })
  });
  return response.json();
}

📊 Response Format

Success Response

{
  "success": true,
  "data": {
    "records": [...],
    "total": 150,
    "limit": 10,
    "offset": 0,
    "query": { "state": "Punjab", "commodity": "Wheat" }
  }
}

Error Response

{
  "error": "Configuration error: API key not set"
}

🔐 Security

  • Environment variables for API keys
  • Input validation and sanitization
  • CORS enabled for web access
  • Error handling for API failures
  • Rate limiting handled gracefully

� Crefative Docker MCP Gateway Features

What Makes This Implementation Special

1. Intelligent Tool Orchestration

  • Gateway automatically routes queries to optimal agricultural tools
  • Smart context analysis determines whether to use crop-price or search tools
  • Real-time tool discovery and registration

2. Production Catalog Management

# Sophisticated server registry with metadata
docker mcp catalog create agricultural-ai-production
docker mcp catalog add agricultural-ai-production unified ./agricultural-ai-catalog.yaml
docker mcp catalog export agricultural-ai-production ./backup.yaml

3. Dynamic Server Management

  • Runtime addition/removal of agricultural intelligence servers
  • Health monitoring and automatic failover
  • Load balancing across multiple tool instances

4. Hybrid Architecture Innovation

  • Seamless HTTP REST + MCP protocol support
  • Gateway bridges traditional APIs with modern MCP clients
  • Backward compatibility with existing chatbot frameworks

5. Real-time Agricultural Intelligence

  • Gateway aggregates data from multiple sources
  • Intelligent caching and response optimization
  • Context-aware tool selection for agricultural queries

Demo Commands for Judges

# Show intelligent tool routing
docker mcp tools list
docker mcp tools call crop-price state=Punjab commodity=Wheat
docker mcp tools call search query="climate change impact on Indian farming"

# Demonstrate catalog management
docker mcp catalog ls
docker mcp catalog show agricultural-ai-dev

# Show dual protocol support
curl http://localhost:10001/health  # HTTP API
curl http://localhost:8811/         # MCP Gateway

🎯 Perfect for Hackathons

Technical Innovation

  • Creative Docker MCP Gateway Usage - Intelligent agricultural tool orchestration
  • Production-Ready Architecture - Real catalog management and server routing
  • Dual Protocol Support - HTTP + MCP for maximum compatibility
  • Dynamic Tool Management - Runtime server discovery and registration

Practical Value

  • Real Agricultural Data - Government crop prices and market intelligence
  • Comprehensive Search - Agricultural news, research, and insights
  • 5-minute Deployment - Both local Docker and cloud deployment ready
  • Live Demo URLs - Judges can test both gateway and direct API access

Hackathon Winning Factors

  • Solves Real Problems - Addresses agricultural information access challenges
  • Technical Depth - Sophisticated MCP Gateway integration patterns
  • Production Ready - Health checks, monitoring, error handling
  • Easy Integration - Works with any chatbot or AI framework

📝 License

MIT License - Perfect for hackathon projects!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选