Yggdrasil
MCP ServersMCP 伺服器 SKILLs技能 PlugIns解決方案 Asgard AI SolutionAsgard AI 方案 Submit Listing申請上架 GitHub
M

MCP CPBL Statistics MCP 中華職棒統計

Released已發布
data global

An MCP (Model Context Protocol) server that provides comprehensive statistics and data for the Chinese Professional Baseball League (CPBL).

一個中華職棒(CPBL)統計資料的 MCP 伺服器,透過 Model Context Protocol (MCP) 將資料查詢功能以 AI 可呼叫工具的形式對外開放。

Status狀態
released
Tools工具數
10
Category分類
data
Region地區
global
Maintainer維護者
GitHub

Features功能特色

  • 10 ready-to-use tools covering team standings, player profiles, batting/pitching stats, game logs, head-to-head matchups, top-5 leaderboards, and game schedules
  • MCP server (stdio JSON-RPC 2.0) — plug into Claude Code and start asking about CPBL instantly
  • Web scraper — HTML scraping and XHR JSON API calls against cpbl.com.tw
  • No-auth public access — No API keys required; CSRF token handling is automatic
  • Fixture-based unit tests — Fast offline test suite with saved HTML/JSON fixtures
  • Integration tests — Live end-to-end tests against cpbl.com.tw, opt-in via -m integration

  • stdio JSON-RPC 2.0 — 標準 MCP 傳輸協定
  • @mcp.tool() 裝飾器 — Pydantic 型別化工具註冊
  • 網頁爬蟲 — 針對 cpbl.com.tw 的 HTML 解析與 XHR JSON API 呼叫
  • 免認證公開存取 — 無需 API 金鑰;CSRF token 自動處理
  • Fixture 單元測試 — 使用已儲存的 HTML/JSON fixture,可離線快速執行
  • 整合測試 — 對 cpbl.com.tw 進行端對端即時測試,透過 -m integration 選擇性執行

Quick Start快速開始

Install

pip install mcp-cpbl-statistics

Or with uv:

uv sync

Use with Claude Code

claude mcp add --transport stdio cpbl-statistics -- mcp-cpbl-statistics

Use with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "cpbl-statistics": {
      "command": "uv",
      "args": ["run", "mcp-cpbl-statistics"]
    }
  }
}

Or with pip:

{
  "mcpServers": {
    "cpbl-statistics": {
      "command": "mcp-cpbl-statistics"
    }
  }
}

# 安裝相依套件
uv sync

# 啟動伺服器(stdio 傳輸)
uv run mcp-cpbl-statistics

Available Tools可用工具

Standings

Tool Description
get_season_standings Current season team standings (W/L record, pitching, batting, fielding)
get_history_standings Historical standings for a given year (first half / second half / full season)

Top Lists

Tool Description
get_toplist Season top-5 leaderboards for ERA, W, SV, HLD, SO, AVG, H, HR, RBI, SB

Players

Tool Description
search_players Search active players by name (partial match); returns player ID, name, team
get_player_profile Player profile: jersey number, position, batting/throwing hand, height/weight, birthday, first appearance, education, draft
get_player_stats Career or single-season batting/pitching stats for a player
get_player_apart_stats Split stats (home/away, vs. opponent, lineup position, runners on base, inning, score situation, month, stadium, etc.)
get_player_game_log Per-game log for a player, optionally filtered by year or last N games
get_player_headtohead Head-to-head matchup stats for a player against a specific team

Schedule

Tool Description
get_schedule Game schedule / results, filterable by year, month, team, and game type; finished games include score, W/L/SV pitchers, and MVP

kind_code values (shared across tools)

Code Description
A 一軍例行賽 (1st team regular season, default)
B 一軍明星賽 (All-Star game)
C 一軍總冠軍賽 (Championship series)
D 二軍例行賽 (2nd team)
E 一軍季後挑戰賽 (Postseason challenger)
G 一軍熱身賽 (Spring training)

目前這個伺服器共提供 10 個 MCP tool。

戰績

  • get_season_standings — 取得本季球隊戰績(勝負戰績、投球、打擊、守備)
  • get_history_standings — 取得指定年度的歷年戰績(上半季/下半季/全年)

單項排行

  • get_toplist — 取得年度單項排行榜前五名(ERA、W、SV、HLD、SO、AVG、H、HR、RBI、SB)

