The Odds API MCP server

Provides a bridge to The Odds API for accessing sports betting data including available sports, odds comparisons across bookmakers, and quota tracking in both test and live modes.
Back to servers
Provider
Wagyu Sports Team
Release date
Feb 28, 2025
Language
Python
Stats
1 star

The MCP server from Wagyu Sports provides a Model Context Protocol implementation that integrates with sports betting data. It serves as a bridge between your code and sports betting APIs, allowing you to access odds and related information through a standardized interface.

Installation

To install Wagyu Sports with the MCP server:

# User installation
uv install wagyu_sports

# Development installation (if you want to modify the code)
uvx install -e .

After installation, you'll need to set up your API key:

cp config/.env.example config/.env
# Edit .env and add your API key from https://the-odds-api.com/

Basic Usage

Here's how to get started with the client:

from wagyu_sports import OddsClient
import os
from dotenv import load_dotenv

# Load API key
load_dotenv(dotenv_path="config/.env")
api_key = os.getenv("ODDS_API_KEY")

# Create client and get sports
client = OddsClient(api_key)
sports = client.get_sports()
print(f"Available sports: {len(sports['data'])}")

Advanced Usage Examples

Fetch NBA Odds

To fetch odds for NBA games:

from wagyu_sports import OddsClient
import os
from dotenv import load_dotenv

load_dotenv(dotenv_path="config/.env")
api_key = os.getenv("ODDS_API_KEY")

client = OddsClient(api_key)

# Get NBA odds
nba_odds = client.get_odds(
    sport="basketball_nba",
    regions="us",
    markets="h2h",
    oddsFormat="decimal"
)

# Process the results
for game in nba_odds.get('data', []):
    home_team = game['home_team']
    away_team = game['away_team']
    print(f"{away_team} @ {home_team}")
    
    # Display the odds for each bookmaker
    for bookmaker in game.get('bookmakers', []):
        print(f"  {bookmaker['title']}:")
        for market in bookmaker.get('markets', []):
            if market['key'] == 'h2h':
                for outcome in market.get('outcomes', []):
                    print(f"    {outcome['name']}: {outcome['price']}")

Using the MCP Server

The MCP (Model Context Protocol) server provides a standardized interface for accessing sports betting data:

Starting the MCP Server

# From the project directory
python -m mcp_server.server

Connecting to the MCP Server

import asyncio
from mcp_protocol import MCPClient

async def main():
    # Connect to the MCP server
    client = MCPClient("localhost", 8000)
    await client.connect()
    
    # Get available sports
    sports_response = await client.send_and_receive({
        "type": "request",
        "request_id": "sports_request",
        "endpoint": "get_sports"
    })
    
    print(f"Available sports: {len(sports_response['data'])}")
    
    # Get odds for a specific sport
    odds_response = await client.send_and_receive({
        "type": "request",
        "request_id": "odds_request",
        "endpoint": "get_odds",
        "params": {
            "sport": "basketball_nba",
            "regions": "us",
            "markets": "h2h",
            "oddsFormat": "decimal"
        }
    })
    
    print(f"Received odds for {len(odds_response['data'])} games")
    
    await client.disconnect()

# Run the async function
asyncio.run(main())

Configuration Options

The MCP server can be configured using environment variables:

# In your .env file or environment
MCP_SERVER_HOST=0.0.0.0  # Server host (default: localhost)
MCP_SERVER_PORT=8000     # Server port (default: 8000)
ODDS_API_KEY=your_api_key_here  # Required API key

Tracking API Usage

The client automatically tracks API usage through response headers:

from wagyu_sports import OddsClient
import os
from dotenv import load_dotenv

load_dotenv(dotenv_path="config/.env")
api_key = os.getenv("ODDS_API_KEY")

client = OddsClient(api_key)
response = client.get_sports()

# Access usage information
requests_remaining = response.get('requests_remaining')
requests_used = response.get('requests_used')

print(f"API Usage: {requests_used} used, {requests_remaining} remaining")

With these instructions, you should be able to install and effectively use the Wagyu Sports MCP server for accessing sports betting data in your applications.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later