Sponsored by Deepsite.site

NBA Odds MCP Server

Created By
nikhilkichili6 months ago
Advanced NBA odds tracking, betting analysis, and trivia MCP server for Claude Desktop with line movement detection and AI/ML game simulations
Content

NBA Odds MCP Server

A Model Context Protocol (MCP) server that provides NBA basketball odds data from The Odds API.

Overview

This MCP server enables LLMs (Large Language Models) like Claude to access real-time NBA odds data. It provides information about:

  • Current NBA games with betting odds
  • NBA Championship winner odds
  • Team-specific game schedules
  • Basic NBA league information

The server acts as a bridge between LLMs and The Odds API, handling authentication, data formatting, and error handling.

Requirements

  • Python 3.10 or higher
  • The Odds API key (included in the server)
  • MCP-compatible client (Claude Desktop, etc.)
  • Matplotlib, NumPy, and Pillow for visualizations

Installation

  1. Set up Python 3.10 or higher

    # Using pyenv (already set up)
    pyenv local 3.10.13
    
  2. Create and activate a virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies

    pip install "mcp[cli]" httpx
    

Usage

Running the Server

# Activate the virtual environment
source venv/bin/activate

# Run the server
python nba_odds_server.py

Automated Data Collection

To build a meaningful historical database for trend analysis, set up automated data collection:

  1. Create a data collection script (odds_collector.py) in your project directory that collects and stores odds data

  2. Set up cron jobs to run this script at regular intervals:

# Daily collection at 7:30 AM
30 7 * * * cd /Users/nikhil/Documents/MCP_test && /Users/nikhil/Documents/MCP_test/venv/bin/python odds_collector.py >> /Users/nikhil/Documents/MCP_test/collection_log.txt 2>&1

# Collection at 3:30 PM (for game days)
30 15 * * * cd /Users/nikhil/Documents/MCP_test && /Users/nikhil/Documents/MCP_test/venv/bin/python odds_collector.py >> /Users/nikhil/Documents/MCP_test/collection_log.txt 2>&1

# Collection at 8:30 PM (for game days and post-game)
30 20 * * * cd /Users/nikhil/Documents/MCP_test && /Users/nikhil/Documents/MCP_test/venv/bin/python odds_collector.py >> /Users/nikhil/Documents/MCP_test/collection_log.txt 2>&1
  1. Recommended collection frequency:
    • Daily baseline collection (morning)
    • Pre-game collection on game days (afternoon)
    • Post-game collection for market reactions (evening)

Configuring Claude Desktop

  1. Edit the Claude Desktop configuration file:

    ~/Library/Application Support/Claude/claude_desktop_config.json
    
  2. Add the following configuration:

    {
      "mcpServers": {
        "nba-odds": {
          "command": "/Users/nikhil/Documents/MCP_test/venv/bin/python",
          "args": [
            "/Users/nikhil/Documents/MCP_test/nba_odds_server.py"
          ]
        }
      }
    }
    
  3. Restart Claude Desktop

Testing the Server

Ask questions like:

  • "What are the current odds for the NBA Championship?"
  • "Show me upcoming NBA games"
  • "What team is favored to win the NBA Championship?"
  • "Tell me about the NBA games happening today"
  • "Simulate a game between the Lakers and the Celtics"

Available Tools

The server provides the following tools:

Basic NBA Data Tools

  1. get_nba_info() - Provides basic information about the NBA basketball category

  2. get_nba_games(markets, regions) - Gets current NBA games with odds

    • Parameters:
      • markets: Comma-delimited list of markets (h2h, spreads, totals)
      • regions: Comma-delimited list of regions (us, uk, eu, au)
  3. get_nba_championship_odds() - Gets current NBA Championship winner odds

  4. get_nba_team_stats(team_name) - Gets upcoming games for a specific team

    • Parameters:
      • team_name: Name of the NBA team

Simulation Tools

  1. simulate_nba_game(home_team, away_team) - Simulate an NBA game using AI/ML models

    • Parameters:
      • home_team: Name of the home team
      • away_team: Name of the away team
  2. simulate_championship_odds() - Simulate NBA championship odds using 1000 season simulations

  3. simulate_season_remainder() - Simulate the remainder of the NBA season including playoffs

  4. get_simulation_accuracy() - Get the accuracy statistics of previous game simulations

Betting Analysis Tools

  1. get_betting_recommendations(max_recommendations) - Get smart betting recommendations based on odds movement and historical trends

    • Parameters:
      • max_recommendations: Maximum number of recommendations to return (default: 3)
  2. analyze_team_ats_performance(team_name) - Analyze a team's performance against the spread (ATS)

    • Parameters:
      • team_name: Name of the NBA team to analyze
  3. analyze_odds_movement(event_id, days) - Analyze how betting odds have moved for a specific game

    • Parameters:
      • event_id: Event identifier
      • days: Number of days to look back (default: 7)

