Metadata-Version: 2.4
Name: randonneuring-connect-mcp
Version: 5.0.3
Summary: Universal MCP tools for randonneuring data - 5 tools work across all sources (LRM, Audax India, Challenge Lepertel)
Author-email: Prathap Pandian <mprathappandian@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/mprathappandian/randonneuring-platform
Project-URL: Repository, https://github.com/mprathappandian/randonneuring-platform
Project-URL: Issues, https://github.com/mprathappandian/randonneuring-platform/issues
Project-URL: Documentation, https://github.com/mprathappandian/randonneuring-platform/tree/main/packages/mcp-server#readme
Project-URL: Changelog, https://github.com/mprathappandian/randonneuring-platform/blob/main/packages/mcp-server/CHANGELOG.md
Keywords: mcp,randonneuring,cycling,audax,model-context-protocol,ai,lrm,challenge-lepertel
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp>=1.0.0
Requires-Dist: randonneuring-intelligence>=1.2.1
Provides-Extra: http
Requires-Dist: starlette; extra == "http"
Requires-Dist: uvicorn[standard]; extra == "http"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Dynamic: license-file

# Randonneuring Connect MCP Server

[![PyPI version](https://badge.fury.io/py/randonneuring-connect-mcp.svg)](https://badge.fury.io/py/randonneuring-connect-mcp)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Connect AI assistants to randonneuring cycling event data - Universal Tools Architecture**

An MCP server that lets AI agents explore randonneuring (ultra-distance cycling) events through natural language. Version 5.0.0 introduces a revolutionary **Universal Tools Architecture** with **5 tools that work across ALL data sources**.

## 🚀 What's New in v5.0.0

**Breaking Change: Complete Architecture Overhaul**

We've evolved from 8 source-specific tools to **5 universal tools** that work across all data sources:

| Old (v3.x) | New (v5.0) | Benefit |
|------------|------------|---------|
| 8 tools tied to specific sources | 5 universal tools | Less cognitive load for LLMs |
| Hard to add new sources | Add sources without new tools | Unlimited scalability |
| `audax_query_events()` | `query_data(source="audax_india", ...)` | Consistent interface |

### 5 Universal Tools

1. **discover_data** - Discover available sources and their capabilities
2. **query_data** - Execute filtered queries across any source
3. **analyze_data** - Get statistics and aggregations
4. **compare_data** - Compare data across sources, time periods, or cohorts
5. **get_insights** - Multi-step intelligent analysis and summaries

### 3 Data Sources (68 functions)

- **LRM** (Les Randonneurs Mondiaux): 26 functions - worldwide events
- **Audax India**: 26 functions - Indian events and participants
- **Challenge Lepertel**: 16 functions - Grand Slam finishers

## Installation

```bash
pip install randonneuring-connect-mcp
```

For development:
```bash
pip install randonneuring-connect-mcp[dev]
```

## Quick Start

### For AI Clients (Claude Desktop, Kiro, etc.)

Add to your MCP configuration file:

**Claude Desktop** (`claude_desktop_config.json`):
```json
{
  "mcpServers": {
    "randonneuring-connect": {
      "command": "python",
      "args": ["-m", "randonneuring_mcp"]
    }
  }
}
```

**Kiro IDE** (`~/.kiro/settings/mcp.json`):
```json
{
  "mcpServers": {
    "randonneuring-connect": {
      "command": "python",
      "args": ["-m", "randonneuring_mcp"]
    }
  }
}
```

Then restart your AI client. The 5 universal tools will be available.

## Usage Examples

### Discovery
```
"What data sources are available?"
→ Uses discover_data to list LRM, Audax India, Challenge Lepertel

"What can I query from LRM data?"
→ Shows 26 available functions (filters, stats, queries)
```

### Querying
```
"Show me Paris-Brest-Paris 2023 finishers"
→ query_data(source="lrm", filters={"filter_by_year": {"year": 2023}, "filter_by_event": {"event_name": "Paris-Brest-Paris"}})

"Find Audax India events in Mumbai from 2024"
→ query_data(source="audax_india", filters={"filter_by_location": {"location": "Mumbai"}, "filter_by_year": {"year": 2024}})
```

### Analysis
```
"Get gender distribution in LRM"
→ analyze_data(source="lrm", analysis_type="get_gender_distribution")

"Who are the top 10 riders by events completed?"
→ analyze_data(source="lrm", analysis_type="get_top_riders_by_events", parameters={"limit": 10})
```

### Comparison
```
"Compare PBP 2023 vs PBP 2019"
→ compare_data(comparisons=[
    {"label": "PBP 2023", "source": "lrm", "filters": {...}},
    {"label": "PBP 2019", "source": "lrm", "filters": {...}}
  ])
```

### Insights
```
"Give me a summary of LRM data"
→ get_insights(source="lrm", insight_type="summary")
→ Returns: year range, unique riders, countries, events, top riders, gender distribution
```

## Architecture

### Registry-Adapter-Tool Pattern

```
┌─────────────────────────────────────────────┐
│          5 Universal Tools                   │
│  (discover, query, analyze, compare, insights)│
└───────────────┬─────────────────────────────┘
                │
┌───────────────▼─────────────────────────────┐
│          Adapter Layer                       │
│   (LRMAdapter, AudaxAdapter, ChallengeAdapter)│
└───────────────┬─────────────────────────────┘
                │
┌───────────────▼─────────────────────────────┐
│       Capability Registry                    │
│     (68 functions mapped)                    │
└───────────────┬─────────────────────────────┘
                │
┌───────────────▼─────────────────────────────┐
│    randonneuring-intelligence package        │
│        (actual implementations)              │
└─────────────────────────────────────────────┘
```

**Benefits:**
- **Scalability**: Add new sources without new tools
- **LLM-friendly**: 5 tools instead of 8 (reduces cognitive load)
- **Future-proof**: Support 50+ sources with same 5 tools
- **Maintainable**: Clean separation of concerns

## Available Functions by Source

### LRM (26 functions)
**Filters (10)**: by year, rider, country, event, club, distance, gender, time, organizer, date range  
**Statistics (8)**: rider stats, club stats, event stats, time analysis, gender distribution, top riders, organizer stats, country stats  
**Queries (8)**: unique riders, clubs, events, years, countries, distances, genders, organizers

### Audax India (26 functions)
**Event Filters (8)**: by year, club, location, state, distance, status, type, date range  
**Participant Filters (4)**: by name, club, result status, fee paid  
**Queries (14)**: unique clubs, locations, states, distances, years, event types, etc.

### Challenge Lepertel (16 functions)
**Filters (5)**: by rider, country, claiming period, brevet country, claiming year  
**Statistics (5)**: rider stats, country stats, period stats, country diversity, brevet distribution  
**Queries (6)**: unique riders, countries, claiming periods, claiming years, brevet countries, brevet distances

## Migration Guide (v3.x → v5.0)

### Old Way (v3.x)
```python
# 8 source-specific tools
audax_query_events(year=2024, club="Mumbai")
lrm_query_results(event="Paris-Brest-Paris", year=2023)
audax_get_statistics(stat_type="top_participants", limit=10)
```

### New Way (v5.0)
```python
# 5 universal tools
query_data(source="audax_india", filters={"filter_by_year": {"year": 2024}, "filter_by_club": {"club": "Mumbai"}})
query_data(source="lrm", filters={"filter_by_event": {"event_name": "Paris-Brest-Paris"}, "filter_by_year": {"year": 2023}})
analyze_data(source="audax_india", analysis_type="get_top_participants_by_events", parameters={"limit": 10})
```

**Key Changes:**
1. All queries now specify `source` parameter
2. Filters are structured as nested dictionaries
3. Statistics use `analysis_type` instead of `stat_type`
4. New tools: `discover_data`, `compare_data`, `get_insights`

## Data Sources

All data is automatically loaded from S3 via the `randonneuring-intelligence` package (no manual downloads needed):

- **LRM**: Worldwide Long Randonnée Medal results (PBP, LEL, etc.)
- **Audax India**: Indian randonneuring events and participant details
- **Challenge Lepertel**: Grand Slam finishers (riders who completed 200/300/400/600km in multiple countries)

## Development

```bash
# Clone the repository
git clone https://github.com/mprathappandian/randonneuring-platform.git
cd randonneuring-platform/packages/mcp-server

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/
```

## Contributing

Contributions welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Submit a pull request

## Changelog

### v5.0.0 (2024-12-01)
- **BREAKING**: Complete architecture overhaul
- Introduced Universal Tools Architecture (5 tools)
- Added Challenge Lepertel data source (16 functions)
- Registry-Adapter-Tool pattern for unlimited scalability
- Upgraded to randonneuring-intelligence v1.2.0

### v3.1.3
- 8 consolidated tools (Audax India + LRM)
- S3 auto-loading

### v3.0.0
- Initial MCP server release
- 72 individual tools

## License

MIT License - see [LICENSE](LICENSE) file for details

## Links

- **PyPI**: https://pypi.org/project/randonneuring-connect-mcp/
- **GitHub**: https://github.com/mprathappandian/randonneuring-platform
- **Issues**: https://github.com/mprathappandian/randonneuring-platform/issues
- **MCP Protocol**: https://modelcontextprotocol.io/

## Support

- 📧 Email: mprathappandian@gmail.com
- 🐛 Issues: [GitHub Issues](https://github.com/mprathappandian/randonneuring-platform/issues)
- 💬 Discussions: [GitHub Discussions](https://github.com/mprathappandian/randonneuring-platform/discussions)
