mlb
MCP server for advanced baseball analytics (statcast, fangraphs, baseball reference, mlb stats API) with client demo
claude mcp add --transport stdio etweisberg-mlb-mcp python -m mlb_stats_mcp.server \ --env ANTHROPIC_API_KEY="your-anthropic-api-key" \ --env MLB_STATS_LOG_FILE="path/to/logfile.log" \ --env MLB_STATS_LOG_LEVEL="INFO"
How to use
This MLB Stats MCP Server provides access to MLB statistics by leveraging the MLB Stats API and pybaseball tools through an MCP-compatible interface. It exposes a set of stat-focused tools (e.g., MLB StatsAPI lookups, Statcast data, and pybaseball-derived plots and utilities) that clients can query via MCP protocols to retrieve structured baseball data, run analyses, or generate visuals. You can connect to the MCP server with any MCP client (such as Claude Desktop or custom tooling) and request tool calls by name, passing parameters like player IDs, teams, seasons, or date ranges; responses will be returned in a consistent structured format suitable for downstream consumption.
To use the server, start the Python module as described in the installation instructions. Once running, you can invoke the available tools through MCP tool calls. For example, you might retrieve Statcast data for a specific year, fetch player statistics from MLB Stats API, or generate pybaseball-derived plots that return images encoded in base64 for easy embedding in clients. The environment is configurable via the provided environment variables for logging and API keys, and you can adjust the verbosity of logs to help with debugging during development or integration.
How to install
Prerequisites:
- Python 3.8+ installed
- uv (Python package manager) or a virtual environment setup
- Access to the project repository (clone or download the code)
Install and run locally (using uv):
-
Create and activate a virtual environment (optional but recommended):
- On Unix/macOS: uv venv source .venv/bin/activate
- On Windows: uv venv .venv\Scripts\activate
-
Install the package in editable mode from the repository root: uv pip install -e .
-
Install additional dependencies and set up environment as needed (examples):
- Create a .env file or export variables directly (example shown below)
-
Run the MCP server using uv (as shown in the README example): uv run python -m mlb_stats_mcp.server
Alternative installation via Smithery (for Claude Desktop integration):
- Use Smithery CLI to install the server package for a client, e.g.: npx -y @smithery/cli install @etweisberg/mlb-mcp --client claude
Note: Ensure MLB_STATS_LOG_LEVEL and MLB_STATS_LOG_FILE are configured if you want file-based logging. You may also need to provide an API key for anthropic-based features via ANTHROPIC_API_KEY.
Additional notes
Tips and common issues:
- Ensure you have network access to MLB Stats API endpoints; some hosts may block external requests.
- If you encounter authentication or API quota issues with Anthropics (ANTHROPIC_API_KEY), verify the key is valid and has the necessary permissions.
- Configure logging levels via MLB_STATS_LOG_LEVEL to DEBUG during development for more verbose output.
- MLB_STATS_LOG_FILE is optional; if omitted, logs go to stdout.
- When integrating with Claude Desktop, use the provided template in your claude_desktop_config.json and adjust {PATH_TO_UV}, {PROJECT_DIRECTORY}, and {LOG_FILE_PATH} accordingly.
- Running tests: uv run pytest -v to validate tool functionality and MCP protocol adherence.
Related MCP Servers
ebook
A MCP server that supports mainstream eBook formats including EPUB, PDF and more. Simplify your eBook user experience with LLM.
python -client
支持查询主流agent框架技术文档的MCP server(支持stdio和sse两种传输协议), 支持 langchain、llama-index、autogen、agno、openai-agents-sdk、mcp-doc、camel-ai 和 crew-ai
infobus
Model Context Protocol server enabling AI assistants to access transit information through standardized interfaces
mcp-gateway
MCP Gateway and Registry
mcp -email
一个基于 MCP (Model Context Protocol) 的邮件服务,支持 LLM 发送带附件的电子邮件及在指定目录中搜索文件。提供安全的 SMTP 传输、多收件人支持和附件模式匹配搜索功能,适用于 Gmail、Outlook、Yahoo、QQ 邮箱和网易 126 邮箱等主流邮箱服务。
pentestMCP
pentestMCP: AI-Powered Penetration Testing via MCP, an MCP designed for penetration testers.