AdemolaAri/tennis-mcp-server
If you are the rightful owner of tennis-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Tennis Database MCP Server is a practical example of using the Model Context Protocol to enhance AI systems with dynamic querying capabilities for tennis data.
Tennis Database MCP Server Example
As the 2025 US Open unfolds with its thrilling matches and incredible stats, I've been thinking about how AI could enhance our tennis experience. What if we could build AI systems that understand tennis as deeply as the commentators do? That's what inspired this projectβa perfect way to demonstrate the power of the Model Context Protocol (MCP) in the world of tennis.
πΎ The Story Behind This Project
Imagine you're building an AI tennis commentator or a sports analytics system that needs to access historical tennis data on the fly. Your large language model (LLM) assistant needs to answer questions like:
- "What's the head-to-head record between Nadal and Djokovic at Wimbledon?"
- "How does Federer perform on different surfaces?"
- "Which players have the best serve statistics in Grand Slams?"
Traditionally, you'd have to pre-write specific SQL queries for each possible question. But what if your LLM could generate and execute database queries dynamically based on natural language questions?
This is where our Tennis Database MCP Server comes in. It's a practical example of how to create a Model Context Protocol (MCP) server that exposes a SQLite tennis database as a set of tools that any LLM can use. The server provides a clean interface for querying player statistics, match histories, tournament results, and detailed match statistics.
π― What This Example Demonstrates
- How to create a simple MCP server in Python
- How to expose a SQLite database as a set of tools for LLMs
- How to structure tennis tournament data and statistics
- How to provide flexible querying capabilities through well-defined tool interfaces
π Database Schema
The database includes four main tables:
players
: Tennis player profiles (name, country, birthdate)tournaments
: Tournament details (name, location, surface type, category)matches
: Match records (players, round, score, winner)match_stats
: Detailed statistics per player per match
π οΈ Available Tools
The server exposes several tools that an LLM can use:
get_player_stats
: Retrieve a player's total matches, wins, and win percentageget_head_to_head
: Get complete match history between two playersget_tournament_draw
: Get full tournament bracket and resultsget_player_surface_stats
: Analyze a player's performance by court surfacelist_tables
: List all tables in the databasedescribe_table
: Describe the schema of a tableExecute a SQL query and return the results
: Execute a SQL query and return the results. Useful for when we do not have a predefined query set
π Running the Sample
Prerequisites
- Python 3.8 or higher
- uv (recommended but not required)
Step-by-Step Setup
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
- Linux/macOS:
source .venv/bin/activate
- Windows:
.venv\\Scripts\\activate
- Linux/macOS:
-
Install dependencies:
pip install "mcp[cli]"
-
Run the server:
mcp run server.py
-
Test the server:
In a new terminal, start the visual interface and navigate to the localhost route in your browser:
mcp dev server.py
Or test directly from CLI:
# List available tools npx @modelcontextprotocol/inspector --cli mcp run server.py --method tools/list # Example: Get player stats for Nadal (by name) npx @modelcontextprotocol/inspector --cli mcp run server.py --method tools/call --tool-name get_player_stats --tool-arg player_name="Rafael Nadal" # Example: Get Nadal vs Djokovic head-to-head (by names) npx @modelcontextprotocol/inspector --cli mcp run server.py --method tools/call --tool-name get_head_to_head --tool-arg player1_name="Rafael Nadal" --tool-arg player2_name="Novak Djokovic"
π License
MIT
This example is part of the Model Context Protocol (MCP) samples, demonstrating how to create practical tool interfaces for LLMs. The tennis database schema and sample data are fictional and used for demonstration purposes only.