使用说明
和育体育
一个与MCP服务器集成的体育博彩数据Python客户端。
graph LR
User([Your Code]) --> Client[Wagyu Sports Client] --> API[The Odds API]
MCP[MCP Server] --> Client
Client --> MCP
API --> Client --> User
style User fill:#f8f8f8,stroke:#666,stroke-width:1px,color:#000
style Client fill:#4285F4,stroke:#2965C9,stroke-width:2px,color:#fff
style API fill:#F5F5F5,stroke:#999,stroke-width:1px,color:#000
style MCP fill:#34A853,stroke:#1E8E3E,stroke-width:2px,color:#fff
目录结构
为了提高可维护性,该项目已经过重组:
build/-构建相关文件(pyproject.toml、requirements.txt、setup.py)config/-配置文件(.env.example、pytest.ini)docs/-文档(许可证,README.md)examples/-示例脚本mcp_server/-模型上下文协议(MCP)服务器实现tests/-测试文件
安装
# Development installation
uvx install -e .
# User installation
uv install wagyu_sports
# Set up API key
cp config/.env.example config/.env
# Edit .env and add your API key from https://the-odds-api.com/
快速开始
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'])}")
特性
- 访问体育博彩数据端点
- 通过响应头跟踪API使用情况
- 支持所有API参数和选项
例子
请参阅 examples/ 使用模式目录:
examples/example.py:基本用法examples/advanced_example.py:高级功能examples/verify_install.py:验证安装examples/fetch_nba_odds.py:获取NBA赔率示例examples/verify_import.py:简单的导入验证
测试
测试套件已经过清理和改进,以实现更好的组织和可靠性。使用pytest运行测试:
# Install test dependencies
uvx install pytest pytest-asyncio
# Run all tests
uvx run pytest --rootdir=. -c config/pytest.ini
# Run specific test file
uvx run pytest tests/test_simple_mcp.py
或者使用Makefile:
make test
测试套件包括:
- API客户端测试:核心Odds API客户端功能测试
- MCP服务器测试:MCP服务器实现测试
- 基于客户端的测试:测试完整的MCP协议实现
- 直接测试:直接测试服务器方法的更简单的测试
请参阅 tests/README.md 有关测试方法的更多详细信息,请参阅文件。
MCP服务器信息
有关运行和配置MCP服务器的详细信息,请参阅主README.md文件。