etweisberg/mlb-mcp 是从 https://github.com/etweisberg/mlb-mcp. 导入的 MCP 服务器候选服务器。
概览
etweisberg/mlb-mcp 是从 https://github.com/etweisberg/mlb-mcp. 导入的 MCP 服务器候选服务器。
概述(AI 翻译)
这是一个Python项目,创建了一个模型上下文协议(MCP)服务器,通过MLB统计API和pybaseball库访问MLB统计数据,用于统计广播、粉丝图和棒球参考统计。该服务器提供结构化的API访问棒球统计数据,可与兼容MCP的客户端使用。
项目结构
mlb_stats_mcp/- 主包目录server.py- 核心MCP服务器实现tools/- MCP 工具实现mlb_statsapi_tools.py- MLB StatsAPI 工具定义statcast_tools.py- 统计数据工具定义pybaseball_plotting_tools.py- 额外的pybaseball工具,用于生成matplotlib图和返回base64编码图像pybaseball_supp_tools.py- 补充的pybaseball功能,用于与球迷图、棒球参考及其他数据源交互utils/- 实用模块logging_config.py- 日志配置images.py- 与处理图图像相关的函数tests/- 用于验证服务器功能的测试套件pyproject.toml- 项目配置与依赖关系.pre-commit-config.yaml- 预提交钩子配置
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MLB Stats MCP Server
A Python project that creates a Model Context Protocol (MCP) server for accessing MLB statistics data through the MLB Stats API and pybaseball library for statcast, fangraphs, and baseball reference statistics. This server provides structured API access to baseball statistics that can be used with MCP-compatible clients.
Project Structure
mlb_stats_mcp/- Main package directoryserver.py- Core MCP server implementationtools/- MCP tool implementationsmlb_statsapi_tools.py- MLB StatsAPI tool definitionsstatcast_tools.py- Statcast data tool definitionspybaseball_plotting_tools.py- Additionalpybaseballtools provided for generating matplotlib plots and returning base64 encoded imagespybaseball_supp_tools.py- Supplementalpybaseballfunctions for interfacing with fangraphs, baseball reference, and other data sources
utils/- Utility moduleslogging_config.py- Logging configurationimages.py- functions related to handling plot images
tests/- Test suite for verifying server functionality
pyproject.toml- Project configuration and dependencies.pre-commit-config.yaml- Pre-commit hooks configuration.github/- GitHub Actions workflows
Tools
Setup
- Install uv if you haven’t already:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Create and activate a virtual environment:
uv venv
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
- Install dependencies:
uv pip install -e .
Installing via Smithery
To install MLB Stats Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @etweisberg/mlb-mcp --client claude
Running Tests
The project includes comprehensive pytest tests for the MCP server functionality:
uv run pytest -v
Tests verify all MLB StatsAPI tools work correctly with the MCP protocol, establishing connections, making API calls, and processing responses.
Environment Variables
The project uses environment variables stored in .env to configure settings.
Use ANTHROPIC_API_KEY to enable MCP Server.
Logging Configuration
The MLB Stats MCP Server supports configurable logging via environment variables:
MLB_STATS_LOG_LEVEL- Sets the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
安装
npx -y @smithery/cli install @etweisberg/mlb-mcp --client claude