IPL MCP Server

IPL MCP Server

Provides natural language access to IPL cricket match data, allowing users to query player statistics, team performances, and match results. It utilizes a SQLite backend and Cricsheet data to deliver detailed cricket analytics through the Model Context Protocol.

Category
访问服务器

README

IPL MCP Server

A Model Context Protocol (MCP) server that provides natural language access to IPL (Indian Premier League) cricket match data. Built using data from Cricsheet with an enhanced sample of 18 IPL matches including Virat Kohli games and CSK vs MI classics.

🏏 Features

  • Natural Language Queries: Ask questions about IPL data in plain English
  • Enhanced Dataset: 18 carefully selected IPL matches including:
    • Virat Kohli batting performances (99 runs in 4 matches)
    • CSK vs MI classic encounters (3 matches)
    • All major IPL teams represented
  • Rich Analytics: Player stats, team performance, match analysis
  • Claude Desktop Integration: Works seamlessly with Claude Desktop
  • Fast SQL Backend: Efficient SQLite database with optimized queries
  • Extensible: Can easily be extended to work with the full 1,169+ match dataset

🚀 Quick Start

Prerequisites

  • Python 3.11+
  • uv package manager
  • Claude Desktop (for MCP integration)

Installation

  1. Clone and setup:
git clone <your-repo>
cd ipl-mcp-server
  1. Install dependencies:
uv install
  1. Setup database and load data:
uv run python main.py --setup --data-dir data_small

This will:

  • Create SQLite database tables
  • Process 18 sample JSON match files (includes V Kohli & CSK vs MI)
  • Calculate player and team statistics
  • Takes ~10-15 seconds to complete
  1. Test the queries (optional):
uv run python test_queries.py
  1. Start the MCP server:
uv run python main.py --server

🎯 Example Queries

Basic Match Information

  • "Show me all matches in the dataset"
  • "How many matches are in the database?"
  • "Which team won the most matches?"
  • "What was the highest total score?"
  • "Show matches played in Mumbai"

Player Performance

  • "Who scored the most runs across all matches?"
  • "Which bowler took the most wickets?"
  • "Show me Virat Kohli's batting stats"
  • "Who has the best bowling figures in a single match?"
  • "Show all centuries scored"

Advanced Analytics

  • "What's the average first innings score?"
  • "Which venue has the highest scoring matches?"
  • "What's the most successful chase target?"
  • "Which team has the best powerplay performance?"
  • "Show me partnership records over 100 runs"

Match-Specific Queries

  • "Show me the scorecard for match between CSK and MI"
  • "How many sixes were hit in the final?"
  • "What was the winning margin in the closest match?"

🔧 Claude Desktop Integration

  1. Add to Claude Desktop config:

Edit your Claude Desktop MCP configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "ipl-cricket-server": {
      "command": "uv",
      "args": ["run", "python", "main.py", "--server"],
      "cwd": "/path/to/your/ipl-mcp-server"
    }
  }
}
  1. Restart Claude Desktop

  2. Test the connection: Ask Claude: "Show me IPL team statistics"

📊 Database Schema

The server uses SQLite with the following key tables:

  • matches: Match metadata (teams, venue, date, outcome)
  • innings: Innings-level data (totals, wickets, overs)
  • deliveries: Ball-by-ball data (runs, wickets, extras)
  • player_stats: Aggregated batting/bowling statistics
  • team_stats: Team performance metrics
  • players: Player registry with Cricsheet IDs
  • teams: Team information

🛠️ Advanced Usage

Command Line Options

# Setup database (first time only)
uv run python main.py --setup

# Reset database and reload data
uv run python main.py --reset

# Start server (default)
uv run python main.py --server

# Custom data directory
uv run python main.py --setup --data-dir /path/to/data

API Integration

The server can be extended to work with other MCP clients beyond Claude Desktop. The query engine supports pattern matching for natural language understanding.

Adding Custom Queries

Extend the QueryEngine class in src/mcp_server/query_engine.py:

{
    'pattern': r'your.*query.*pattern',
    'handler': self.your_handler_method,
    'description': 'Your query description'
}

📈 Performance

  • Database Size: ~3MB for 18 sample matches
  • Setup Time: 10-15 seconds for data load
  • Query Response: <1 second for most queries
  • Memory Usage: ~50MB typical runtime

🚀 Scaling to Full Dataset

The system can easily handle the complete 1,169 match dataset:

  • Full Database Size: ~50MB
  • Full Setup Time: 2-3 minutes
  • Simply use --data-dir data instead of --data-dir data_small

🔍 Sample Query Results

Query: "Which team won the most matches?"

📊 **Team with most wins**

1. Mumbai Indians | 120 wins | 203 matches | 59.11% win rate
2. Chennai Super Kings | 118 wins | 195 matches | 60.51% win rate
3. Royal Challengers Bangalore | 88 wins | 203 matches | 43.35% win rate
...

Query: "Show me Virat Kohli batting stats"

🏏 **V Kohli** Batting Stats:
• Total Runs: 99
• Matches: 4  
• Highest Score: N/A
• Average: 24.75
• Strike Rate: 117.86
• Sixes: 4
• Fours: 8

🗄️ Data Source

All data comes from Cricsheet, which provides:

  • Ball-by-ball data for IPL matches from 2008-2017 seasons (enhanced sample of 18 matches)
  • Player registry with unique identifiers
  • Match metadata including officials, venues, outcomes
  • JSON format with comprehensive match details
  • Full dataset available: 1,169+ matches (2008-2024) can be loaded by using --data-dir data

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add your improvements
  4. Test with sample queries
  5. Submit a pull request

📝 License

This project is licensed under the MIT License. Data provided by Cricsheet under their terms of use.

🚀 Working with Full Dataset

To use the complete 1,169 match dataset instead of the sample:

  1. Reset and load full data:
uv run python main.py --reset --data-dir data

⚠️ This will take 2-3 minutes to complete

  1. Benefits of full dataset:
  • Complete IPL history (2008-2024)
  • More accurate player statistics
  • Comprehensive team performance data
  • Better trend analysis capabilities

✅ Verify Installation

Test your setup with these commands:

# Quick database check
uv run python -c "from src.database.database import get_db_session; from src.database.models import *; session = get_db_session(); print(f'✅ Database ready: {session.query(Match).count()} matches loaded')"

# Test natural language query
uv run python -c "from src.mcp_server.query_engine import QueryEngine; print(QueryEngine().process_query('how many matches'))"

# Run interactive demo
uv run python test_queries.py

🔗 Links


Built with ❤️ for cricket analytics and AI-powered data exploration

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选