Singapore Location Intelligence MCP

Provides real-time Singapore transport data and routing information.

Singapore Location Intelligence MCP πŸ‡ΈπŸ‡¬

CI/CD npm version License: MIT

As the creator of this project, I, Siva (Sivasubramanian Ramanathan), developed this comprehensive Singapore Location Intelligence Platform to explore the capabilities of the Model Context Protocol (MCP). My goal was to test how MCP could be leveraged to help AI accurately plan routes, while also showcasing my ability to work with various APIs and my expertise in the technologies involved.

What began as an experiment with MCP integration evolved into a sophisticated, real-world application that demonstrates the power of this exciting new protocol to create tools that can rival commercial solutions. This platform provides enterprise-grade transport routing, postal code resolution, and location intelligence with Google Maps-level detailed navigation instructions, all optimized for Singapore's unique transport ecosystem.

🌟 Key Features

🎯 NEW in v0.3.0 - MRT Exit Integration & Landmarks Tool Fix

  • πŸš‡ MRT Exit Recommendations - Google Maps-level precision with specific exit codes
  • πŸ›οΈ Enhanced Location Resolution - Fixed JSON string parsing and coordinate validation
  • πŸ“ Exit-Level Navigation - "Use Exit E (14m walk, 1 min)" for optimal station navigation
  • πŸ”§ Robust Input Handling - All location formats now work correctly
  • 🎯 Singapore-Optimized - Proper coordinate bounds and postal code validation

🎯 v0.2.7 - Weather Service Fixes & Enhanced Reliability

  • 🌦️ Robust Weather Integration - Fixed all weather API inconsistencies and crashes
  • πŸ”§ Production-Ready Error Handling - Graceful degradation when weather APIs fail
  • 🎯 Singapore Weather API Compatibility - Supports all 5 official weather endpoints
  • ⚑ Enhanced Journey Planning - Weather-aware routing with resilient fallbacks
  • πŸ›‘οΈ Zero-Crash Guarantee - Weather service failures no longer break journey planning

🎯 NEW in v0.2.1 - Weather Intelligence

  • 🌦️ Standalone Weather Tools - Comprehensive weather conditions and activity-specific advisories
  • 🎯 Activity Recommendations - Tailored advice for walking, cycling, sports, photography, dining
  • 🌑️ Comfort Analysis - Intelligent comfort level assessment with travel impact
  • ⏰ Best Time Recommendations - Optimal timing for outdoor activities based on weather

🎯 NEW in v0.2.0 - Enhanced Intelligence

  • πŸ” Advanced Fuzzy Search - "Opp Blk 910" β†’ finds "Opposite Block 910" with 95% accuracy
  • 🌦️ Weather-Aware Routing - Real-time weather impact on walking times and route suggestions
  • πŸš‡ Transfer Minimization - Smart algorithms to reduce transfers in multi-modal journeys
  • πŸ—ΊοΈ Google Maps-Quality Directions - "Turn Left To Stay On Thomson Road" level instructions
  • πŸ“ Comprehensive Stop Details - Nearby amenities, accessibility info, and location context

🎯 Core Features

  • 🎯 Advanced Postal Code Intelligence - 95% accuracy resolution for all Singapore postal codes
  • πŸ—ΊοΈ Professional Navigation Instructions - Turn-by-turn directions like "Turn Left To Stay On Thomson Road"
  • πŸš‡ Multi-Modal Transport Planning - Seamless integration of MRT, LRT, buses, and walking
  • ⏰ Singapore Time Intelligence - Business hours, rush hour detection, and timing optimization
  • πŸ” Intelligent Location Search - Fuzzy matching, typo tolerance, and smart suggestions
  • πŸ“ Comprehensive Geocoding - Forward and reverse geocoding with Singapore-specific accuracy
  • 🚌 Real-Time Transport Data - Live bus arrivals, train status, and service disruptions
  • πŸ’‘ Context-Aware Routing - Peak hour optimization, last train warnings, night bus alternatives

🎯 Real-World Problem Solved

Before: Basic transport tools with failed postal code resolution After: Enterprise-grade location intelligence platform with weather-aware routing

Singapore Transport MCP Demo

INPUT: "How to get to Suntec City from Little India MRT during heavy rain?"

