Skip to content

Tatsuru-Kikuchi/MCP-traffic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

87 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš‡ MCP Traffic - Tokyo Traffic Data Collection System

Deploy Jekyll site to Pages GitHub Pages GitHub stars GitHub forks

Real-time Tokyo transportation data collection and visualization system using ODPT API


🎯 Live Dashboard & Demo

Interactive real-time visualization of Tokyo's transportation network

Dashboard Preview User Guide Project Website

✨ Dashboard Features

  • πŸ—ΊοΈ Interactive Tokyo Station Map with real-time markers
  • πŸ“ˆ Live Charts & Metrics showing passenger flow and performance
  • πŸš‚ Real-time Train Tracking with delay status
  • 🚌 Bus Route Monitoring with live positions
  • πŸ“± Mobile Responsive design for all devices
  • ⚑ Auto-refresh with 30-second data updates

πŸ“Š Current System Status

πŸ”΄ LIVE: Tokyo Transportation Monitor
β”œβ”€β”€ Daily Passengers: 2.15M across 5 major stations
β”œβ”€β”€ System Performance: 94.2% punctuality rate
β”œβ”€β”€ Average Delay: 1.0 minutes
└── Active Alerts: 0 service disruptions

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Git
  • Ruby 3.1+ (for Jekyll documentation)

Installation

# Clone the repository
git clone https://github.com/Tatsuru-Kikuchi/MCP-traffic.git
cd MCP-traffic

# Set up Python environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install Python dependencies
pip install -r requirements.txt

# Set up Jekyll for documentation
bundle install

# Configure the system
cp config/api_config.example.json config/api_config.json
# Edit config/api_config.json with your ODPT API settings

Running the System

# Test the installation
python src/collectors/traffic_collector.py --catalog-only

# Run a single data collection
python scripts/collect_all_data.py

# Start continuous scheduled collection
python scripts/schedule_collection.py

# Serve documentation locally
bundle exec jekyll serve

πŸ“Š What is MCP Traffic?

A comprehensive Tokyo traffic data collection and analysis system that leverages the ODPT (Open Data Platform for Transportation) API to gather, process, and monitor real-time transportation data across Tokyo's extensive public transit network.

MCP Traffic (Model Control Protocol for Traffic) is an automated system designed for:

  • πŸ”„ Real-time Data Collection: Continuous gathering of Tokyo transportation data
  • ⚑ Data Processing: Automated cleaning, validation, and transformation
  • πŸ“ˆ Analysis & Monitoring: Traffic pattern analysis and system health monitoring
  • πŸ—„οΈ Data Management: Organized storage with automatic archiving
  • πŸ“š Documentation: Comprehensive guides and API documentation

πŸ—οΈ System Architecture

Data Flow

ODPT API β†’ Data Collectors β†’ Data Processors β†’ Storage β†’ Analysis
    ↓              ↓              ↓            ↓         ↓
Raw Data β†’ Validation β†’ Transformation β†’ Archive β†’ Insights

Directory Structure

MCP-traffic/
β”œβ”€β”€ src/                    # Source code
β”‚   β”œβ”€β”€ collectors/         # Data collection modules
β”‚   └── processors/         # Data processing utilities
β”œβ”€β”€ data/                   # Data storage
β”‚   β”œβ”€β”€ raw/               # Original API responses
β”‚   β”œβ”€β”€ processed/         # Cleaned data
β”‚   └── archives/          # Historical data
β”œβ”€β”€ scripts/               # Automation scripts
β”œβ”€β”€ config/                # Configuration files
β”œβ”€β”€ monitoring/            # Health checks and alerts
β”œβ”€β”€ logs/                  # System logs
β”œβ”€β”€ docs/                  # Documentation
└── .github/workflows/     # CI/CD workflows

πŸ”§ Configuration

API Configuration

Edit config/api_config.json:

{
  "odpt_api": {
    "base_url": "https://ckan.odpt.org/api/3/action/",
    "api_key": "your-api-key",
    "rate_limit": 100,
    "timeout": 30
  },
  "collection": {
    "schedule_interval": 300,
    "data_types": ["train", "bus", "station"],
    "regions": ["tokyo"]
  },
  "storage": {
    "format": "json",
    "compression": true,
    "retention_days": 365
  }
}

Jekyll Configuration

The documentation site is configured in _config.yml with:

  • GitHub Pages deployment
  • SEO optimization
  • Responsive design
  • Multi-language support

πŸ“ˆ Data Collection Features