球員

  • search_players — 依姓名搜尋現役球員(支援部分匹配);回傳球員 ID(acnt)、姓名、球隊
  • get_player_profile — 取得球員基本資料:背號、位置、投打習慣、身高體重、生日、初出場、學歷、選秀
  • get_player_stats — 取得球員生涯累計或單一年度的打擊/投球成績
  • get_player_apart_stats — 取得球員分項成績(主客場、對戰對象、打序、壘上跑者、局數、比分情況、月份、球場等)
  • get_player_game_log — 取得球員逐場成績,可依年度或最近 N 場篩選
  • get_player_headtohead — 取得球員對特定球隊的投打對決累計成績

賽程

  • get_schedule — 查詢賽程與比賽結果,可依年度、月份、球隊、賽制篩選;已結束的比賽包含比分、勝投/敗投/救援投手及 MVP

kind_code 賽制代碼(各工具共用)

代碼 說明
A 一軍例行賽(預設
B 一軍明星賽
C 一軍總冠軍賽
D 二軍例行賽
E 一軍季後挑戰賽
G 一軍熱身賽

License授權

MIT

MIT License — 詳見 LICENSE

Project StructureProject Structure

mcp-cpbl-statistics/
├── main.py                              # Stub entry point (unused)
├── pyproject.toml                       # Project metadata & scripts
├── .mcp.json                            # Local MCP server config
│
└── src/mcp_cpbl_statistics/
    ├── server.py                        # FastMCP server, registers all tools
    ├── scraper/
    │   └── fetcher.py                   # HTTP client (HTML scraping + JSON POST APIs)
    ├── models/                          # Pydantic output models
    │   ├── standings.py
    │   ├── toplist.py
    │   ├── player.py
    │   ├── apart.py
    │   ├── game_log.py
    │   ├── headtohead.py
    │   ├── schedule.py
    │   └── teams.py                     # Team code registry
    └── tools/                           # MCP tool implementations
        ├── standings/                   # get_season_standings, get_history_standings
        ├── toplist/                     # get_toplist
        ├── player/                      # search_players, get_player_*, ...
        └── schedule/                    # get_schedule
mcp-cpbl-statistics/
├── main.py                              # 進入點存根(未使用)
├── pyproject.toml                       # 專案設定與腳本
├── .mcp.json                            # 本機 MCP 伺服器設定
│
└── src/mcp_cpbl_statistics/
    ├── server.py                        # FastMCP 伺服器,註冊所有工具
    ├── scraper/
    │   └── fetcher.py                   # HTTP 客戶端(HTML 解析 + JSON POST API)
    ├── models/                          # Pydantic 輸出模型
    │   ├── standings.py
    │   ├── toplist.py
    │   ├── player.py
    │   ├── apart.py
    │   ├── game_log.py
    │   ├── headtohead.py
    │   ├── schedule.py
    │   └── teams.py                     # 球隊代碼對照表
    └── tools/                           # MCP 工具實作
        ├── standings/                   # get_season_standings, get_history_standings
        ├── toplist/                     # get_toplist
        ├── player/                      # search_players, get_player_*, ...
        └── schedule/                    # get_schedule

TestingTesting

Unit tests run against saved HTML/JSON fixtures (no live network calls required):

uv run pytest

Integration tests make live requests to cpbl.com.tw and are excluded by default:

uv run pytest -m integration

單元測試使用已儲存的 HTML/JSON fixture,不需要網路連線:

uv run pytest

整合測試會對 cpbl.com.tw 發出即時請求,預設不執行:

uv run pytest -m integration

Data SourceData Source

All data is scraped from the official CPBL website (cpbl.com.tw). No API keys are required. The scraper handles CSRF token extraction automatically for POST-based JSON APIs.

所有資料均爬取自中華職棒官方網站(cpbl.com.tw)。無需 API 金鑰,爬蟲會自動處理 POST API 所需的 CSRF token。

RequirementsRequirements

  • Python >=3.12(開發環境使用 3.14
  • uv
  • Python >=3.12(開發環境使用 3.14
  • uv

ConfigurationConfiguration

專案內附 .mcp.json 供本機使用:

{
  "mcpServers": {
    "cpbl-statistics": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "mcp-cpbl-statistics"]
    }
  }
}

專案內附 .mcp.json 供本機使用:

{
  "mcpServers": {
    "cpbl-statistics": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "mcp-cpbl-statistics"]
    }
  }
}

Tags標籤

dataglobalcpblstatistics

Related MCP Servers相關 MCP 伺服器