OUTPUT: 
βœ… Postal Code 039594 β†’ SUNTEC CITY
🌧️ Heavy rain detected - prefer covered routes
πŸš‡ Route: DT Line (8 min) β†’ Covered walkway (6 min) 
πŸ’° Cost: $1.55 | πŸ• Duration: 32 minutes (adjusted for weather)
πŸ“ Step-by-step: "Walk 246m via covered walkway to ROCHOR MRT β†’ Take DT Line from Rochor to Promenade β†’ Use underground connection to Suntec City"
⚠️ Weather Advisory: Allow extra 5 minutes for walking segments

πŸš€ Quick Start

Installation

npx @siva-sub/mcp-public-transport

Claude Desktop Setup

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "singapore-transport": {
      "command": "npx",
      "args": ["-y", "@siva-sub/mcp-public-transport"],
      "env": {
        "LTA_ACCOUNT_KEY": "your_lta_api_key_here",
        "ONEMAP_TOKEN": "your_onemap_token_here",
        "ONEMAP_EMAIL": "your_onemap_email@example.com",
        "ONEMAP_PASSWORD": "your_onemap_password"
      }
    }
  }
}

βš™οΈ Configuration

Required Environment Variables

  • LTA_ACCOUNT_KEY: Required. Your LTA DataMall API key (Get here)

Optional Environment Variables

  • ONEMAP_TOKEN: OneMap API token for enhanced features (Register here)
  • ONEMAP_EMAIL: OneMap account email for authentication
  • ONEMAP_PASSWORD: OneMap account password for authentication
  • CACHE_DURATION: Cache duration in seconds (default: 300)
  • LOG_LEVEL: Logging level (default: info)

πŸ› οΈ Available Tools

🌍 NEW - Enhanced Location Intelligence

  • search_bus_stops ⭐ - Advanced fuzzy search with Singapore abbreviations

    • Supports: "Opp Blk 910", "Bef Jurong East MRT", "CP near Orchard"
    • Intelligent pattern recognition and typo tolerance
    • Distance-based ranking and confidence scoring
  • get_bus_stop_details ⭐ - Comprehensive stop information

    • Real-time service information and nearby amenities
    • Accessibility details and location context
    • Walking distances to nearby stops
  • plan_comprehensive_journey ⭐ - Complete multi-modal journey planning

    • Transfer minimization algorithms
    • Real-time disruption handling
    • Google Maps-quality turn-by-turn directions
    • Weather impact on walking segments
    • Supports all input types: addresses, postal codes, coordinates

🌍 Location Intelligence

  • search_location - Enhanced with fuzzy search capabilities
  • resolve_postal_code - High-accuracy Singapore postal code resolution (95% success rate)
  • reverse_geocode - Convert coordinates to addresses with Singapore-specific accuracy

🚌 Public Transport

  • get_bus_arrival - Real-time bus arrival times with crowding information
  • find_bus_stops - Find bus stops by location, name, or coordinates
  • plan_comprehensive_journey - Multi-modal journey planning with detailed instructions

πŸš‡ Train Services

  • get_train_service_status - Real-time MRT/LRT service status and disruptions

πŸš• Taxis & Ride-Hailing

  • get_nearby_taxis - Find available taxis and estimate wait times

🚦 Traffic & Roads

  • get_traffic_conditions - Live traffic conditions, incidents, and road speeds

🌦️ NEW - Weather Intelligence

  • get_weather_conditions ⭐ - Comprehensive real-time weather with travel impact

    • Real-time temperature, rainfall, humidity, and wind data
    • Comfort level analysis and walking condition ratings
    • Travel impact assessment with time adjustments
    • Activity-specific recommendations and safety advice
  • get_weather_advisory ⭐ - Activity-specific weather recommendations

    • Tailored advice for walking, cycling, outdoor dining, sports, photography
    • Suitability ratings and best time recommendations
    • Weather-specific safety guidance and precautions

πŸ“Š Enterprise Features

Advanced Routing with Weather Intelligence

// Weather-aware journey planning
{
  "primaryRoute": {
    "summary": {
      "totalTime": 1980, // seconds (adjusted for weather)
      "walkingTime": 720, // includes weather buffer
      "transfers": 1
    },
    "weatherImpact": {
      "conditions": {
        "rainfall": 12.5, // mm
        "temperature": 28, // Β°C
        "humidity": 85 // %
      },
      "advisories": [
        {
          "severity": "high",
          "type": "rain",
          "message": "Heavy rain detected. Allow extra time for walking.",
          "routingImpact": {
            "walkingTimeMultiplier": 1.5,
            "preferredModes": ["MRT", "Covered Bus Stops"]
          }
        }
      ]
    }
  }
}

Enhanced Bus Stop Search

// Fuzzy search with Singapore intelligence
{
  "query": "Opp Blk 910",
  "searchType": "fuzzy",
  "results": [
    {
      "busStopCode": "83139",
      "description": "OPP BLK 910",
      "matchScore": 0.95,
      "locationPatterns": {
        "blockNumber": "910",
        "direction": "opp"
      },
      "searchContext": {
        "queryVariations": ["opposite block 910", "opp blk 910"],
        "bestMatch": "OPP BLK 910"
      }
    }
  ]
}

Comprehensive Stop Details

// Detailed stop information with context
{
  "details": {
    "busStopCode": "83139",
    "description": "OPP BLK 910",
    "services": [...], // Real-time arrivals
    "nearbyStops": [...], // Within walking distance
    "accessibility": {
      "wheelchairAccessible": true,
      "sheltered": true,
      "tactilePaving": true
    },
    "locationContext": {
      "district": "Tampines",
      "landmarks": ["Block 910", "Tampines Mall"],
      "transportHubs": ["Tampines MRT Station"]
    },
    "nearbyAmenities": [
      {
        "name": "Tampines Mall",
        "type": "shopping",
        "distance": 250,
        "walkingTime": 3
      }
    ]
  }
}

Singapore Time Intelligence

{
  "singaporeTime": "27/06/2025, 10:58 PM",
  "businessHours": false,
  "rushHour": false,
  "contextInfo": {
    "nextRushHour": "7:00 AM tomorrow",
    "travelRecommendation": "Off-peak travel - comfortable journey expected"
  }
}

Postal Code Intelligence

{
  "postalCode": "039594",
  "location": {
    "name": "SUNTEC CITY",
    "address": "3 TEMASEK BOULEVARD SUNTEC CITY SINGAPORE 039594",
    "district": "Downtown Core",
    "areaType": "Central Singapore",
    "confidence": 0.98
  }
}

🎯 Use Cases

1. Navigation Applications

  • Weather-aware route planning
  • Detailed turn-by-turn directions
  • Multi-modal journey optimization
  • Real-time traffic integration

2. Delivery & Logistics

  • Postal code validation and resolution
  • Optimal route planning with weather considerations
  • Address standardization and fuzzy matching

3. Urban Planning

  • Transport accessibility analysis
  • Weather impact on pedestrian traffic
  • Peak hour traffic optimization
  • Public transport coverage mapping

4. Tourism & Hospitality

  • Tourist-friendly directions with landmarks
  • Weather-appropriate route suggestions
  • Public transport guidance
  • Location discovery with fuzzy search

πŸ“ˆ Performance & Reliability

  • Sub-3-second route planning with weather integration
  • 5-minute weather data cache for real-time responsiveness
  • Intelligent caching with location and weather-aware TTL
  • Graceful degradation during API maintenance
  • 95% postal code resolution accuracy
  • Real-time data integration with official Singapore APIs
  • Fuzzy search accuracy of 90%+ for Singapore terms

πŸ”§ Advanced Configuration

Weather-Aware Route Preferences

{
  "routingOptions": {
    "includeWeatherImpact": true,
    "maxWalkingDistance": 800,
    "weatherSensitivity": "high",
    "preferredModes": ["MRT", "Covered Bus Stops"],
    "minimizeTransfers": true
  }
}

Fuzzy Search Configuration

{
  "searchOptions": {
    "enableFuzzySearch": true,
    "minScore": 0.3,
    "singaporeAbbreviations": true,
    "typoTolerance": true
  }
}

Business Hours Configuration

{
  "businessHours": {
    "weekdays": { "start": 9, "end": 18 },
    "saturday": { "start": 9, "end": 13 },
    "sunday": { "closed": true }
  }
}

🀝 API Integration

OneMap Integration

  • Authentication: Automatic token refresh with 3-day TTL
  • Geocoding: High-accuracy address resolution with fuzzy matching
  • Routing: Professional-grade turn-by-turn directions
  • Weather Integration: Real-time weather data from Singapore APIs

LTA DataMall Integration

  • Real-time Data: Bus arrivals, train status, traffic conditions
  • Transport Network: Complete bus and train network data
  • Service Alerts: Live disruption and maintenance notifications
  • Enhanced Error Handling: Graceful degradation and retry logic

