EM

etweisberg/mlb-mcp

开发工具

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

34 stars 12 forks 质量 67 趋势 14

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 directory
    • server.py - Core MCP server implementation
    • tools/ - MCP tool implementations
      • mlb_statsapi_tools.py - MLB StatsAPI tool definitions
      • statcast_tools.py - Statcast data tool definitions
      • pybaseball_plotting_tools.py - Additional pybaseball tools provided for generating matplotlib plots and returning base64 encoded images
      • pybaseball_supp_tools.py - Supplemental pybaseball functions for interfacing with fangraphs, baseball reference, and other data sources
    • utils/ - Utility modules
      • logging_config.py - Logging configuration
      • images.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

  1. Install uv if you haven’t already:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create and activate a virtual environment:
uv venv
source .venv/bin/activate  # On Unix/macOS
# or
.venv\Scripts\activate  # On Windows
  1. 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)
在 GitHub 查看完整 README

安装

npx -y @smithery/cli install @etweisberg/mlb-mcp --client claude
新手?先看 mcpskill.org 教程 →