Skip to main content

🚇 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

📊 🔴 LIVE Tokyo Traffic Dashboard

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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_traffic-1.0.0.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_traffic-1.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_traffic-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_traffic-1.0.0.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mcp_traffic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 20ae8a8a5121533f1fedce23e15753b4f4713ea38ac2a42d1fa5f07b92dbfd9e
MD5 72a44fd53db751b987ee87ff5fab81ce
BLAKE2b-256 4baebeb0c90faba42524afedeedc28fbc0b1787e6b63f37163045c1df40fbb9b

See more details on using hashes here.

File details

Details for the file mcp_traffic-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_traffic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mcp_traffic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94d9efd649d11c5860e4a2e6b6069e2b7091c9c22fe3408f459edc50e96cd97
MD5 b257f7e33e9c940056854dda24836a19
BLAKE2b-256 c7332e7fda8764b01e9aa1201880b920c71c79981a4783424046387c3fcf23ae

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page