Singapore Weather API Integration

  • Real-time Data: Rainfall, temperature, humidity, wind speed
  • 5-minute Updates: Fresh weather data for accurate routing
  • Location-based: Weather conditions for specific route segments
  • Advisory Generation: Smart recommendations based on conditions

πŸš€ Development

Local Development

git clone https://github.com/siva-sub/MCP-Public-Transport
cd MCP-Public-Transport
npm install
cp .env.example .env.local
# Add your API keys to .env.local
npm run dev

Building

npm run build    # Builds both ESM and CJS versions
npm run test     # Runs comprehensive test suite
npm run lint     # TypeScript and ESLint checks

Testing

# Unit tests
npm run test

# Integration tests with real APIs
npm run test:integration

# Performance tests
npm run test:performance

πŸ“¦ Architecture

src/
β”œβ”€β”€ services/           # Core business logic
β”‚   β”œβ”€β”€ lta.ts         # LTA DataMall integration
β”‚   β”œβ”€β”€ onemap.ts      # OneMap API with authentication
β”‚   β”œβ”€β”€ weather.ts     # ⭐ Real-time weather integration
β”‚   β”œβ”€β”€ routing.ts     # ⭐ Enhanced multi-modal routing
β”‚   β”œβ”€β”€ fuzzySearch.ts # ⭐ Singapore-optimized fuzzy search
β”‚   β”œβ”€β”€ time.ts        # Singapore time intelligence
β”‚   β”œβ”€β”€ postalCode.ts  # Postal code validation & resolution
β”‚   └── cache.ts       # Intelligent caching layer
β”œβ”€β”€ tools/             # MCP tool implementations
β”‚   β”œβ”€β”€ location/      # Enhanced location intelligence tools
β”‚   β”œβ”€β”€ bus/           # ⭐ Enhanced bus tools with fuzzy search
β”‚   β”‚   β”œβ”€β”€ search.ts  # ⭐ Advanced bus stop search
β”‚   β”‚   └── details.ts # ⭐ Comprehensive stop details
β”‚   β”œβ”€β”€ routing/       # ⭐ Enhanced journey planning tools
β”‚   β”‚   └── enhanced.ts# ⭐ Weather-aware optimal routing
β”‚   β”œβ”€β”€ train/         # Train service tools
β”‚   └── traffic/       # Traffic and road tools
β”œβ”€β”€ types/             # TypeScript interfaces
β”‚   β”œβ”€β”€ location.ts    # Location and search types
β”‚   β”œβ”€β”€ transport.ts   # Transport system types
β”‚   β”œβ”€β”€ search.ts      # Search and query types
β”‚   └── time.ts        # Singapore time types
└── utils/             # Shared utilities
    β”œβ”€β”€ errors.ts      # Custom error handling
    β”œβ”€β”€ logger.ts      # Structured logging
    └── validation.ts  # Input validation

🌟 What Makes This Special

  1. Singapore-Optimized: Built specifically for Singapore's unique transport ecosystem with local intelligence
  2. Weather-Aware: Real-time weather integration affects routing decisions and walking time estimates
  3. Professional-Grade: Routing instructions comparable to Google Maps with fuzzy search capabilities
  4. Real-Time Context: Business hours, rush hour, weather, and timing intelligence
  5. High Accuracy: 95% success rate for postal code resolution, 90%+ fuzzy search accuracy
  6. Enterprise-Ready: Comprehensive error handling, weather resilience, and performance optimization
  7. Developer-Friendly: Full TypeScript support with comprehensive documentation
  8. Transfer Minimization: Smart algorithms to reduce transfers in multi-modal journeys

🎯 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

  • Singapore Land Authority (SLA) for OneMap API
  • Land Transport Authority (LTA) for DataMall API
  • Singapore Meteorological Service for weather data
  • Model Context Protocol for the extensible framework
  • Singapore Open Data initiative for public transport data

Built with ❀️ for Singapore's smart city initiative and MCP exploration

πŸ“Š Version 0.2.0 Statistics

  • 11 Total Tools (up from 8)
  • 4 New Major Services added
  • 3 New Tools with advanced capabilities
  • Weather API Integration for real-time conditions
  • Fuzzy Search Engine with 50+ Singapore abbreviations
  • Google Maps-Quality turn-by-turn directions
  • Transfer Minimization algorithms

Related Servers