fantrax-mcp

fantrax-mcp

MCP server for Fantrax fantasy baseball that provides tools to read league info, rosters, standings, free agents, and related data.

Category
访问服务器

README

fantrax-mcp

MCP server for Fantrax fantasy baseball. It exposes tools to read league info, rosters, standings, free agents, and related data. The server is league-scoped: set one Fantrax league ID per deployment or local process.

Requirements

  • Node.js 18+
  • pnpm (or use npx / npm equivalents)

Environment

Variable Required Description
FANTRAX_LEAGUE_ID Yes Fantrax league ID (from the league URL)

The app does not load .env automatically for the stdio entrypoint; set variables in your shell or in your MCP client config (env).

MCP tools

All tools use the league configured by FANTRAX_LEAGUE_ID. Atomic tools map roughly one-to-one to Fantrax data; composite tools combine several calls for common workflows.

Atomic

Tool Description
get_league_info Full league info: teams, roster settings, player statuses. Prefer get_league_summary when you only need high-level details.
get_league_summary Lightweight league info: name, season year, start/end dates, roster and draft settings.
get_standings Standings: rank, points, and win percentage per team.
list_teams All teams with teamId, teamName, and rank — use before tools that require a team ID.
get_all_rosters Every team’s roster (player IDs, positions, salary). Prefer get_team_roster for a single team.
get_team_roster One team’s roster (teamId).
get_free_agents Free agents with name, MLB team, position, and eligible fantasy positions.
get_player_info MLB player ADP-style data for ranking and valuation. Optional: position, limit, order.
get_scoring_categories Stats that count in this league — use when comparing or recommending players.

Composite

Tool Description
get_enriched_rosters All rosters enriched with player names and ADP.
find_trade_targets Trade targets by position and max ADP (teamId, position, maxAdp; optional status exclusions and whether to search all teams vs bottom half).
get_team_overview One team’s roster, standings position, and league scoring categories (teamId).
get_waiver_candidates Free agents ranked by ADP, with scoring categories — for add/drop decisions.
compare_players Side-by-side comparison for two players by name, with league scoring context.

Run locally (stdio MCP)

Use this when your client spawns a subprocess and talks MCP over stdin/stdout (e.g. Cursor, Claude Desktop).

From the repo root:

pnpm install
export FANTRAX_LEAGUE_ID=your-league-id
pnpm mcp:stdio

Cursor (~/.cursor/mcp.json or project .cursor/mcp.json):

{
  "mcpServers": {
    "fantrax": {
      "command": "pnpm",
      "args": ["mcp:stdio"],
      "cwd": "/absolute/path/to/fantrax-mcp",
      "env": {
        "FANTRAX_LEAGUE_ID": "your-league-id"
      }
    }
  }
}

Prefer the example above: it runs the lockfile-pinned tsx from this repo. Using npx tsx … for the local server works after pnpm install, but npx adds resolver/caching overhead on each spawn compared to pnpm mcp:stdio or pnpm exec tsx src/mcp-stdio.ts. If you use npm, npm run mcp:stdio with the same cwd is the analogous choice.

Important: Do not log to stdout in the stdio server; MCP uses stdout for the protocol.

Run remotely (HTTP MCP)

This repo is a Next.js app. The MCP endpoint is served by mcp-handler at:

https://<your-host>/api/mcp

Examples:

  • Local dev: http://localhost:3000/api/mcp (after pnpm dev)
  • Production: https://<project>.vercel.app/api/mcp (or your custom domain)

Clients that support Streamable HTTP can use the URL directly, for example:

{
  "mcpServers": {
    "fantrax-remote": {
      "url": "https://your-deployment.vercel.app/api/mcp"
    }
  }
}

If your client only supports stdio, proxy the remote server with mcp-remote:

{
  "mcpServers": {
    "fantrax-remote": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://your-deployment.vercel.app/api/mcp"]
    }
  }
}

Deploy to Vercel

  1. Push this repository to GitHub (or another supported Git provider).
  2. In the Vercel dashboard, import the project and select the Next.js preset.
  3. Under Settings → Environment Variables, add FANTRAX_LEAGUE_ID for Production (and Preview if you want preview deployments to work).
  4. Deploy. The build runs prebuild, which generates src/player-ids.json via scripts/generate-player-ids.ts.

Official reference: Deploying Next.js to Vercel.

Scheduled rebuilds

Production is redeployed automatically every Monday and Thursday at approximately 6:00 AM Eastern via .github/workflows/scheduled-rebuild.yml. The workflow POSTs to a Vercel Deploy Hook, which runs a full build (including prebuild player ID refresh).

One-time setup:

  1. In Vercel: Settings → Git → Deploy Hooks — create a hook named e.g. scheduled-production-rebuild on branch main for Production.
  2. In GitHub: Settings → Secrets and variables → Actions — add VERCEL_DEPLOY_HOOK_URL with the hook URL.

Manual trigger: Actions → Scheduled production rebuild → Run workflow.

Timezone note: GitHub cron uses UTC only (no DST). The schedule 0 11 * * 1,4 runs at 6:00 AM EST and 7:00 AM EDT. To target 6:00 AM during daylight saving instead, change the cron to 0 10 * * 1,4 (5:00 AM in winter).

Player data at build time

pnpm build runs prebuild first (package.json), which executes scripts/generate-player-ids.ts. That script fetches the MLB player ID catalogue from Fantrax’s public getPlayerIds API over HTTPS and writes src/player-ids.json. The build host must allow outbound network access; if the fetch fails, the build exits with an error. This step does not use FANTRAX_LEAGUE_ID (that variable is only for runtime MCP requests against your league).

Development

Script Purpose
pnpm dev Next.js dev server (remote MCP at /api/mcp)
pnpm mcp:stdio Local stdio MCP server
pnpm build Production build (prebuild regenerates player IDs)
pnpm test Vitest
pnpm typecheck tsc --noEmit

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选