Soccer MCP Server
A Python server implementing Model Context Protocol (MCP) for football (soccer) statistics and live match data using the API-Football service.
Overview
This server provides a comprehensive set of tools for accessing football data through the API-Football API. It serves as a bridge between applications and football data services, offering both live match information and historical statistics for leagues, teams, and players worldwide.
Features
- League data (standings, fixtures, schedules)
- Team information and fixtures
- Player statistics and profiles
- Live match data (events, statistics, timelines)
- Match analysis (statistics, events)
Configuration
This server requires an API key from RapidAPI for the API-Football service:
Create an account on RapidAPI
Subscribe to the API-Football API
Set the environment variable:
RAPID_API_KEY_FOOTBALL=your_api_key_here
Tools
League Data
Player Data
get_player_id
- Retrieve player IDs and information for players matching a name
- Example:
get_player_id(player_name="Messi")
get_player_profile
- Retrieve a player's profile by their last name
- Example:
get_player_profile(player_name="Messi")
get_player_statistics
- Retrieve detailed player statistics by seasons and league name
- Example:
get_player_statistics(player_id=154, seasons=[2022, 2023], league_name="La Liga")
get_player_statistics_2
- Retrieve detailed player statistics by seasons and league ID
- Example:
get_player_statistics_2(player_id=154, seasons=[2022, 2023], league_id=140)
Team Data
Match/Fixture Data
Live Match Data
get_live_match_for_team
- Checks if a team is currently playing live
- Example:
get_live_match_for_team(team_name="Chelsea")
get_live_stats_for_team
- Retrieves live in-game stats for a team in a match
- Example:
get_live_stats_for_team(team_name="Liverpool")
get_live_match_timeline
- Retrieves real-time timeline of events for a team's live match
- Example:
get_live_match_timeline(team_name="Manchester City")
Usage
The server is implemented using the Fast MCP framework and can be run as a standalone service.
# Start the server
python soccer_server.py
# or
mcp run soccer-server.py
Configuration
- The server runs with a 30-second timeout for more reliable operation
- Signal handlers are implemented for graceful shutdown (Ctrl+C)
Usage with Claude Desktop
Option 1: Using Docker (Recommended)
- Clone this repository
git clone https://github.com/obinopaul/soccer-mcp-server.git
cd soccer-mcp-server
- Install dependencies
pip install -r requirements.txt
- Build the Docker image
docker build -t soccer_server .
- Run the Docker container (ensure your API key is passed as an environment variable)
docker run -d -p 5000:5000 -e RAPID_API_KEY_FOOTBALL=your_api_key_here --name soccer_server soccer_server
- Add this to your
claude_desktop_config.json
:
{
"mcpServers": {
"soccer_server": {
"command": "docker",
"args": [
"exec",
"-i",
"soccer_server",
"python",
"soccer_server.py"
],
"env": {
"RAPID_API_KEY_FOOTBALL": "your_api_key_here"
}
}
}
}
Option 2: Direct Python Execution
- Clone this repository
git clone https://github.com/obinopaul/soccer-mcp-server.git
cd soccer-mcp-server
- Install dependencies
pip install -r requirements.txt
- Set the API key environment variable
export RAPID_API_KEY_FOOTBALL=your_api_key_here
- Add this to your
claude_desktop_config.json
, adjusting the Python path as needed:
{
"mcpServers": {
"soccer_server": {
"command": "/path/to/your/python",
"args": [
"/path/to/soccer_server.py"
],
"env": {
"RAPID_API_KEY_FOOTBALL": "your_api_key_here"
}
}
}
}
After adding your chosen configuration, restart Claude Desktop to load the soccer server. You'll then be able to use all the football data tools in your conversations with Claude.
Technical Details
The server is built on:
- API-Football via RapidAPI
- MCP for API interface
- Pydantic for input validation
- Requests for API communication
License
This MCP server is available under the MIT License.