NBA Trivia Game Tools

  1. start_nba_quiz(category, difficulty, length) - Start a new NBA trivia quiz game

    • Parameters:
      • category: Category of questions (random, nba_history, current_nba, nba_stats, nba_rules, championships)
      • difficulty: Difficulty level (rookie, veteran, all-star, hall-of-fame, mixed)
      • length: Number of questions (default: 5)
  2. answer_quiz_question(quiz_id, answer) - Answer a question in an active trivia quiz

    • Parameters:
      • quiz_id: ID of the active quiz
      • answer: The answer selected by the user
  3. get_daily_nba_question() - Get the daily NBA trivia question

  4. answer_daily_nba_question(answer) - Answer the daily NBA trivia question

    • Parameters:
      • answer: The answer selected by the user
  5. get_nba_quiz_stats() - Get statistics about NBA trivia quiz performance

Line Movement Analysis Tools

  1. analyze_reverse_line_movement(days) - Analyze reverse line movement patterns from historical odds data

    • Parameters:
      • days: Number of days of historical data to analyze (default: 30)
  2. analyze_sharp_money_action(days, threshold) - Identify games with potential sharp money action

    • Parameters:
      • days: Number of days to analyze (default: 30)
      • threshold: Minimum probability change to consider (default: 3%)
  3. calculate_betting_strategy_roi(movement_type, days) - Calculate historical ROI for betting strategies based on line movements

    • Parameters:
      • movement_type: Type of movement to analyze (reverse, sharp)
      • days: Number of days to analyze (default: 90)
  4. create_line_movement_chart(game_id, team_name, days) - Create a chart showing probability impact of line movements

    • Parameters:
      • game_id: Optional specific game to analyze (use "help" to see available games)
      • team_name: Optional team name to filter by
      • days: Number of days to analyze if no specific game/team

Odds Tracking & Analysis Tools

  1. analyze_championship_odds_trend(team_name, days) - Analyzes how a team's championship odds have changed over time

    • Parameters:
      • team_name: Name of the NBA team to analyze
      • days: Number of days to look back (default: 30)
  2. get_team_odds_history(team_name, days) - Gets historical championship odds data for a specific team

    • Parameters:
      • team_name: Name of the NBA team
      • days: Number of days of historical data to retrieve (default: 30)
  3. get_odds_tracking_stats() - Gets statistics about the tracked odds data in the database

Visualization Tools

  1. generate_team_odds_chart(team_name, days) - Creates a chart showing championship odds movement for a team

    • Parameters:
      • team_name: Name of the NBA team to chart
      • days: Number of days to include in the chart (default: 30)
  2. generate_teams_comparison_chart(team_names, days) - Creates a chart comparing championship odds for multiple teams

    • Parameters:
      • team_names: Comma-separated list of team names to compare
      • days: Number of days to include in the chart (default: 30)
  3. generate_game_odds_chart(event_id) - Creates a chart showing odds movement for a specific game

    • Parameters:
      • event_id: ID of the game/event to chart
  4. generate_bookmaker_comparison_chart(team_name, days) - Creates a chart comparing odds from different bookmakers

    • Parameters:
      • team_name: Name of the NBA team to analyze
      • days: Number of days to include in the chart (default: 30)

Data Storage and Visualization

SQLite Database

The server uses SQLite to store historical odds data, enabling trend analysis:

  • Championship Odds Table: Tracks team championship odds over time
  • Game Odds Table: Tracks individual game odds and line movements
  • Automatic Storage: All API requests automatically store data in the database

Visualization System

The server includes a robust visualization system powered by Matplotlib:

  • Charts Directory: All generated charts are saved to a charts folder
  • Base64 Embedding: Charts are returned as base64-encoded images for display in LLM responses
  • Chart Types:
    • Team odds trend charts
    • Multi-team comparison charts
    • Game odds movement charts
    • Bookmaker comparison charts

Data Analysis

The system provides automated analysis of odds data:

  • Trend detection (improvement, decline, stability)
  • Bookmaker discrepancy analysis
  • Historical odds movement patterns
  • Visual indicators of significant odds shifts

API Information

This server uses The Odds API (https://the-odds-api.com/) with the following endpoints:

  • GET /sports - List all sports categories
  • GET /sports/{sport_key}/odds - Get odds for a specific sport
  • GET /sports/{sport_key}/events/{event_id}/odds - Get odds for a specific event

API key is included in the server configuration.

Troubleshooting

  • Server not starting: Ensure Python 3.10+ is installed and the virtual environment is activated
  • MCP client not connecting: Check the configuration file path and format
  • API errors: Verify API key validity and check for rate limiting

License

This project is for educational purposes.

Acknowledgements

  • The Odds API for providing sports betting data
  • Model Context Protocol (MCP) for the server framework
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
DeepChatYour AI Partner on Desktop
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code