Skip to main content
Glama
ligamx-mcp

ligamx-mcp

by fferegrino

Liga MX API

Query Liga MX form, head-to-head history, and tournament standings from football-data.co.uk match data.

Data is rebuilt daily into a local SQLite database (data/ligamx.db). Form and H2H are answered from the matches table; standings are materialised at rebuild time.

Setup

Requires Python 3.12+ and uv.

uv sync
DATA_URL=https://www.football-data.co.uk/new/MEX.csv ./scripts/rebuild_db.sh

Or rebuild from an existing CSV without re-downloading:

uv run python -m ligamx.etl

Related MCP server: copamind-mcp

Run the server

One process serves both the REST API and MCP (streamable HTTP):

uv run ligamx-serve
# or
uv run uvicorn ligamx.api:app --reload

Deploy on Fly.io

The image rebuilds data/ligamx.db from DATA_URL on every start (fits free machines that stop when idle).

Set the CSV URL as a Fly secret (required by scripts/rebuild_db.sh):

fly secrets set DATA_URL=https://www.football-data.co.uk/new/MEX.csv
# once: install flyctl, log in, then from the repo root:
fly launch        # accept the existing fly.toml; pick a unique app name if needed
fly deploy

Useful checks:

fly status
fly logs
fly open /docs

App URL will look like https://<app-name>.fly.dev — MCP at /mcp, REST docs at /docs.

After deploy, optional daily refresh without idle sleep:

fly machine run --schedule daily ...   # or just rely on rebuild-on-boot when traffic wakes the machine

On the free allowance, auto_stop_machines means the first request after idle pays a cold start (download CSV + ETL + boot).

MCP (HTTP)

Point an MCP client at the streamable HTTP URL (no stdio):

{
  "mcpServers": {
    "ligamx": {
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}

Exact client config keys vary; the transport is streamable HTTP at /mcp.

MCP tools

Tool

Description

list_teams

All known team slugs

team_form

Last n matches for a team (default 5, max 30)

head_to_head

Historical H2H between two slugs

current_standings

Full current tournament table

team_position

One team’s row in the current table

REST and MCP share ligamx/service.py payloads.

Endpoints

Method

Path

Description

GET

/health

Liveness check

GET

/teams/{slug}/form?n=5

Last n matches for a team (default 5, max 30), newest first

GET

/h2h/{slug_a}/{slug_b}

Historical head-to-head + summary

GET

/standings/current

Full table for the current tournament

GET

/teams/{slug}/position

One team’s row in the current table

*

/mcp

MCP streamable HTTP endpoint

Unknown team slugs return 404.

Examples

curl 'http://127.0.0.1:8000/teams/america/form?n=10'
curl 'http://127.0.0.1:8000/h2h/america/guadalajara'
curl 'http://127.0.0.1:8000/standings/current'
curl 'http://127.0.0.1:8000/teams/tigres/position'

Pipeline

MEX.csv  →  ligamx.etl  →  ligamx.db  →  FastAPI (REST + MCP /mcp)
                 │
                 ├─ matches (raw names + slugs)
                 └─ standings (per season + tournament)
  1. scripts/rebuild_db.sh downloads DATA_URL (required env var) into data/MEX.csv and runs the ETL.

  2. ETL loads matches via the CSV reader, normalises team names to slugs, writes a temp SQLite file, then atomically replaces data/ligamx.db.

  3. Standings are aggregated with 3/1/0 points and ranked by points → goal difference → goals for.

Tournaments

The CSV only has a Season string (e.g. 2025/2026). Short tournaments are derived from the match date:

  • Apertura — July–December

  • Clausura — January–June

“Current” standings use the season and tournament of the latest match in the database.

Team slugs

Raw CSV labels are kept on each match; API paths use stable slugs from ligamx/teams.py:

Slug

CSV label

america

Club America

atlante

Atlante

atlas

Atlas

atletico-san-luis

Atl. San Luis

chiapas

Chiapas

cruz-azul

Cruz Azul

dorados

Dorados de Sinaloa

guadalajara

Guadalajara Chivas

juarez

Juarez

leon

Club Leon

leones-negros

Leones Negros

lobos-buap

Lobos BUAP

mazatlan

Mazatlan FC

monterrey

Monterrey

morelia

Monarcas

necaxa

Necaxa

pachuca

Pachuca

puebla

Puebla

pumas

UNAM Pumas

queretaro

Queretaro

santos-laguna

Santos Laguna

tigres

Tigres UANL

tijuana

Club Tijuana

toluca

Toluca

veracruz

Veracruz

Package layout

Path

Role

ligamx/reader.py

Parse MEX.csv into Match rows

ligamx/teams.py

Raw name → slug map

ligamx/db.py

Schema + SQLite connection

ligamx/etl.py

Daily rebuild + standings

ligamx/queries.py

Form / H2H / standings helpers

ligamx/service.py

Shared JSON payloads for API + MCP

ligamx/api.py

FastAPI REST + MCP HTTP mount

ligamx/mcp_server.py

MCP tool definitions

scripts/rebuild_db.sh

Download + ETL entrypoint

scripts/start.sh

Container entrypoint (rebuild + serve)

Dockerfile / fly.toml

Fly.io deploy

data/notes.txt

football-data.co.uk column key

Library usage

from ligamx.queries import get_form, get_h2h, get_standings, get_position

get_form("america", n=5)
get_h2h("america", "guadalajara")
get_standings()           # current tournament
get_position("tigres")

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    • Independent statistical feature evaluation for machine learning and forecasting. ML Referee tests up to 1,000 candidate features in one run against a declared baseline, helping researchers and AI agents decide which inputs to pursue, which bounded feature repairs merit further testing, and where more evidence is needed—without a separate ablation run for every feature. Use the MCP tools to discover input schemas, check access and credits, preflight a dataset, obtain a quote, submit an authorized evaluation, and retrieve structured results and reports. Results are scoped to the submitted evidence and evaluation design; they do not guarantee future model performance. Invite-only beta with manual approval. Public tool discovery requires no authentication; account and evaluation tools require OAuth through approved client connections and available evaluation credits. Connect directly to https://api.mlreferee.com/mcp. Website: https://mlreferee.com Request beta access: https://mlreferee.com/beta Agent setup and documentation: https://mlreferee.com/agents

      https://api.mlreferee.com/mcp
    • Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.

      https://climbpast.com/api/mcp
    • Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.

      https://livecontext.ai/mcp
    • Hosted MCP server from TwitterAPI.io that gives AI agents read-only access to Twitter/X data. 12 tools: tweet search with X operators, user profiles, a user's latest tweets, followers and followings, replies, quotes, retweeters, mentions and trends. Connect at https://mcp.twitterapi.io/mcp with a TwitterAPI.io API key or account sign-in; usage is paid per result returned.

      https://mcp.twitterapi.io/mcp

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Provides live football data through MCP tools, enabling users to fetch today's matches and top scorers for competitions like the Premier League or World Cup.
      2
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables interaction with the CopaMind platform via MCP, exposing read-only and write tools for querying match predictions, Monte Carlo simulations, team rankings, and RAG-based explanations, all while maintaining full traceability and reproducibility.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables MCP clients to access live football data from FotMob, including match stats, team form, injuries, and player workload, without making predictions.
      10
      1
      MIT
    • F
      license
      A
      quality
      B
      maintenance
      Enables querying FotMob football data including matches, match details, teams, leagues, players, and search through MCP-compatible LLM clients.
      6
      -