@pipeworx/historical-baseball
Connect: https://pipeworx.io/mcp — every tool in the catalog, including @pipeworx/historical-baseball’s. Install: one-click buttons
Connect to just the @pipeworx/historical-baseball pack
https://gateway.pipeworx.io/historical-baseball/mcp — only @pipeworx/historical-baseball’s own tools, nothing else in the catalog.
No MCP client? Skip the connection: POST https://gateway.pipeworx.io/v1/tools/search_packs {"query":"..."} to find a tool below, GET /v1/tools/<name> for its schema, POST the same URL with arguments for the data — see For AI agents.
Tools: 5
Historical MLB statistics: career batting/pitching lines, team-season
records, per-game box-score summaries, and season leaderboards, back to
1871. Fleet #2976 — the live mlb-stats pack only covers the current MLB
Stats API; this pack is the historical record underneath it.
Tools
baseball_player_history(player)— year-by-year batting and/or pitching stats for one player’s whole career. Pass a name (“Babe Ruth”) or an exact Lahmanplayer_id(“ruthba01”). An ambiguous name returns a candidate list (withplayer_id) instead of guessing.baseball_team_season(team, year)— one team’s full-season record for one year: wins/losses, division/league/World Series result, team batting and pitching totals, park and attendance. Pass a code (“NYA”) or common name (“Yankees”).baseball_game_log(date, team)— box-score-level summary of the game(s) one team played on one date (an array, so doubleheaders return two games): final score, winning/losing/save pitcher, managers, and each side’s AB/H/2B/3B/HR/RBI/BB/SO/errors. Covers regular season plus All-Star, Division Series, League Championship Series, Wild Card and World Series games (game_type: R/A/D/L/C/W).baseball_season_leaders(year, stat, league?, limit?)— top-N leaderboard for one batting or pitching stat in one season. Batting:HR, AVG, RBI, R, H, SB, BB, SO, 2B, 3B. Pitching:W, ERA, SO_P, SV, L, WHIP.AVG/ERA/WHIPapply a simple qualifying floor (AB>=100 / IPouts>=100), not MLB’s official plate-appearance/innings qualifying rule.baseball_coverage()— the loaded Retrosheet date range, latest Lahman season year, and when it was last refreshed. Call this if a date/year you expect to exist comes back not-found.
Team codes changed for several relocated/renamed franchises (e.g. the
Athletics’ Retrosheet code changed for the 2025 move to Sacramento); both the
old and new codes exist in the data where applicable, and a handful of common
names and well-known defunct franchises resolve automatically (see
TEAM_ALIASES in src/store.ts). An unrecognized team/year/date/stat is
refused with a clear error, never an empty success.
Auth
Keyless. The tools answer only through the Pipeworx gateway, which holds the
data; a standalone npm install has no data to read, and every tool throws a
clear “not bound in this runtime” error there instead of returning an empty
list.
Data sources
-
Retrosheet (retrosheet.org/gamelogs) — one row per game, 1871-2025. Free with a required attribution notice, reproduced verbatim in every
baseball_game_logresponse:The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at “www.retrosheet.org”.
-
SABR Lahman Baseball Database (sabr.org/lahman-database) — season batting/pitching/team tables and player bios, 1871-2025 (now including Negro Leagues statistics licensed from Seamheads.com), maintained by SABR from Sean Lahman’s original donation. Licensed CC BY-SA 3.0 Unported (Creative Commons Attribution-ShareAlike):
This database is copyright 1996-2025 by SABR, via generous donation from Sean Lahman. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. For details see: http://creativecommons.org/licenses/by-sa/3.0/
Neither source publishes a live query API — both ship bulk files only — so this pack builds a copy rather than proxying (CLAUDE.md “BUILD THE COPY”). Scope: season and game AGGREGATES only. Retrosheet’s play-by-play EVENT files are never loaded; game logs are already one row per game and Lahman’s tables are already one row per player-team-season, so unlike a raw-flight or raw-delivery source, neither needed an aggregation step here.
Licensing and ShareAlike compliance
The Lahman tables (people, batting_season, pitching_season,
teams_season) are built from SABR’s bulk files rather than answered by
calling SABR live per request — and CC BY-SA 3.0’s ShareAlike term applies to
that kind of build, not to calling an upstream live. Concretely, that means:
- Attribution (BY): every response from a Lahman-backed tool carries
source(SABR/Sean Lahman),source_url(sabr.org/lahman-database) and the full license text inlicense, and this README states it again. - ShareAlike: because we hold and redistribute a derivative of these
specific four tables (via the tool responses above), that derivative is
itself licensed CC BY-SA 3.0 — same as the source, not more restrictively.
If you build a product on data returned by
baseball_player_history,baseball_team_seasonor the batting/pitching side ofbaseball_season_leaders, your own adaptation of that data carries the same CC BY-SA 3.0 obligation: credit SABR/Sean Lahman, and license your own redistribution of it under CC BY-SA 3.0 or a compatible license. - This does not extend to the Retrosheet-backed
baseball_game_logdata, which carries only Retrosheet’s own attribution requirement (quoted above), no ShareAlike term. - It does not restrict anything else in the Pipeworx catalog — ShareAlike
“infects” only the specific copied/adapted work, not an unrelated codebase
that happens to also call this gateway (the same reasoning as the
symmapprecedent in CLAUDE.md, applied to a license that actually requires it rather than one that was waived).
Refreshing or extending the data
node scripts/historical-baseball/load-data.mjs
# Retrosheet only (skip re-downloading/parsing Lahman's local CSVs):
node scripts/historical-baseball/load-data.mjs --skip-lahman
# Lahman only, once new CSVs are in place:
node scripts/historical-baseball/load-data.mjs --skip-retrosheet
Retrosheet is fully automated. The loader downloads
https://www.retrosheet.org/gamelogs/gl1871_2025.zip (a stable combined bulk
file covering 1871-2025 plus All-Star/postseason game logs) directly — no
manual step. Re-run once Retrosheet publishes the following season’s combined
zip (check https://www.retrosheet.org/gamelogs/ for a newer
gl1871_20XX.zip, or a standalone gl20XX.zip before the combined file is
updated).
Lahman is NOT automated and needs a one-time manual download. SABR
distributes the comma-delimited release through signed per-file Box.com
links (sabr.box.com/s/<share-id>/file/<id>) minted by Box’s web app —
there is no stable, curlable URL for the CSVs themselves (unlike Retrosheet’s
zip). To refresh:
- Open https://sabr.org/lahman-database/ and follow the “Comma-delimited
version” link (currently
sabr.box.com/s/...) under “Download latest version”. - Download
Teams.csv,People.csv,Batting.csvandPitching.csvfrom that Box folder into a local directory. - Run the loader with
--lahman-dir <that directory>(defaults to../lahman-csvrelative to this repo’s root, i.e. a sibling of thepipeworxcheckout).
Each run replaces every table (DROP + reload), because SABR republishes corrected editions of the whole file rather than publishing incremental diffs, so a clean reload is the only way to avoid stale rows from a previously-corrected season lingering alongside the new data.
Needs wrangler logged in to the Pipeworx Cloudflare account for either
source.
Tools
- baseball_player_history — Career year-by-year batting/pitching lines for one MLB player.
- baseball_team_season — One team’s season record, standings result and team stats for one year.
- baseball_game_log — Per-game box-score summary for one team on one date (handles doubleheaders).
- baseball_season_leaders — Top-N leaderboard for one batting or pitching stat in one MLB season.
- baseball_coverage — Loaded date/year ranges and when they were last refreshed.
Tools
baseball_coverage— Loaded date/year ranges and when they were last refreshed.baseball_game_log— Per-game box-score summary for one team on one date (handles doubleheaders).baseball_player_history— Career year-by-year batting/pitching lines for one MLB player.baseball_season_leaders— Top-N leaderboard for one batting or pitching stat in one MLB season.baseball_team_season— One team's season record, standings result and team stats for one year.