Sustainable-path-mcp-server

RIKTESH89/Sustainable-path-mcp-server

3.2

If you are the rightful owner of Sustainable-path-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server implementation for sustainable travel route planning and environmental impact analysis.

Tools
4
Resources
0
Prompts
0

Sustainable Travel AI Agent - MCP Server

A Model Context Protocol (MCP) server implementation for sustainable travel route planning and environmental impact analysis. This server provides AI agents with tools to calculate eco-friendly travel routes, carbon footprints, cost savings, and health benefits.

Features

🌱 Core Capabilities

  • Sustainable Route Planning: Mixed-mode transportation combining walking and public transit
  • Carbon Footprint Analysis: Real-time CO2 emissions calculation for different transport modes
  • Cost-Benefit Analysis: Compare costs between sustainable and conventional transport
  • Health Impact Tracking: Calculate calories burned, steps walked, and health benefits
  • Personalized Recommendations: Transport suggestions based on user preferences and constraints

πŸš€ MCP Tools Available

  1. calculate_sustainable_route - Generate eco-friendly multi-modal routes
  2. calculate_carbon_footprint - Analyze environmental impact by transport mode
  3. calculate_health_benefits - Track fitness and wellness benefits
  4. get_transport_recommendations - Get personalized transport suggestions

πŸ“š MCP Resources

  • sustainable-travel-guide - Comprehensive sustainable travel practices guide
  • carbon-calculator-data - Emission factors and calculation methodology

Architecture

The server implements the architecture described in the project requirements:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User Client   │───▢│   MCP Server     │───▢│  Calculation    β”‚
β”‚   (AI Agent)    β”‚    β”‚  (SSE Transport) β”‚    β”‚   Engine        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   Route & Impact β”‚
                        β”‚   Analysis       β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation

Prerequisites

  • Python 3.10 or higher
  • Virtual environment (recommended)

Setup

  1. Clone or download the project:

    cd sustainableAI
    
  2. Activate the virtual environment:

    # Windows
    .venv\Scripts\activate
    
    # Linux/Mac
    source .venv/bin/activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Usage

Starting the Server

Development Mode (with auto-reload)
python server.py
Production Mode
uvicorn server:app --host 0.0.0.0 --port 8000
Using MCP CLI (recommended for development)
mcp dev server.py

Server Configuration

The server runs on http://localhost:8000 by default with SSE (Server-Sent Events) transport.

Environment Variables:

  • MCP_SERVER_PORT: Server port (default: 8000)
  • MCP_TRANSPORT_TYPE: Transport type - sse (default) or streamable_http

Example Usage

1. Calculate Sustainable Route
# Tool call example
result = calculate_sustainable_route(
    origin_lat=28.6139,
    origin_lon=77.2090,
    origin_address="India Gate, New Delhi",
    dest_lat=28.5355,
    dest_lon=77.3910,
    dest_address="Noida Sector 62",
    user_weight_kg=70.0,
    car_fuel_efficiency=15.0,
    fuel_price_per_liter=100.0
)

Response:

{
  "success": true,
  "route": {
    "segments": [
      {
        "mode": "walking",
        "distance_km": 1.0,
        "duration_minutes": 12.0,
        "cost_inr": 0.0,
        "carbon_emissions_kg": 0.0,
        "description": "Walk 1.0 km from India Gate, New Delhi"
      },
      {
        "mode": "metro",
        "distance_km": 23.5,
        "duration_minutes": 56.4,
        "cost_inr": 70.5,
        "carbon_emissions_kg": 0.964,
        "description": "Take metro for 23.5 km"
      }
    ],
    "total_distance_km": 24.5,
    "total_duration_minutes": 68.4,
    "total_cost_inr": 70.5,
    "steps_walked": 1300,
    "calories_burned": 70.0,
    "money_saved_vs_car": 125.5,
    "carbon_saved_vs_car": 4.181
  }
}
2. Get Transport Recommendations
recommendations = get_transport_recommendations(
    distance_km=5.0,
    time_available_minutes=60.0,
    budget_inr=50.0,
    prioritize="environment"
)
3. Calculate Carbon Footprint
footprint = calculate_carbon_footprint(
    transport_mode="bus",
    distance_km=10.0
)

Integration with AI Agents

Claude Desktop Integration

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "sustainable-travel": {
      "command": "python",
      "args": ["path/to/sustainableAI/server.py"],
      "env": {
        "MCP_TRANSPORT_TYPE": "sse"
      }
    }
  }
}

Custom MCP Client

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def use_sustainable_travel_agent():
    server_params = StdioServerParameters(
        command="python",
        args=["server.py"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the session
            await session.initialize()
            
            # Call tools
            result = await session.call_tool(
                "calculate_sustainable_route",
                {
                    "origin_lat": 28.6139,
                    "origin_lon": 77.2090,
                    "origin_address": "India Gate",
                    "dest_lat": 28.5355,
                    "dest_lon": 77.3910,
                    "dest_address": "Noida"
                }
            )
            print(result)

API Reference

Tools

calculate_sustainable_route

Calculates an eco-friendly multi-modal route between two points.

Parameters:

  • origin_lat (float): Origin latitude
  • origin_lon (float): Origin longitude
  • origin_address (str): Origin address description
  • dest_lat (float): Destination latitude
  • dest_lon (float): Destination longitude
  • dest_address (str): Destination address description
  • user_weight_kg (float, optional): User weight for calorie calculation (default: 70.0)
  • car_fuel_efficiency (float, optional): Car fuel efficiency in km/L (default: 15.0)
  • fuel_price_per_liter (float, optional): Fuel price in INR/L (default: 100.0)
calculate_carbon_footprint

Analyzes carbon emissions for a specific transport mode and distance.

Parameters:

  • transport_mode (str): Transport mode ('walking', 'bus', 'metro', 'car')
  • distance_km (float): Distance in kilometers
calculate_health_benefits

Calculates health benefits from walking.

Parameters:

  • walking_distance_km (float): Walking distance in kilometers
  • user_weight_kg (float, optional): User weight in kg (default: 70.0)
get_transport_recommendations

Provides personalized transport recommendations based on constraints.

Parameters:

  • distance_km (float): Journey distance
  • time_available_minutes (float): Available time for journey
  • budget_inr (float): Budget in INR
  • prioritize (str, optional): Priority ('environment', 'cost', 'time', 'health')

Resources

sustainable-travel-guide

Comprehensive guide for sustainable travel practices including transport mode comparisons and tips.

carbon-calculator-data

JSON data containing emission factors, calculation methodology, and environmental context.

Emission Factors

Transport ModeCO2 Emissions (kg/km)Cost (INR/km)Speed (km/h)
Walking0.0000.005
Bus0.0892.0025
Metro0.0413.0025
Car0.2108.0030

Development

Running Tests

# Install test dependencies
pip install pytest pytest-asyncio

# Run tests
pytest tests/

Code Structure

sustainableAI/
β”œβ”€β”€ server.py              # Main MCP server implementation
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ README.md             # This file
└── .venv/                # Virtual environment

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:

  1. Check the MCP Documentation
  2. Review the Python SDK Examples
  3. Open an issue in this repository

Acknowledgments