Supported Data Types

  • πŸš† Train Data: Real-time positions, delays, service status
  • 🚌 Bus Data: Vehicle locations, route information, schedules
  • 🏒 Station Data: Facility information, accessibility features
  • πŸ—ΊοΈ Route Data: Network topology, connections, fare information
  • πŸ“Š Operational Data: Service disruptions, maintenance schedules

Collection Strategies

  • Scheduled Collection: Automated data gathering at configurable intervals
  • On-demand Collection: Manual collection for specific data types
  • Error Recovery: Robust retry mechanisms with exponential backoff
  • Rate Limiting: Compliance with API usage policies

πŸ–₯️ Deployment Options

Local Development

# Standard Python development setup
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python scripts/collect_all_data.py

Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Monitor logs
docker-compose logs -f mcp-traffic

Server Deployment

# Install as systemd service
sudo cp deployment/mcp-traffic.service /etc/systemd/system/
sudo systemctl enable mcp-traffic
sudo systemctl start mcp-traffic

Cloud Deployment

  • AWS: EC2 + S3 + CloudWatch
  • Google Cloud: Compute Engine + Cloud Storage
  • Azure: Virtual Machines + Blob Storage

See the Deployment Guide for detailed instructions.

πŸ“Š Monitoring & Health Checks

System Monitoring

  • API Connectivity: Continuous monitoring of ODPT API availability
  • Data Quality: Validation and completeness checks
  • Storage Usage: Disk space monitoring with alerts
  • Performance Metrics: Response times and throughput tracking

Health Check Commands

# System health overview
python monitoring/health_check.py

# Detailed performance metrics
python monitoring/performance_monitor.py

# Data quality report
python monitoring/data_quality_check.py

Alerting

  • Email notifications for system failures
  • Slack integration for real-time alerts
  • Custom webhook support for external monitoring

πŸ” Data Analysis Tools

Built-in Analytics

  • Traffic pattern analysis
  • Peak hour identification
  • Service reliability metrics
  • Historical trend analysis

Integration Options

  • Jupyter Notebooks: Interactive data exploration
  • Pandas/NumPy: Statistical analysis
  • Matplotlib/Plotly: Data visualization
  • Apache Spark: Large-scale data processing

πŸ“š Documentation & Links

🎯 Main Dashboard Links

πŸ“‹ Technical Documentation

πŸ” Security & Privacy

Data Privacy

  • No Personal Data: Only collects aggregate transportation data
  • Anonymized Data: All data is inherently anonymous
  • Compliance: Adheres to data protection regulations

Security Features

  • API key encryption
  • Secure configuration management
  • Network security best practices
  • Regular security updates

🀝 Contributing

We welcome contributions! Here's how to get started:

Development Setup

# Fork and clone the repository
git clone https://github.com/YOUR-USERNAME/MCP-traffic.git
cd MCP-traffic

# Create development branch
git checkout -b feature/your-feature-name

# Set up development environment
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt

# Run tests
python -m pytest tests/

Contribution Guidelines

  1. Code Style: Follow PEP 8 for Python, use meaningful variable names
  2. Testing: Add tests for new functionality
  3. Documentation: Update documentation for changes
  4. Commits: Use clear, descriptive commit messages

Types of Contributions

  • πŸ› Bug Fixes: Report and fix issues
  • ✨ Features: New functionality and improvements
  • πŸ“š Documentation: Improve guides and examples
  • πŸ§ͺ Testing: Enhance test coverage
  • πŸ”§ DevOps: Improve deployment and CI/CD

πŸ“„ License

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

πŸ†˜ Support

Getting Help

  1. Documentation: Check the docs/ directory
  2. Issues: Search existing issues
  3. Discussions: Join GitHub Discussions
  4. Dashboard Help: Read the User Guide

Reporting Issues

When reporting issues, please include:

  • Operating system and Python version
  • Error messages and stack traces
  • Steps to reproduce the issue
  • Configuration (without sensitive data)

πŸ† Acknowledgments

Data Sources

Technology Stack

  • Python: Core programming language
  • Jekyll: Documentation site generator
  • GitHub Actions: CI/CD and deployment
  • Docker: Containerization
  • Chart.js: Interactive data visualization
  • Leaflet: Interactive mapping

Community

Special thanks to all contributors who have helped improve this project through code, documentation, testing, and feedback.


🎯 Ready to Explore Tokyo's Transportation System?

Launch Dashboard Read Guide

πŸ”΄ LIVE Demo Available Now!


GitHub issues GitHub pull requests Last commit

For more information, visit the project website or check out the live dashboard!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors