SY

spilchen/yahoo_fantasy_mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 3 forks 质量 68 趋势 14MIT

MCP server for Yahoo! Fantasy League

概览

A Model Context Protocol (MCP) server that provides access to Yahoo Fantasy Sports data. This server acts as a front-end for the yahoo_fantasy_api library, allowing AI assistants and other MCP clients to query fantasy league information. - Query fantasy league standings and team information - Retrieve player statistics and projections - Access matchup data and scoring details - Get roster information for teams - Search for players and free agents Before using this MCP server, you need to set up Yahoo Fantasy API credentials: 1. Register your application at Yahoo Developer Network 2. Obtain your consumer_key and consumer_secret 3. Set up OAuth2 authentication using one of the methods below There are two ways to authenticate with Yahoo's API: Create an oauth2.json file with your Yahoo OAuth credentials.

README

以下为原文 README 节选,完整内容请查看原文。

Yahoo Fantasy MCP Server

A Model Context Protocol (MCP) server that provides access to Yahoo Fantasy Sports data. This server acts as a front-end for the yahoo_fantasy_api library, allowing AI assistants and other MCP clients to query fantasy league information.

Features

  • Query fantasy league standings and team information
  • Retrieve player statistics and projections
  • Access matchup data and scoring details
  • Get roster information for teams
  • Search for players and free agents

Installation

From PyPI (when published)

pip install yahoo-fantasy-mcp

From Source

git clone https://github.com/yourusername/yahoo_fantasy_mcp.git
cd yahoo_fantasy_mcp
pip install -e .

Prerequisites

Before using this MCP server, you need to set up Yahoo Fantasy API credentials:

  1. Register your application at Yahoo Developer Network
  2. Obtain your consumer_key and consumer_secret
  3. Set up OAuth2 authentication using one of the methods below

Configuration

There are two ways to authenticate with Yahoo’s API:

Create an oauth2.json file with your Yahoo OAuth credentials. You can generate this file using the yahoo_fantasy_api authentication flow:

from yahoo_oauth import OAuth2

# This will prompt you to authorize via browser
sc = OAuth2(None, None, from_file='oauth2.json')

The oauth2.json file will look like:

{
  "access_token": "...",
  "consumer_key": "your_consumer_key",
  "consumer_secret": "your_consumer_secret",
  "guid": "...",
  "refresh_token": "...",
  "token_time": 1234567890.123456,
  "token_type": "bearer"
}

Option 2: Using Environment Variables

Set the following environment variables:

export YAHOO_CLIENT_ID="your_consumer_key"
export YAHOO_CLIENT_SECRET="your_consumer_secret"

Setting Your League ID

The server requires a YAHOO_LEAGUE_ID environment variable to know which league to query.

Finding your League ID:

If you don’t know your league ID, simply run the server without setting YAHOO_LEAGUE_ID:

python -m yahoo_fantasy_mcp

The server will list all leagues you’re part of and then exit. Example output:

============================================================
YAHOO_LEAGUE_ID not set - Listing available leagues
============================================================

Checking NFL leagues...
Checking MLB leagues...

Found the following leagues:

1. [NFL 2024] My Fantasy League
   League ID: 423.l.123456

2. [MLB 2024] Baseball League
   League ID: 412.l.789012

To use one of these leagues, set the YAHOO_LEAGUE_ID environment variable:

  export YAHOO_LEAGUE_ID=

For example:
  export YAHOO_LEAGUE_ID=423.l.123456

Then set the environment variable:

export YAHOO_LEAGUE_ID=423.l.123456

Usage

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "yahoo-fantasy": { "command": "python", "args": ["-m", "yahoo_fantasy_mcp"], "cwd": "/path/to/directory/with/oauth2.json", "env": { "YAHOO_LEAGUE_ID": "423.l.123456" } } } }