hltv-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@hltv-mcp what are the live Counter-Strike scores right now?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
📦 已迁移到新仓库 / Project moved
旧版 frogg435/hltv-mcp 已停止维护,请改用 👉 frogg436/hltv-mcp。
新版本有 27 个工具(旧版 18 个)、修复了排行榜数据错误、并大幅降低内存占用。迁移说明见 MIGRATION.md。
The old frogg435/hltv-mcp is deprecated. Please use 👉 frogg436/hltv-mcp instead.
The new version ships 27 tools (vs. 18), fixes ranking data bugs, and uses far less memory. See MIGRATION.md.
hltv-mcp
让 AI 直接查询 HLTV.org 的 Counter-Strike 赛事数据 Let AI query HLTV.org for Counter-Strike match data
赛程 · 赛果 · 实时比分 · 世界排名 · 战队 · 选手 · 赛事 · 新闻 Matches · Results · Live scores · Rankings · Teams · Players · Events · News
简体中文
让 AI 直接查询 HLTV.org 的 Counter-Strike 赛事数据 —— 赛程、赛果、世界排名、战队、选手、新闻、赛事日历。
默认用真实浏览器取数据:后台运行、界面上完全看不见,也不会打扰你正在浏览的页面。 支持 Windows / macOS / Linux,以及 Android Termux。
为什么用这个版本(对比旧版 frogg435/hltv-mcp)
本仓库在旧版基础上做了全面升级:工具从 18 个扩展到 27 个,并修复了若干数据正确性问题。
能力 | frogg435/hltv-mcp(旧版) | 本仓库 |
工具数量 | 18 | 27 |
选手 / 比赛 / 战队照片下载 | ❌ | ✅ |
击杀矩阵 / 单图表现 | ❌ | ✅ |
选手对位 / 阵容对位 | ❌ | ✅ |
角色标签(IGL / AWPer)+ 角色推断 | ❌ | ✅ |
单赛事选手统计(Rating / KAST / ADR…) | ❌ | ✅ |
空闲自动关闭浏览器(显著省内存) | ❌ | ✅ |
渲染进程上限 / 浏览器掉线自动重连 | ❌ | ✅ |
知名选手 / 战队 ID 缓存(毫秒级解析) | ❌ | ✅ |
排行榜 | ❌(误解析成选手 ID) | ✅(已修复) |
结论:本仓库功能更完整、更省内存、数据更准确,是可直接替换旧版的升级版本。
它能回答什么
提问 | 调用的工具 |
今天有哪些比赛? |
|
现在正在打的有哪些? |
|
现在比分多少? |
|
Vitality 最近战绩如何? |
|
现在世界排名前 30 是谁? |
|
ZywOo 的 Rating 和生涯荣誉? |
|
ZywOo 历年表现怎么样? |
|
ropz 每年 Rating 多少? |
|
这场比赛 Inferno 上 CT 方谁打得好? |
|
这届 Major 奖金多少?谁参加? |
|
FaZe 最近战绩如何? |
|
FaZe 和 Vitality 历史交手谁强? |
|
FaZe 现在阵容都有谁? |
|
最近有什么新闻? |
|
接下来有哪些大赛? |
|
所有工具都接受 ID 或名称 —— 直接写 name="Vitality" 就行,服务端会自动解析成 ID,不需要模型先查一遍搜索。
只想飞快地看一眼当前比分?仓库里带了
python scripts/hltv-live—— 不经浏览器直连 HLTV, 1~2 秒出结果,见下文「极速实时比分」。
安装
git clone <repo> && cd hltv-mcp
python3 -m venv .venv
.venv/bin/pip install -e .依赖里没有 Playwright —— 浏览器控制由自带的原生 CDP 客户端完成,只有一个纯 Python
的 websocket-client 依赖。这么设计有两个原因:Playwright 在 Termux/Android 上装不起来,
而且它创建标签页时一定会抢焦点(见下文「不打扰你的浏览」)。
前提是本机装了 Chrome / Chromium / Edge 之一(三选一即可)。Linux 上还建议装 Xvfb,
用来提供「界面上看不见」的虚拟显示。装不了浏览器(比如 CI)就改用 HTTP 后端:
pip install -e ".[http]" 并设置 HLTV_BACKEND=http。
curl_cffi是可选依赖。 只有 HTTP 后端需要它,默认的浏览器后端用不到。 它需要编译 curl-impersonate + BoringSSL,在 Android 等平台上很难装成功,因此不要 把它加回dependencies。
Android / Termux 离线安装(零编译)
Termux 上装 Python 依赖最痛的一环是现场编译原生扩展(lxml、cryptography、pydantic_core…)。
本仓库提供一个预编译好的离线包,解压后一条命令装完,全程不编译任何东西:
tar xzf hltv-mcp-termux-offline.tar.gz
cd hltv-mcp-termux-offline
bash install.sh包里已经放了全部 29 个 wheel(含 Android ARM64 版的 pydantic_core,以及 pip install -e . 需要的构建后端 setuptools),安装时用
--no-index 强制只读本地文件,完全不访问 PyPI。详见
Releases 页面的离线包说明。
离线包的构建脚本也在仓库里(termux/):build-bundle.sh 可在任意有网络的 Linux/macOS 上
重新产出该包,采用可复现构建,相同输入两次构建的字节完全一致。
脚本会同时给出可直接粘贴的 MCP 客户端配置,其中默认带上了 HLTV_CHALLENGE_WAIT=120:
部分网络出口首次访问 HLTV 时,Cloudflare 挑战可能远超默认的 25 秒(实测中国联通出口约需 120 秒)。 调大它可以避免首次查询直接超时;挑战一旦通过、
cf_clearance落盘,后续启动走热路径就很快了。 桌面端如果首次就正常,不必改这个值。
接入 MCP 客户端
在客户端的 MCP 配置里加上:
{
"mcpServers": {
"hltv": {
"command": "/绝对路径/hltv-mcp/.venv/bin/python",
"args": ["-m", "hltv_mcp"],
"env": {
"PYTHONPATH": "/绝对路径/hltv-mcp/src"
}
}
}
}用 pip install -e . 装过之后,也可以直接用命令入口:
{
"mcpServers": {
"hltv": { "command": "/绝对路径/hltv-mcp/.venv/bin/hltv-mcp" }
}
}不需要任何环境变量。 服务启动时会在后台预热:拉起浏览器,并把赛程、实时比分、 赛果、排名这几个常用页各取一遍。实测 Cloudflare 对首访的某些路径会额外给一次真挑战 (10–25 秒),这样做等于把这些代价提前到启动时消化掉,第一次查询就已经是热的。
预热会让路:第一页之后,每一页都要先等 8 秒确认你没在查询,一旦有请求进来就立刻收工, 不会把慢请求堆在你前面。之后复用同一个浏览器实例,MCP 退出时自动关掉它。
几个可选的调优项:
{
"env": {
"HLTV_BACKEND": "auto",
"HLTV_BROWSER_VISIBLE": "0"
}
}工具清单
工具 | 说明 |
| 搜索选手/战队/赛事/新闻,名称 → ID |
| 赛程(即将开始 + 进行中),支持按队伍/赛事过滤、只看直播 |
| 实时比分快照:正在进行的比赛、当前地图回合数、已赢地图数(轮询获取进展) |
| 赛果,含比分与胜方,支持分页 |
| 单场详情:地图比分 + 逐地图分队伍的选手数据(昵称、选手 ID、国籍、K-D、ADR、KAST、Rating、Swing) |
| 世界战队排名(含积分) |
| 战队资料:排名、教练、阵容 |
| 选手资料:Rating 3.0、能力评分、生涯荣誉汇总 |
| 选手逐年生涯:历年在哪支队、历年 Top20 排名、奖项、冠军、MVP |
| 选手逐年 Rating 与详细数据:Rating、K/D、ADR、地图数、对 Top5/10/20 对手的 Rating |
| 单场比赛逐地图、分阵营(CT/T)的选手数据:Op.K-D、多杀、KAST、1vX、爆头、ADR、Rating |
| 赛事详情:奖金池、日期、地点、VRS 权重、参赛队、名次与奖金分配 |
| 战队近期战绩:日期、对手、比分、胜负 |
| 两队交手记录:逐地图明细 + 按地图聚合胜率 |
| 新闻列表 |
| 新闻正文 |
| 赛事日历 |
| 当前用哪种后端、浏览器是否可用;排查「查不到数据」时先调它 |
全部只读,没有任何写操作。
工作原理与已知限制
取页面的三种后端
后端 | 怎么用 | 特点 |
浏览器(默认) | 用真实浏览器取页面 | 过 Cloudflare 最稳;唯一能做点击交互;需要本机有浏览器 |
HTTP |
| 快、轻、无需浏览器;但过不了 Cloudflare 的路径级规则 |
hybrid | 先试 HTTP,被拦了自动改用浏览器 | 两种能力都有;代价是每次先花半秒探一次路 |
HLTV_BACKEND=auto(默认)/ browser / http / hybrid 控制选择,见下文「后端选择」。
Cloudflare
HLTV 在 Cloudflare 之后。实测(在出口 IP 干净的前提下):
方式 | 结果 |
裸 | ❌ 403 Just a moment... |
| ❌ 403 |
| ❌ 403 |
| ✅ 200,正常页面 |
真实浏览器 | ✅ 200,含 /stats/* |
HTTP 后端用 curl_cffi 且 impersonate="safari17_0"。换网络环境后最优指纹可能不同,可用 HLTV_IMPERSONATE 覆盖。
后端:默认用真实浏览器
Cloudflare 按 IP 累积信誉,封禁会逐级升级:
干净 IP → 某条路径被拦(如 /stats/*) → 整站 403(首页也进不去)进了第二、三阶段后,换客户端伪装是没用的 —— 我们实测过:
尝试 | 结果 |
换 7 种 TLS 指纹(Safari / Chrome 131 / 124 / 120 / Firefox / Edge) | 全部 403 |
无头 Chromium / 有头 Chromium(Xvfb)/ 有头真实 Chrome | 全部 403 |
加 stealth 脚本(抹 | 无效 |
真正有效的做法是用真实浏览器。 实测对照(同一 IP、同一时刻):
方式 |
|
|
| ❌ 403 | ❌ 403 |
真实浏览器 + 持久化配置文件 | ✅ 200 | ✅ 200 |
差异不在「有头/无头」,而在两点:真实浏览器的完整指纹,以及使用持久化的配置文件上下文。用匿名上下文同样会被拦。
所以默认后端就是浏览器,并且开箱即用 —— 不需要你先敲命令启动 Chrome:
# 什么都不用配,直接用。(首次会在 ~/.cache/hltv-mcp 建立独立 profile)
python scripts/browser_check.py启动器会自动完成这些事:
若已有带调试端口的浏览器在跑(或你设了
HLTV_BROWSER_CDP),直接复用否则自己拉起一个浏览器,用独立的持久化 profile(位于
~/.cache/hltv-mcp/chrome-profile)MCP 退出时只关掉自己拉起的那个实例;你自己的浏览器不会被碰
不打扰你的浏览
这是硬性设计目标,不是「尽量」:
界面上看不见。 Linux 上启动器会自己造一个 Xvfb 虚拟显示,浏览器有头运行但根本没有 显示设备;其他桌面系统把窗口挪到屏幕外。你既看不到窗口,也没有弹窗。
不抢焦点、不动你的标签页。 所有标签页都以 CDP 的
background=true创建, 用完立刻关闭。你正在看的页面不会被跳转,也不会被顶到后台。
这两件事都实测过。用 document.visibilityState 和 document.hasFocus() 作为客观指标,
在用户页面全程开着的情况下跑完 4 次真实查询:
查询前 | 全程查询中 / 查询后 | |
用户页面 URL |
| 未变 |
|
|
|
| 未变 | 未变 |
标签页数 | 1 | 1(无残留) |
对照实验也做了:用早期实现的 background=false 方式,同一场景下用户页面的
visibilityState 会立刻变成 hidden、hasFocus() 变 false —— 也就是被顶掉了。
这正是本项目不用 Playwright 的原因之一(它的 new_page() 一定会激活新标签页)。
python scripts/browser_check.py 里内置了这项检查,可以自己验证。
Android / Termux
Termux 是明确支持的目标平台:浏览器照样由本服务自己拉起、界面上看不见, 不需要动你手机上的浏览器,也不需要 adb 转发。
pkg install tur-repo x11-repo
pkg install chromium xorg-server-xvfb python
pip install hltv-mcp几个容易踩的点:
Chromium 不在官方 main 源里,它在 TUR(
tur-repo),并且依赖x11-repo里的 GTK/X11 库(即使跑无头也会链接这些库)。但注意:tur-repo和x11-repo这两个**「启用源」的包本身就在 main 源里** —— 所以只要官方源可用就够了, 不需要任何第三方源。反过来,如果pkg install chromium报找不到包, 先确认这两条pkg install tur-repo x11-repo执行成功了。Chromium 的可执行文件叫
chromium-browser,不是chromium。本项目会自动找到它 ($PREFIX/bin/chromium-browser)。xorg-server-xvfb是必须的 —— 它就是"界面上看不见"的实现方式:浏览器有头运行, 但没有显示设备。没有它就只能退化成无头模式,而无头会被 Cloudflare 拦。启动时自动带上 Android 需要的
--no-sandbox(Android 上 setuid 沙箱不可用)和--disable-gpu。Termux 把临时目录放在
$TMPDIR(/data/data/com.termux/files/usr/tmp)而不是/tmp, X11 的 socket 也跟着在那里 —— 本项目会在这三处一起找。
playwright 在这里是装不起来的 —— 官方直接抛 Unsupported platform: android,
而且它的 new_page() 一定会抢焦点。所以本项目不用它,改用自带的原生 CDP 客户端
(只需纯 Python 的 websocket-client)。
独立 profile 不是随便选的:一是避免拿你日常的浏览数据去开调试端口,二是 Chrome 在同
profile 已有实例运行时,新进程只会把标签页塞进旧实例、调试端口根本不会打开。它还有个
副作用是好的 —— profile 持久化后 cf_clearance 会留存,后续启动遇到的挑战明显更少。
安全边界:绝不关闭你的浏览器,不读取也不导出 cookie。用户如需登录态,自己在浏览器里 登录即可,本项目不经手任何账号密码。
无头模式会被拦(实测)
一个必须说清楚的点:--headless 会被 Cloudflare 拦。
模式 | 首页 |
|
|
| ❌ 挑战页 | ❌ 挑战页 | ❌ 挑战页 |
有头(含 Xvfb 虚拟显示) | ✅ 200 | ✅ 200 | ✅ 964KB |
所以「没有显示器」时不能直接退化成无头 —— 那等于静默失效。本项目的做法是:Linux 上
若检测到没有可用显示且有 Xvfb,就自己造一个虚拟显示(如 :99),让浏览器仍以有头模式
运行。实测这条路径在容器里同样可用,退出时会连虚拟显示一起收掉。
不用 Xvfb 也没关系:只要有显示环境(桌面系统),走的就是普通有头模式。
后端选择
| 行为 |
| 优先浏览器;只有浏览器根本起不来时才降级到 HTTP |
| 强制浏览器。起不来就报错,不降级 |
| 强制 HTTP。适合装不了浏览器的环境(CI、纯容器) |
| HTTP 优先,被 Cloudflare 拦了才自动改用浏览器,并记住「哪类路径必须用浏览器」 |
注意 auto 的降级边界:「页面被 Cloudflare 拦」不算「起不来」,那种情况不会降级 ——
因为 HTTP 后端会拿到同样的拦截页,降级只会把错误变得更难理解。只有「找不到浏览器 / 连不上
调试端口 / 启动超时」这类才降级,且会在 stderr 提示一次并转到 HTTP。
hybrid 是 auto 的「快路径版」而不是缩水版 —— 最终拿到的数据完全一样,只是把顺序倒过来:
先花半秒试一次廉价请求,被拦了才启动浏览器。实测 /stats/* 有独立的拦截规则,其余路径
HTTP 全通。
但要如实说:桌面端 hybrid 并不比默认的浏览器后端快(本机实测两者都在 1 秒上下)。
它的价值在弱设备 —— 手机/Termux 上渲染 1MB HTML 的代价比多一次网络往返更高。桌面用户
直接用默认的 auto 就好。
先诊断,再动手
python scripts/browser_check.py # 默认后端:检查浏览器能不能用、能不能取到 HLTV
python scripts/health.py # HTTP 后端:定位是 IP 级封禁还是路径级拦截health.py 的判读方式:
首页也 403 → IP 级封禁。换出口 IP,或改用默认的浏览器后端
只有个别路径 403 → 路径级规则(
/stats/*属于此类),浏览器后端不受影响
也可用代理(HLTV_PROXY)换出口。住宅 IP 效果最好;机房 IP 通常同样会被拦。
限流
请求频率是使用这个 MCP 时最需要注意的事。 短时间密集请求会让当前出口 IP 被 Cloudflare 单独限流,表现为某一路径持续 403,而其他路径正常,且恢复需要数分钟到数小时。
客户端默认做了这些事:
浏览器后端:间隔 0.5 秒 + 0–0.8 秒随机抖动(
HLTV_BROWSER_MIN_INTERVAL/HLTV_JITTER)。 浏览器请求本身就是「一个真人在翻页」,Cloudflare 的判定依据与裸 HTTP 完全不同, 按爬虫的标准自我设限只是白白卡自己HTTP 后端:间隔 3 秒(
HLTV_MIN_INTERVAL)。裸 HTTP 请求最像爬虫,也最容易被限流内存缓存:实时比分 15s、赛程 60s、赛果 120s、新闻 300s、排名 1h、选手/战队 30min
遇到 403 不立刻重建会话(那会丢掉已通过的 cookie,反而更糟),先退避重试,最后一次才换会话
如果某个工具持续报 403,把 HLTV_MIN_INTERVAL 调到 5 或更大,或换网络出口。
地图 × 阵营的比赛数据
hltv_get_match_stats 能给出某场 BO1/BO3/BO5 里,每张地图、每个阵营(CT/T)下每位选手的完整数据:
// hltv_get_match_stats(match_id=2399253, map="Inferno", side="ct")
{
"available_maps": ["2 - 1 Best of 3", "13 - 0 Dust2", "8 - 13 Inferno", "13 - 9 Mirage"],
"results": [{
"map": "Inferno",
"sides": {
"ct": [
{"team": "100 Thieves", "players": [
{"nickname": "rain", "opening_kd": "3 : 0", "multi_kills": "2", "kast": "83.3%",
"clutches_1vx": "0", "kills": "8 (4)", "assists": "5 (0)", "deaths": "8 (0)",
"adr": "78.8", "round_swing": "-2.27%", "rating": "0.90"}
]}
]
}
}]
}两个实现要点:
地图必须点击切换,阵营不用。 实测 DOM 里同时存在
totalstats/ctstats/tstats三套表,只有当前选中的那套不带hidden类 —— 所以一次取回三个阵营,只对地图做点击。比赛页的 "Detailed stats" 指向另一套 ID。 比赛页是
/matches/{id}, 统计页是/stats/matches/{另一个id},两者不通用,得先从比赛页里取出来。
关于 /stats/* 与逐年 Rating
/stats/* 路径(含逐年 Rating 所在的统计页)在 HTTP 后端下会被 Cloudflare 拦截。
启用浏览器后端后可以正常访问 —— 这是 hltv_get_player_year_stats 的前提。
// hltv_get_player_year_stats(player_id=11816, years=[2019, 2022, 2024, 2025, 2026])
{
"seasons": [
{"year": 2019, "rating_version": "Rating 2.0", "rating": 1.19, "kd_ratio": 1.29,
"adr": 80.4, "maps_played": 200, "kills": 4005},
{"year": 2024, "rating_version": "Rating 3.0", "rating": 1.13, "kd_ratio": 1.18,
"adr": 75.9, "maps_played": 189, "kills": 3035},
{"year": 2025, "rating_version": "Rating 3.0", "rating": 1.18, "kd_ratio": 1.24,
"adr": 78.6, "maps_played": 200, "kills": 3182}
],
"career_total": {"rating_version": "Rating 2.0", "rating": 1.15, "maps_played": 1915}
}注意 HLTV 的 Rating 体系改过版(1.0 → 2.0 → 2.1 → 3.0),跨年份的 Rating 数值不可直接比较,
所以每一季都返回了 rating_version 供判断。
一个名不副实的 URL
/stats/teams/matches/{a}/{b} 看起来是「a 与 b 的交手记录」,但实测它返回的是 a 队的全部比赛 ——
FaZe 的页面有 2063 张地图、131 个不同对手,第二个 ID 不起过滤作用,?contextIds= 参数也无效。
所以 hltv_get_head_to_head 改为本地按对手名过滤,才得到真正的 H2H
(FaZe vs Vitality = 81 张地图,37 胜 44 负,胜率 45.7%)。
代价是要下载整个页面(约 5MB / 5 秒)。
解析器维护
HLTV 会改版,选择器可能失效。当某个工具抽不到数据时:
python scripts/hltv_inspect.py /matches # dump 页面类名分布
python scripts/hltv_inspect.py /team/6667/x --selector .profile-team-stat定位到新类名后改 src/hltv_mcp/parsers.py 里对应的解析函数即可。所有解析器都遵循「缺字段返回 None,不抛异常」的约定,页面局部变化不会让整个工具调用失败。
速度
耗时几乎全在两处:浏览器冷启动和取页面本身。现在分别这么处理:
问题 | 做法 |
冷启动(起浏览器 + 过 Cloudflare 挑战)全压在第一次查询上 | 服务启动时后台预热,把这几秒挪进「客户端握手 + 你打字」的空档;预热还会让路,不会挡住你的查询 |
某些路径首次访问会被 Cloudflare 额外挑战一次(10–25 秒) | 把常用路径(赛程/实时比分/赛果/排名)都放进预热清单,在启动时消化掉 |
浏览器后端被按爬虫标准限速(每次请求硬等 3 秒) | 浏览器后端改用 0.5 秒间隔;HTTP 后端仍保持 3 秒 |
比赛统计页有两段固定 | 改成「等元素出现 / 等内容变化」,通常不到 1 秒就返回 |
挑战通过后页面由 JS 重载,中间有个「标题正常、内容残缺」的空壳 | 检测到这种情况就等内容稳定再取,避免收到一页残缺数据还不报错 |
本机实测(同一台机器、同一网络,逐页计时):
场景 | 优化前 | 优化后 |
赛程 / 赛果 / 排名 / 实时比分等常规页 | 2.6 – 4.2 秒 | 0.3 – 2.0 秒 |
实时比分首次查询(会撞上路径挑战) | 28 秒 | 0.8 秒(挑战已在启动预热里消化) |
比赛详细统计( | 8 秒以上(光固定等待就占 6.5 秒) | 约 2 秒 |
第一次查询(冷启动) | 2 – 15 秒 | ≈ 0(已被启动预热吸收) |
有一条不是代码能修的:对不在预热清单里的路径(
/stats/*尤其明显),首次访问 仍可能撞上一次真挑战,实测 9 – 25 秒,之后同一条路径都是 1 秒级。所以「第一次查某个 选手的逐年 Rating」偏慢属于正常,同一个选手再查就快了。想连这个也消掉,把对应路径加进HLTV_WARMUP_PAGES即可。
配置
环境变量 | 默认 | 说明 |
|
| 后端: |
|
| 启动时后台预热浏览器,让第一次查询不必等冷启动。置 |
|
| 预热依次取这些页面。实测 Cloudflare 对首访的某些路径( |
|
| 预热继续下一页之前,先等这么多秒看用户有没有动静。有请求就让路收工 |
| 空 | 复用一个外部已启动的浏览器,如 |
|
| 置 |
|
| 置 |
| 自动 | 置 |
| 自动探测 | 浏览器可执行文件路径(Chrome/Chromium/Edge) |
|
| 自动启动时优先使用的调试端口,被占则自动换 |
|
| 自动启动时用的独立 profile 目录 |
| 平台缓存目录 | 存放 profile、浏览器日志、端口记录 |
| 空 | 出口代理,形如 |
|
| HTTP 后端两次请求的最小间隔(秒) |
|
| 浏览器后端两次请求的最小间隔(秒) |
|
| hybrid 模式里那次探路 HTTP 请求的最小间隔(秒) |
|
| 间隔上的随机抖动上限(秒) |
|
| 单次请求超时(秒) |
|
| 失败重试次数 |
|
| 页面导航重试次数(浏览器后端) |
|
| 等 Cloudflare 挑战通过的上限(秒) |
|
| 挑战轮询间隔(秒) |
|
| 置 |
|
| HTTP 后端的 TLS 指纹,可选 |
也识别标准的 HTTPS_PROXY / ALL_PROXY。
极速实时比分:scripts/hltv-live
MCP 里的 hltv_get_live_scores 走浏览器后端,准确但代价是等浏览器渲染。只想快速瞄一眼比分时,
用仓库自带的脚本更划算 —— 它直接请求 https://www.hltv.org/scores(这条路径不受 Cloudflare
拦截,被拦的是 /matches/* 那类页面;gzip 后约 40KB),完全不启动浏览器:
python scripts/hltv-live # 列出当前所有进行中的比赛(约 1.5~2.5 秒)
python scripts/hltv-live falcons # 只筛队名含 falcons 的(可多个关键字)
python scripts/hltv-live --json # JSON 输出
python scripts/hltv-live --watch 15 # 守护模式:每 15 秒轮询一次并写缓存
python scripts/hltv-live --cache # 读守护进程缓存,毫秒级(不联网)实测(Android/Termux,同一场比赛):直连脚本 1.6~2.4 秒,守护模式缓存读取约 60 毫秒, 比分与页面同步;相比之下浏览器后端冷启动要几十秒。脚本同样只读公开页面, 请保持合理的轮询间隔(守护模式默认 15 秒)。
诊断与测试
python scripts/browser_check.py # 默认后端:浏览器能否连接、能否取到 HLTV
python scripts/health.py # HTTP 后端:区分 IP 级 / 路径级封锁
python scripts/health.py --json
python scripts/hltv_inspect.py /matches # 页面结构 dump,改版时用来定位新选择器
python scripts/hltv-live --watch 15 # 极速实时比分(守护模式,写缓存)
python tests/test_parsers.py # 离线:解析逻辑
python tests/test_launcher.py # 离线:后端选择、显示环境、Termux 识别、CDP 探测
python tests/smoke.py # 联网冒烟(约 1.5 分钟)
python tests/smoke.py --only ranking player career测试分两层是有意的:离线测试用与线上同构的夹具验证逻辑,不依赖网络,所以当 HLTV 限流或改版时,能立刻分清是逻辑问题还是页面变了 —— 这个区分在本项目的开发过程中 救过好几次场。
合规声明
本项目为非官方工具,与 HLTV.org 无关联。它只读取公开页面,不做任何写操作。
请合理使用:保持默认的低请求频率,不要用于商业再分发或高频轮询。工具返回的数据版权归 HLTV 及其原始权利人所有。
许可
MIT
🌐 Language / 语言
Related MCP server: GRID.gg Esports MCP Server
English
Query HLTV.org Counter-Strike data directly from your AI assistant — matches, results, live scores, world rankings, teams, players, news, and the event calendar.
By default it fetches pages with a real browser: it runs in the background, completely invisible, and never disturbs the page you're currently reading. Supports Windows / macOS / Linux, plus Android Termux.
Why this version? (vs. the older frogg435/hltv-mcp)
This repo is a full upgrade over the older version: the tool count grows from 18 to 27, along with several data-correctness fixes.
Capability | frogg435/hltv-mcp (old) | This repo |
Tool count | 18 | 27 |
Player / match / team photo download | ❌ | ✅ |
Kill matrix / per-map performance | ❌ | ✅ |
Player / squad head-to-head | ❌ | ✅ |
Role tags (IGL / AWPer) + role inference | ❌ | ✅ |
Per-event player stats (Rating / KAST / ADR…) | ❌ | ✅ |
Auto-close browser when idle (saves RAM) | ❌ | ✅ |
Renderer process cap / auto-reconnect | ❌ | ✅ |
Cached well-known player/team IDs | ❌ | ✅ |
Ranking | ❌ (parsed a player ID) | ✅ (fixed) |
Bottom line: this repo is a more complete, more memory-efficient and more accurate upgrade — a safe drop-in replacement for the old version.
What it can answer
Question | Tool called |
What matches are on today? |
|
What's live right now? |
|
What's the current score? |
|
How has Vitality been doing lately? |
|
Who's in the world top 30 right now? |
|
ZywOo's rating and career achievements? |
|
How has ZywOo performed year by year? |
|
What was ropz's rating each year? |
|
Who played well on CT side on Inferno in this match? |
|
What's the prize pool for this Major? Who's attending? |
|
How has FaZe been doing lately? |
|
Who's stronger historically, FaZe or Vitality? |
|
Who's on FaZe's current roster? |
|
What's in the news lately? |
|
What big events are coming up? |
|
Every tool accepts either an ID or a name — just write name="Vitality" and the server resolves it to an ID, so the model never has to run a separate search first.
Just want a quick glance at the current score? The repo ships
python scripts/hltv-live— it bypasses the browser and talks to HLTV directly, returning in 1–2 seconds. See Fast live scores below.
Installation
git clone <repo> && cd hltv-mcp
python3 -m venv .venv
.venv/bin/pip install -e .No Playwright in the dependency list — browser control is handled by a built-in native CDP client, with a single pure-Python websocket-client dependency. There are two reasons for this design: Playwright can't be installed on Termux/Android, and its new_page() always steals focus (see "Not disturbing your browsing" below).
You need one of Chrome / Chromium / Edge installed locally. On Linux, installing Xvfb is also recommended to provide the invisible virtual display. If you can't install a browser (CI, for example), switch to the HTTP backend: pip install -e ".[http]" and set HLTV_BACKEND=http.
curl_cffiis an optional dependency. Only the HTTP backend needs it; the default browser backend does not. It requires compiling curl-impersonate + BoringSSL, which is very hard to get working on platforms like Android — so don't add it back todependencies.
Android / Termux offline install (zero compilation)
The most painful part of installing Python dependencies on Termux is compiling native extensions on-device (lxml, cryptography, pydantic_core…). This repo provides a prebuilt offline bundle that installs with a single command and compiles nothing at all:
tar xzf hltv-mcp-termux-offline.tar.gz
cd hltv-mcp-termux-offline
bash install.shThe bundle already contains all 29 wheels (including the Android ARM64 build of pydantic_core, plus the setuptools build backend that pip install -e . needs), and installation uses --no-index so pip reads only local files and never touches PyPI. See the bundle notes on the Releases page.
The bundle's build script also lives in this repo (termux/): build-bundle.sh regenerates the bundle on any networked Linux/macOS machine, using a reproducible build — identical input produces byte-identical output.
The script also prints a ready-to-paste MCP client config, which sets HLTV_CHALLENGE_WAIT=120 by default:
On some network egresses the Cloudflare challenge on the first HLTV visit can take far longer than the 25-second default (measured at ~120 seconds on a China Unicom connection). Raising it avoids a first query timing out; once the challenge passes and
cf_clearanceis persisted, subsequent startups take the warm path and are fast. On desktop, if the first run works fine, there's no need to change this.
Wiring it into an MCP client
Add this to your client's MCP configuration:
{
"mcpServers": {
"hltv": {
"command": "/absolute/path/hltv-mcp/.venv/bin/python",
"args": ["-m", "hltv_mcp"],
"env": {
"PYTHONPATH": "/absolute/path/hltv-mcp/src"
}
}
}
}After installing with pip install -e ., you can also use the command entry point directly:
{
"mcpServers": {
"hltv": { "command": "/absolute/path/hltv-mcp/.venv/bin/hltv-mcp" }
}
}No environment variables are required. On startup the server warms up in the background: it launches the browser and fetches the schedule, live scores, results and rankings pages once each. In practice Cloudflare issues an extra real challenge on the first visit to certain paths (10–25 seconds), so doing this at startup absorbs that cost up front — your very first query is already warm.
Warmup yields: after the first page it waits 8 seconds before each subsequent page to check whether you're querying, and stops immediately if a request comes in. It never queues slow requests ahead of yours. Afterwards the same browser instance is reused, and it's shut down automatically when the MCP server exits.
A few optional tuning knobs:
{
"env": {
"HLTV_BACKEND": "auto",
"HLTV_BROWSER_VISIBLE": "0"
}
}Tool reference
Tool | Description |
| Search players/teams/events/news, name → ID |
| Schedule (upcoming + live), filterable by team/event, live-only option |
| Live score snapshot: ongoing matches, current map round count, maps won (poll for progress) |
| Results with scores and winner, paginated |
| Single match detail: map scores + per-map, per-team player stats (nickname, player ID, nationality, K-D, ADR, KAST, Rating, Swing) |
| World team rankings (with points) |
| Team profile: ranking, coach, roster |
| Player profile: Rating 3.0, ability ratings, career honours summary |
| Year-by-year career: teams per year, Top 20 placements by year, awards, titles, MVPs |
| Year-by-year rating and detailed stats: Rating, K/D, ADR, maps played, rating vs Top 5/10/20 opponents |
| Per-map, per-side (CT/T) player stats for a single match: Op.K-D, multi-kills, KAST, 1vX, headshots, ADR, Rating |
| Event detail: prize pool, dates, location, VRS weight, attending teams, placements and prize distribution |
| Recent team results: date, opponent, score, win/loss |
| Head-to-head record: per-map detail + aggregated win rate by map |
| News list |
| News article body |
| Event calendar |
| Which backend is in use, whether the browser is available; call this first when troubleshooting "no data" |
Everything is read-only; there are no write operations.
How it works, and known limitations
Three backends for fetching pages
Backend | How | Characteristics |
Browser (default) | Fetches pages with a real browser | Most reliable against Cloudflare; the only one that can do click interactions; requires a local browser |
HTTP |
| Fast, light, no browser needed; but can't get past Cloudflare's path-level rules |
hybrid | Tries HTTP first, falls back to the browser when blocked | Both capabilities; the cost is a half-second probe on every request |
HLTV_BACKEND=auto (default) / browser / http / hybrid controls the choice; see "Backend selection" below.
Cloudflare
HLTV sits behind Cloudflare. Measured results (assuming a clean egress IP):
Method | Result |
Plain | ❌ 403 "Just a moment..." |
| ❌ 403 |
| ❌ 403 |
| ✅ 200, normal page |
Real browser | ✅ 200, including |
The HTTP backend uses curl_cffi with impersonate="safari17_0". The optimal fingerprint may differ on another network; override it with HLTV_IMPERSONATE.
Backend: a real browser by default
Cloudflare accumulates IP reputation, and bans escalate in stages:
Clean IP → one path blocked (e.g. /stats/*) → whole site 403 (even the homepage)Once you're in the second or third stage, changing the client disguise doesn't help — we measured it:
Attempt | Result |
7 different TLS fingerprints (Safari / Chrome 131 / 124 / 120 / Firefox / Edge) | all 403 |
Headless Chromium / headed Chromium (Xvfb) / headed real Chrome | all 403 |
Adding stealth scripts (scrubbing | no effect |
What actually works is a real browser. Measured side by side (same IP, same moment):
Method |
|
|
| ❌ 403 | ❌ 403 |
Real browser + persistent profile | ✅ 200 | ✅ 200 |
The difference isn't headed vs. headless — it's two things: the complete fingerprint of a real browser, and the use of a persistent profile context. An anonymous context gets blocked just the same.
So the default backend is the browser, and it works out of the box — you don't need to start Chrome yourself first:
# Nothing to configure, just run it. (A separate profile is created in ~/.cache/hltv-mcp on first run.)
python scripts/browser_check.pyThe launcher does all of this automatically:
If a browser with a debugging port is already running (or you set
HLTV_BROWSER_CDP), reuse itOtherwise launch one with a separate persistent profile (at
~/.cache/hltv-mcp/chrome-profile)On exit, close only the instance it launched itself — your own browser is never touched
Not disturbing your browsing
This is a hard design requirement, not a "best effort":
Invisible. On Linux the launcher creates its own Xvfb virtual display, so the browser runs headed but has no display device at all; on other desktop systems the window is moved off-screen. You see no window and no pop-ups.
No focus stealing, no touching your tabs. Every tab is created with CDP's
background=trueand closed immediately afterwards. The page you're reading is never navigated away or pushed to the background.
Both were measured. Using document.visibilityState and document.hasFocus() as objective indicators, four real queries were run with the user's page open the whole time:
Before query | Throughout / after query | |
User page URL |
| unchanged |
|
|
|
| unchanged | unchanged |
Tab count | 1 | 1 (no leftovers) |
A control experiment was run too: with the earlier background=false implementation, the same scenario immediately turned the user's page visibilityState to hidden and hasFocus() to false — i.e. it got pushed aside. This is one of the reasons this project doesn't use Playwright (its new_page() always activates the new tab).
python scripts/browser_check.py has this check built in, so you can verify it yourself.
Android / Termux
Termux is an explicitly supported target platform: the service still launches the browser itself and it stays invisible; your phone's browser is untouched, and no adb forwarding is needed.
pkg install tur-repo x11-repo
pkg install chromium xorg-server-xvfb python
pip install hltv-mcpA few easy places to trip up:
Chromium isn't in the official main repo — it lives in TUR (
tur-repo) and depends on the GTK/X11 libraries fromx11-repo(linked even in headless mode). But note:tur-repoandx11-repo— the two repository-enabling packages themselves — are in the main repo, so the official sources alone are enough; no third-party repo is required. Conversely, ifpkg install chromiumsays the package can't be found, first check that those twopkg install tur-repo x11-repocommands succeeded.Chromium's executable is called
chromium-browser, notchromium. This project finds it automatically ($PREFIX/bin/chromium-browser).xorg-server-xvfbis mandatory — it is how "invisible" is implemented: the browser runs headed but with no display device. Without it, you can only fall back to headless mode, and headless gets blocked by Cloudflare.Android-specific flags
--no-sandbox(setuid sandboxing is unavailable on Android) and--disable-gpuare added automatically at launch.Termux puts its temp directory at
$TMPDIR(/data/data/com.termux/files/usr/tmp) rather than/tmp, and the X11 socket lives there too — this project searches all three locations.
playwright cannot be installed here — it throws Unsupported platform: android outright, and its new_page() always steals focus. So this project doesn't use it, and instead ships its own native CDP client (requiring only pure-Python websocket-client).
The separate profile isn't an arbitrary choice: first, it avoids exposing your everyday browsing data on a debugging port; second, when a Chrome instance is already running under the same profile, a new process just stuffs tabs into the old instance and never opens a debugging port at all. It has a welcome side effect too — once the profile persists, cf_clearance survives, so subsequent startups hit noticeably fewer challenges.
Security boundary: your browser is never closed, and cookies are neither read nor exported. If you need an authenticated session, log in yourself in the browser — this project never handles any credentials.
Headless mode gets blocked (measured)
One thing that must be stated clearly: --headless gets blocked by Cloudflare.
Mode | Homepage |
|
|
| ❌ challenge page | ❌ challenge page | ❌ challenge page |
Headed (incl. Xvfb virtual display) | ✅ 200 | ✅ 200 | ✅ 964KB |
So when there's "no display", you must not simply fall back to headless — that amounts to silently failing. This project's approach: on Linux, if no usable display is detected but Xvfb is available, it creates a virtual display itself (e.g. :99) so the browser still runs headed. This path was verified to work in containers too, and the virtual display is torn down on exit along with everything else.
Not using Xvfb is fine as well: as long as a display environment exists (a desktop OS), it just runs in ordinary headed mode.
Backend selection
| Behaviour |
| Browser preferred; falls back to HTTP only when the browser can't start at all |
| Force the browser. Errors out rather than falling back |
| Force HTTP. For environments where a browser can't be installed (CI, bare containers) |
| HTTP preferred; switches to the browser when Cloudflare blocks it, and remembers "which kinds of paths require the browser" |
Note the boundary of auto's fallback: "the page was blocked by Cloudflare" does not count as "can't start", and doesn't trigger a fallback — because the HTTP backend would receive the same challenge page, and falling back would only make the error harder to understand. Only "browser not found / can't reach the debugging port / startup timed out" trigger the fallback, which is announced once on stderr before switching.
hybrid is the "fast path" version of auto rather than a watered-down one — the data it ultimately returns is identical, it just reverses the order: spend half a second on a cheap request first, and only launch the browser if blocked. In practice /stats/* has its own blocking rule while every other path goes through fine over HTTP.
But to be honest: on desktop, hybrid isn't faster than the default browser backend (both measured at around 1 second locally). Its value is on weak devices — on a phone/Termux, rendering 1MB of HTML costs more than an extra network round trip. Desktop users should just use the default auto.
Diagnose before you act
python scripts/browser_check.py # default backend: is the browser usable, can it reach HLTV
python scripts/health.py # HTTP backend: distinguish IP-level from path-level blockingHow to read health.py:
Homepage also 403 → IP-level ban. Change your egress IP, or switch to the default browser backend
Only specific paths 403 → path-level rule (
/stats/*falls in this category); the browser backend is unaffected
You can also change the egress with a proxy (HLTV_PROXY). Residential IPs work best; datacenter IPs are typically blocked just the same.
Rate limiting
Request frequency is the single most important thing to watch when using this MCP. A burst of dense requests gets the current egress IP rate-limited by Cloudflare individually, showing up as one path returning 403 persistently while others work fine, and recovery takes minutes to hours.
The client does the following by default:
Browser backend: 0.5 s interval + 0–0.8 s random jitter (
HLTV_BROWSER_MIN_INTERVAL/HLTV_JITTER). A browser request is "a human paging through a site" — Cloudflare judges it on entirely different grounds than bare HTTP, so throttling yourself to crawler standards just slows you down for nothingHTTP backend: 3 s interval (
HLTV_MIN_INTERVAL). Bare HTTP requests look most like a crawler and are throttled most readilyIn-memory cache: live scores 15 s, schedule 60 s, results 120 s, news 300 s, rankings 1 h, player/team profiles 30 min
On a 403 it does not immediately rebuild the session (that would discard cookies already passed and make things worse); it backs off and retries first, and only swaps the session on the final attempt
If a tool keeps returning 403, raise HLTV_MIN_INTERVAL to 5 or higher, or change your network egress.
Per-map, per-side match data
hltv_get_match_stats returns complete data for every player, on every map, on each side (CT/T), in a given BO1/BO3/BO5:
// hltv_get_match_stats(match_id=2399253, map="Inferno", side="ct")
{
"available_maps": ["2 - 1 Best of 3", "13 - 0 Dust2", "8 - 13 Inferno", "13 - 9 Mirage"],
"results": [{
"map": "Inferno",
"sides": {
"ct": [
{"team": "100 Thieves", "players": [
{"nickname": "rain", "opening_kd": "3 : 0", "multi_kills": "2", "kast": "83.3%",
"clutches_1vx": "0", "kills": "8 (4)", "assists": "5 (0)", "deaths": "8 (0)",
"adr": "78.8", "round_swing": "-2.27%", "rating": "0.90"}
]}
]
}
}]
}Two implementation notes:
Maps must be clicked to switch; sides need not be. In practice the DOM contains all three tables
totalstats/ctstats/tstatssimultaneously, and only the currently selected one lacks thehiddenclass — so all three sides are read in one go, and clicking is only needed for maps."Detailed stats" on the match page points at a different ID. The match page is
/matches/{id}while the stats page is/stats/matches/{another-id}; they aren't interchangeable, so the latter has to be extracted from the former.
About /stats/* and year-by-year ratings
The /stats/* paths (including the stats page where year-by-year ratings live) are blocked by Cloudflare under the HTTP backend. With the browser backend enabled they load normally — this is a prerequisite for hltv_get_player_year_stats.
// hltv_get_player_year_stats(player_id=11816, years=[2019, 2022, 2024, 2025, 2026])
{
"seasons": [
{"year": 2019, "rating_version": "Rating 2.0", "rating": 1.19, "kd_ratio": 1.29,
"adr": 80.4, "maps_played": 200, "kills": 4005},
{"year": 2024, "rating_version": "Rating 3.0", "rating": 1.13, "kd_ratio": 1.18,
"adr": 75.9, "maps_played": 189, "kills": 3035},
{"year": 2025, "rating_version": "Rating 3.0", "rating": 1.18, "kd_ratio": 1.24,
"adr": 78.6, "maps_played": 200, "kills": 3182}
],
"career_total": {"rating_version": "Rating 2.0", "rating": 1.15, "maps_played": 1915}
}Note that HLTV's Rating system has been revised over time (1.0 → 2.0 → 2.1 → 3.0), so rating values are not directly comparable across years; rating_version is returned for each season so you can tell.
A misleading URL
/stats/teams/matches/{a}/{b} looks like "the head-to-head record between a and b", but in practice it returns all of team a's matches — FaZe's page has 2063 maps across 131 distinct opponents, the second ID does no filtering, and the ?contextIds= parameter has no effect either.
So hltv_get_head_to_head was changed to filter locally by opponent name, which is what produces a genuine H2H (FaZe vs Vitality = 81 maps, 37 wins 44 losses, 45.7% win rate). The cost is downloading the whole page (about 5MB / 5 seconds).
Maintaining the parsers
HLTV redesigns its pages, and selectors may stop matching. When a tool returns no data:
python scripts/hltv_inspect.py /matches # dump the page's class-name distribution
python scripts/hltv_inspect.py /team/6667/x --selector .profile-team-statOnce you've located the new class names, update the corresponding parsing function in src/hltv_mcp/parsers.py. All parsers follow the rule "missing field → return None, never raise", so a partial page change won't fail the entire tool call.
Speed
Time is spent almost entirely in two places: browser cold start and fetching the page itself. Here's how each is handled:
Problem | Approach |
Cold start (launching the browser + passing the Cloudflare challenge) all landing on the first query | Background warmup at startup moves those seconds into the gap between "client handshake" and "you typing"; warmup also yields and never blocks your query |
Certain paths get an extra Cloudflare challenge on first visit (10–25 s) | The commonly used paths (schedule / live scores / results / rankings) are all in the warmup list, absorbing that cost at startup |
The browser backend throttled to crawler standards (a hard 3 s wait per request) | The browser backend switched to a 0.5 s interval; the HTTP backend keeps 3 s |
The match stats page had two fixed | Replaced with "wait for the element to appear / for content to change", typically returning in under 1 second |
After passing the challenge, the page reloads via JS, leaving a brief shell with "correct title, incomplete content" | Detected, then waits for the content to stabilise before reading — avoiding a page of partial data being returned without any error |
Measured locally (same machine, same network, timed page by page):
Scenario | Before | After |
Routine pages (schedule / results / rankings / live scores) | 2.6 – 4.2 s | 0.3 – 2.0 s |
Live scores first query (hits the path challenge) | 28 s | 0.8 s (challenge absorbed by startup warmup) |
Detailed match stats ( | 8 s+ (6.5 s of it just fixed waiting) | ~2 s |
First query (cold start) | 2 – 15 s | ≈ 0 (absorbed by startup warmup) |
One thing isn't fixable in code: for paths not in the warmup list (especially
/stats/*), the first visit may still hit a real challenge, measured at 9–25 seconds, after which the same path is consistently around 1 second. So "the first time you look up a player's year-by-year rating" being slow is normal — querying the same player again is fast. To eliminate even that, add the path toHLTV_WARMUP_PAGES.
Configuration
Environment variable | Default | Description |
|
| Backend: |
|
| Warm up the browser in the background at startup so the first query doesn't wait for a cold start. Set |
|
| Pages fetched in sequence during warmup. In practice Cloudflare issues an extra real challenge on the first visit to certain paths ( |
|
| Seconds to wait before warming the next page, to see whether the user is doing anything. Yields immediately if a request arrives |
| empty | Reuse an externally launched browser, e.g. |
|
| Set |
|
| Set |
| automatic | Set |
| auto-detected | Path to the browser executable (Chrome/Chromium/Edge) |
|
| Preferred debugging port when auto-launching; switches automatically if occupied |
|
| Separate profile directory used when auto-launching |
| platform cache dir | Stores the profile, browser logs and port record |
| empty | Egress proxy, e.g. |
|
| Minimum interval between two requests for the HTTP backend (seconds) |
|
| Minimum interval between two requests for the browser backend (seconds) |
|
| Minimum interval for the probing HTTP request in hybrid mode (seconds) |
|
| Upper bound of the random jitter added to intervals (seconds) |
|
| Single-request timeout (seconds) |
|
| Number of retries on failure |
|
| Page navigation retries (browser backend) |
|
| Maximum wait for the Cloudflare challenge to pass (seconds) |
|
| Challenge polling interval (seconds) |
|
| Set |
|
| TLS fingerprint for the HTTP backend; also accepts |
The standard HTTPS_PROXY / ALL_PROXY variables are recognised too.
Fast live scores: scripts/hltv-live
hltv_get_live_scores inside the MCP goes through the browser backend — accurate, but it pays for browser rendering. When you just want a quick glance at the score, the script shipped in the repo is a better deal: it requests https://www.hltv.org/scores directly (this path isn't blocked by Cloudflare — it's the /matches/* style pages that are; roughly 40KB gzipped) without launching a browser at all:
python scripts/hltv-live # list all currently ongoing matches (~1.5–2.5 s)
python scripts/hltv-live falcons # only those whose team name contains "falcons" (multiple keywords allowed)
python scripts/hltv-live --json # JSON output
python scripts/hltv-live --watch 15 # daemon mode: poll every 15 seconds and write a cache
python scripts/hltv-live --cache # read the daemon's cache, millisecond-level (no network)Measured (Android/Termux, same match): the direct script takes 1.6–2.4 s, reading the daemon cache takes about 60 ms, and scores match the page; the browser backend's cold start, by contrast, takes tens of seconds. The script also only reads public pages — please keep polling at a reasonable interval (daemon mode defaults to 15 seconds).
Diagnostics and tests
python scripts/browser_check.py # default backend: can the browser connect, can it reach HLTV
python scripts/health.py # HTTP backend: distinguish IP-level vs path-level blocking
python scripts/health.py --json
python scripts/hltv_inspect.py /matches # page structure dump, for locating new selectors after a redesign
python scripts/hltv-live --watch 15 # fast live scores (daemon mode, writes a cache)
python tests/test_parsers.py # offline: parsing logic
python tests/test_launcher.py # offline: backend selection, display environment, Termux detection, CDP probing
python tests/smoke.py # networked smoke test (~1.5 minutes)
python tests/smoke.py --only ranking player careerThe two-layer split is deliberate: the offline tests verify the logic against fixtures isomorphic to the live pages and don't depend on the network, so when HLTV rate-limits or redesigns, you can immediately tell whether it's a logic problem or the page changed — that distinction has saved the day several times during this project's development.
Compliance
This project is an unofficial tool and is not affiliated with HLTV.org. It only reads public pages and performs no write operations.
Please use it sensibly: keep the default low request rate, and don't use it for commercial redistribution or high-frequency polling. Copyright in the data returned by the tools belongs to HLTV and its original rights holders.
License
MIT
Available Tools
27 toolshltv_backend_statusA
查看当前用哪种方式访问 HLTV(浏览器后端 / HTTP 后端)、浏览器是否可用、以及各页面能否正常取到。排查「查不到数据」类问题时先调这个。
Inputs: check_pages. Returns: result
hltv_get_eventC
获取赛事详情:总奖金池、起止日期、地点、VRS 权重、参赛队伍名单、以及名次与奖金分配(冠军/亚军/各名次拿多少钱)。
Inputs: name, event_id. Returns: result
hltv_get_eventsC
获取赛事日历:正在进行与即将开始的比赛及线下大赛(含赛事 ID、地点、横幅)。
Inputs: name, limit. Returns: result
hltv_get_head_to_headB
获取两支队伍的历史交手记录(H2H)。返回逐地图的对战明细(日期、赛事、地图、比分、胜负)与按地图聚合的胜率,用于赛前分析。
Inputs: limit, team1, team2, team1_id, +1 more. Returns: result
hltv_get_images_batchA
批量获取选手照片 / 战队 logo / 赛事 logo。每类最多 50 个,可混用数字 ID 与名称。默认只返回 URL;download=true 时保存到本地。单条失败不影响其余,错误单独列出。
Inputs: size, teams, events, players, +2 more. Returns: result
hltv_get_kill_matrixA
击杀矩阵:HLTV 单图性能页那张彩色格子表,列出「谁杀了谁、杀了几次」。三个视角:all(全部击杀)、first_kills(首杀)、awp_kills(AWP 击杀)。传 map 只看一张图,不传则把整场各图累加。
Inputs: match_id (required), map, view. Returns: result
hltv_get_live_scoresA
获取正在进行的比赛的实时比分快照:当前地图的回合数、已赢地图数、双方队伍与赛事。想追踪某场比分的变化就间隔调用(内部有 15 秒缓存,防止打爆 HLTV)。可按 match_id 过滤只看一场。
Inputs: limit, match_id. Returns: result
hltv_get_map_performanceB
单图完整性能数据:两队 Kills/Deaths/Assists 对比、击杀矩阵三视角、以及每名选手逐回合的 round swing。给定 mapstatsid 直接拉,不需要 match_id。
Inputs: mapstatsid (required), slug, round_swing. Returns: result
hltv_get_matchC
获取单场比赛的详细信息:双方阵容、地图比分、选手数据。
Inputs: match_id (required), slug. Returns: result
hltv_get_matchesA
获取赛程:即将开始与正在进行中的比赛。可按队伍名或赛事名过滤,也可只看正在直播的比赛。
Inputs: team, event, limit, live_only. Returns: result
hltv_get_match_photosA
一次性下载一场比赛两队全部选手的照片(默认当前官方照,传 year 取当年照片)。做赛事数据页时比逐个调用快得多;返回每人的文件路径与来源。
Inputs: match_id (required), out, year, force. Returns: result
hltv_get_match_statsA
获取单场比赛的逐地图、分阵营(CT/T)的选手详细数据:Op.K-D、多杀、KAST、1vX 残局、爆头数、助攻、死亡、ADR、Rating 等。支持按地图(All/Inferno/Ancient…)与阵营(both/T/CT)筛选。
Inputs: match_id (required), map, side, all_maps. Returns: result
hltv_get_newsB
获取 HLTV 最新新闻列表(标题、分类、时间、链接)。
Inputs: limit. Returns: result
hltv_get_news_articleC
获取一篇 HLTV 新闻的正文内容。
Inputs: news_id (required), slug. Returns: result
hltv_get_playerC
获取选手资料:真名、国籍、年龄、当前战队、Rating 3.0 及各项能力评分、生涯荣誉(Major 冠军数、线下赛冠军数等)。
Inputs: name, player_id. Returns: result
hltv_get_player_careerB
获取选手的逐年生涯数据:历年在哪支战队、历年 HLTV Top 20 年度排名(如 2023 年第 3 名)、历年评委会奖项、历年赛事成绩。用于回答「某选手历年表现如何」这类问题。
Inputs: name, player_id, include_achievements. Returns: result
hltv_get_player_event_statsA
获取选手在【某届赛事】中的个人统计数据(按赛事过滤,区别于按年份)。返回 Rating 2.0、CT/T Rating、KAST、ADR、KPR、DPR、K/D、爆头率、地图数,以及对各级对手的 Rating 与能力评分。需要浏览器后端(约几秒,带缓存)。赛事优先传数字 event_id(如 IEM Cologne 2022 = 6140);也可传 event_name 由服务端解析,但历史赛事名解析可能失败,推荐用 ID。
Inputs: name, event_id, player_id, event_name. Returns: result
hltv_get_player_matchupC
两名选手的「同图对位」数据:两人同时出场的每张地图上各自的 K-D、Rating、ADR、KAST、首杀、多杀、残局,按地图聚合。可指定单张地图(如 Nuke)。
Inputs: player1 (required), player2 (required), map, limit, +3 more. Returns: result
hltv_get_player_photoB
获取选手照片(bodyshot):默认返回 CDN 地址;download=true 时下载到本地。传 year 可回溯那一年的照片(走统计页,通常 800×800,适合做老比赛的数据页)。
Inputs: dest, name, size, year, +4 more. Returns: result
hltv_get_player_year_statsB
获取选手逐年 Rating 与详细数据(Rating 3.0/2.0、K/D、ADR、地图数、对 Top5/10/20 对手的 Rating 等)。这是回答「某选手历年数据怎么样」最直接的接口。
Inputs: name, years, to_year, from_year, +2 more. Returns: result
hltv_get_resultsC
获取最近的比赛结果(已结束),含比分与胜方。可按队伍或赛事过滤。
Inputs: team, event, limit, offset. Returns: result
hltv_get_squad_matchupB
一名选手对上一整支队伍:拆成他与队内每名选手的同图对位,一次拿全。例如「jL 对 MOUZ 全队」,可限定地图与时间范围。
Inputs: team (required), player (required), map, limit, +3 more. Returns: result
hltv_get_teamB
获取战队资料:世界排名、Valve 排名、教练、阵容名单(含选手 ID)。
Inputs: name, team_id. Returns: result
hltv_get_team_logoB
获取战队 logo 的 CDN 地址,可选下载到本地。默认只返回 URL;download=true 时保存文件并返回路径、字节数、sha256 与宽高。
Inputs: name, size, team_id, download. Returns: result
hltv_get_team_matchesB
获取某支战队的近期比赛战绩:日期、对手、比分、胜负。用于回答「某队最近打得怎么样」。
Inputs: name, limit, team_id, only_wins, +1 more. Returns: result
hltv_get_team_rankingC
获取 HLTV 世界战队排名(含各队积分)。这是 CS 圈最常被引用的排名。
Inputs: limit, top_only. Returns: result
hltv_searchA
在 HLTV 上搜索选手、战队、赛事或新闻,返回名称与对应 ID。不确定拼写、或需要把名称换成 ID 时先调这个。
Inputs: query (required), kind, limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 27 tools
Most tools map cleanly to a resource+action (news vs article, matches vs results vs live scores, team matches vs head-to-head), but several clusters overlap: hltv_get_match already returns player data that hltv_get_match_stats re-supplies, and hltv_get_kill_matrix is essentially a subset of hltv_get_map_performance. The image trio (player_photo, team_logo, match_photos) is also largely re-implemented by hltv_get_images_batch, and the three player-stats tools (event_stats, year_stats, career) require careful reading to distinguish.
Nearly every name follows the hltv_<verb>_<resource> snake_case pattern with a consistent 'get_' verb, which makes the set predictable. The only deviations are hltv_search (no get_) and hltv_backend_status (a status probe), both of which are natural exceptions rather than inconsistencies.
27 tools is heavy, though the domain is genuinely broad (players, teams, matches, events, news, images, live data). Some tools are redundant with each other (kill_matrix vs map_performance, images_batch vs the individual photo/logo tools), so trimming a handful would make the set tighter for the same coverage.
Coverage is strong across the lifecycle: search, player/team/event/match profiles, schedules, results, live scores, detailed stats, H2H, matchups, news, and asset fetching. Minor gaps remain — no player Top-20/ranking-list tool and no team map-pool or aggregate team-performance tool — but agents can work around these via existing endpoints.
Maintenance
Related MCP Connectors
Hosted browser for agents: open pages, search the web, extract data, read PDFs and take screenshots.
Web search, browser automation, scraping, crawling and CAPTCHA solving for AI agents.
Web data for agents. Extract web pages, crawl websites, discover URLs, and search the web.
Direct access to 60+ scraping and search tools. Extract structured data from Google (Search, Maps, Trends), Amazon, Airbnb, Social Media, and any web page directly into your AI agent.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to perform undetectable browser automation that bypasses Cloudflare, antibots, and social media blocks. Provides 105 tools for element extraction, network debugging, and real-world web scraping with a 98.7% success rate on protected sites.170 PyPI3,387MIT
- -licenseNot gradedqualityDmaintenanceEnables AI agents to access and analyze professional esports data for League of Legends and Valorant via the GRID.gg API. It provides tools for team lookups, executing GraphQL queries, and retrieving detailed match replay files and event definitions.1-
- AlicenseAqualityCmaintenanceEnables AI agents to crawl, scrape, search, and automate browsers with anti-bot bypass, providing fast web access via 22 tools.2259 npm3MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to search the web, read and extract content from webpages, fetch JSON from REST APIs, and collect links while bypassing anti-bot protections.-