tennis-mcp-server

AdemolaAri/tennis-mcp-server

3.2

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.

Tools
7
Resources
0
Prompts
0

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:

  1. get_player_stats: Retrieve a player's total matches, wins, and win percentage
  2. get_head_to_head: Get complete match history between two players
  3. get_tournament_draw: Get full tournament bracket and results
  4. get_player_surface_stats: Analyze a player's performance by court surface
  5. list_tables: List all tables in the database
  6. describe_table: Describe the schema of a table
  7. Execute 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

  1. Create a virtual environment:

    python -m venv .venv
    
  2. Activate the virtual environment:

    • Linux/macOS:
      source .venv/bin/activate
      
    • Windows:
      .venv\\Scripts\\activate
      
  3. Install dependencies:

    pip install "mcp[cli]"
    
  4. Run the server:

    mcp run server.py
    
  5. 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.