htb-mcp
Integrates with the Hack The Box labs API (api/v4 and api/v5) to let an agent inspect machines and challenges, spawn/stop/reset/extend machines, view active-machine status with IP and expiry, submit machine and challenge flags, manage VPN servers and download OpenVPN profiles, and run auth/status diagnostics.
Downloads UDP/TCP OpenVPN profiles for HTB VPN servers, resolves remote endpoints and reports latency, and can start or stop a local OpenVPN process (optionally via sudo) to establish the tunnel, while reporting HTB-side and local tunnel status.
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., "@htb-mcp spawn the Lame machine and give me its IP address"
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.
htb-mcp
An MCP server for Hack The Box that lets an AI agent inspect machines, spawn and reset targets, resolve/download/connect the VPN, submit flags, and browse challenges.
This project is unofficial and is not affiliated with Hack The Box. Use it only against machines you are allowed to access. Spawning, resetting, and switching VPN servers are real account actions and can terminate a running target.
Features
Machine discovery and details
Spawn, stop, reset, and extend machines
Active-machine status with IP and expiry
VPN server listing, least-busy selection, server switching, and config download
VPN hostname resolution and optional OpenVPN connect/disconnect
Machine and challenge flag submission
Auth/status diagnostics with retry and rate-limit handling
The server talks to the same API used by app.hackthebox.com:
https://labs.hackthebox.com/api/v4 and /api/v5. The old
app.hackthebox.com/api/v4 path now serves the web app rather than JSON.
Related MCP server: htb-mcp
Requirements
Node.js 22+
A Hack The Box App Token
Optional:
openvpnand passwordlesssudoif you want the server to establish the tunnel for you
Setup
git clone https://github.com/Jerit3787/htb-mcp.git
cd htb-mcp
npm ci
npm run buildOr let npm build it directly from GitHub:
npx --yes github:Jerit3787/htb-mcpCreate a token in HTB under Settings → App Tokens, then run:
HTB_TOKEN="your-token" node dist/src/index.jsThe process speaks MCP over stdio. Logs go to stderr so they never corrupt the protocol stream.
OpenCode
Add this to opencode.jsonc (OpenCode V2 uses mcp.servers):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"htb": {
"type": "local",
"command": ["node", "/absolute/path/to/htb-mcp/dist/src/index.js"],
"environment": {
"HTB_TOKEN": "{env:HTB_TOKEN}"
}
}
}
}
}Then export HTB_TOKEN in the environment that starts OpenCode.
Claude Desktop / other clients
{
"mcpServers": {
"htb": {
"command": "node",
"args": ["/absolute/path/to/htb-mcp/dist/src/index.js"],
"env": {
"HTB_TOKEN": "your-token"
}
}
}
}Tools
Tool | What it does |
| Account, active machine, VPN assignments, and API health |
| Search/filter the machine catalogue |
| Machine details by ID or name |
| Spawn a machine and wait for its IP |
| Terminate the active machine |
| Reset the active machine |
| Extend the active machine's lifetime |
| List VPN servers and current assignments |
| Switch VPN server (refuses while a machine is active unless forced) |
| Pick the least-busy server, download config, resolve the endpoint |
| Download a UDP/TCP OpenVPN profile |
| HTB-side and local OpenVPN status |
| Start OpenVPN with a downloaded profile |
| Stop the OpenVPN process started by this server |
| Submit a machine or challenge flag |
| Search/filter challenges |
| Challenge details by ID or slug |
See docs/tools.md for inputs, side effects, and error codes.
Configuration
Environment variable | Default | Description |
| — | App Token (required unless a session cookie is supplied) |
| — | Optional browser cookie for endpoints that reject token auth; supply the whole |
|
| API host; useful for mocks/proxies |
|
| Per-request timeout |
|
| Retries for GET/429 responses |
|
| Downloaded profiles, PID files, and logs |
|
| OpenVPN executable |
|
| Prefix OpenVPN with |
Profiles contain private keys and are written with mode 0600. Do not commit
them.
If App Token auth returns AUTH_FAILED, copy the full Cookie request header
from a logged-in app.hackthebox.com request into HTB_SESSION_COOKIE. The
token and cookie can also be used together.
VPN notes
HTB lets one VPN session be assigned per product. Switching servers can terminate an active machine;
htb_vpn_switchblocks this unlessforceis true.htb_vpn_resolvedownloads the profile, resolves theremotehostname, and reports latency. It does not connect unlessconnect: trueis passed.Auto-connect uses
sudo -n, so it fails cleanly instead of prompting for a password. Configure a narrowly scoped sudoers rule or start OpenVPN yourself.Only profiles inside the configured VPN directory can be passed to
htb_vpn_connect.
Development
npm ci
npm run typecheck
npm testTests use a local mock HTB API and do not touch your account.
License
MIT
Available Tools
17 toolshtb_extend_machineExtend the active machineA
Extend the active machine's lifetime by 24 hours. Returns HTB's new expiration date.
Inputs: target.
htb_get_challengeGet challenge detailsARead-only
Get challenge details by ID or slug, including category, difficulty, description, docker status, and solve state.
Inputs: target (required).
htb_get_machineGet machine detailsARead-only
Get a machine's profile by name or ID, including OS, difficulty, points, ownership, maker, and active play info.
Inputs: target (required), include_raw.
htb_launch_machineSpawn a machineADestructive
Spawn an active or retired machine and wait for its IP. If another machine is active, set replace=true to terminate it first. HTB limits machine actions to roughly one per minute.
Inputs: target (required), replace, wait_seconds.
htb_list_challengesList challengesCRead-only
Search and filter HTB challenges by state, difficulty, category, name, and completion.
Inputs: page, state, keyword, category, +3 more.
htb_list_machinesList Hack The Box machinesBRead-only
Search and filter machines by state, difficulty, OS, name, free/VIP, and completion. Returns compact machine summaries with pagination metadata.
Inputs: os, free, page, todo, +7 more.
htb_reset_machineReset the active machineADestructive
Request a reset of the active machine. HTB applies a cooldown between machine actions; the reset can take a minute.
Inputs: target.
htb_statusHTB account and lab statusARead-only
Check authentication, account summary, active machine (IP/expiry), and current VPN assignments. Start here when something fails.
Inputs: no named parameters.
htb_stop_machineTerminate the active machineADestructive
Terminate the currently active machine. Optionally verify a target first. This ends the machine session immediately.
Inputs: target.
htb_submit_flagSubmit a flagA
Submit a machine or challenge flag. For machines, target defaults to the active machine. Returns HTB's acceptance message, points, and ownership state.
Inputs: flag (required), kind (required), target.
htb_vpn_connectConnect OpenVPNA
Start OpenVPN using a profile in the configured VPN directory. If config_path is omitted, the assigned profile is downloaded first. Uses sudo -n when not root; it never prompts for a password.
Inputs: force, product, protocol, server_id, +1 more.
htb_vpn_disconnectDisconnect OpenVPNA
Stop the OpenVPN process started by this server. With no PID file, stops all HTB OpenVPN processes managed by this server.
Inputs: pid_file.
htb_vpn_downloadDownload a VPN profileA
Download the OpenVPN profile for the assigned server (or server_id) without auto-selecting a new server. Returns only the local path and endpoint metadata, never the private key.
Inputs: force, product, protocol, server_id.
htb_vpn_resolveResolve and download the VPNADestructive
Pick the least-busy server (or use server_id), switch if needed, download the OpenVPN profile, resolve its remote hostname, and optionally connect. Blocks switching while a machine is active unless force=true. Does not connect unless connect=true.
Inputs: force, probe, connect, product, +3 more.
htb_vpn_serversList VPN serversBRead-only
List available VPN servers, client counts, full status, and the server currently assigned to each HTB product.
Inputs: product.
htb_vpn_statusVPN statusARead-only
Show HTB-side VPN connections plus local OpenVPN processes, profiles, and PID state.
Inputs: no named parameters.
htb_vpn_switchSwitch VPN serverADestructive
Assign your account to another VPN server. HTB may terminate an active machine when the server changes, so this tool refuses unless force=true. Prefer htb_vpn_resolve for automatic least-busy selection.
Inputs: server_id (required), force, product.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Machine and challenge tools are cleanly separated by resource+action (list/get/launch/stop/reset/extend), so those are easy to choose between. The VPN cluster has layered overlap: htb_vpn_resolve internally performs switch+download+connect, which can be confused with htb_vpn_switch, htb_vpn_download, and htb_vpn_connect, though descriptions explicitly disambiguate the preferred tool.
Names follow a predictable htb_verb_noun pattern with a consistent htb_vpn_ namespace for the VPN subgroup. The only deviation is htb_status, which omits a verb, but it remains readable and snake_case throughout.
Seventeen tools is slightly on the heavy side but justified by covering three distinct areas (machines, VPN lifecycle, challenges/flags). Each tool maps to a real operation rather than redundant wrappers.
Machine lifecycle (list/get/launch/stop/reset/extend), VPN setup/teardown, and flag submission are fully covered. Challenge support is thinner (only list/get, no docker start/spawn or dedicated challenge workflow), a minor gap an agent can work around.
Maintenance
Related MCP Connectors
Read-only HopBase AI gateway tools: models, limits, docs search, balance and usage for your API key.
Agent utility API: 28+ free endpoints (hash, QR, DNS, scrape, JWT...) run by an autonomous AI agent.
Discover, inspect and run 63,000+ agent tools from one balance. Pay per call, no subscriptions.
Verified, pay-per-use API tools for AI agents through one authenticated connection.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables interaction with Hack The Box App services including machines, challenges, sherlocks, and more through the HTB API v4.601MIT
- AlicenseNot gradedqualityDmaintenanceEnables assistants to interact with Hack The Box by wrapping HTB API operations as MCP tools for querying and operating HTB resources.1GPL 3.0
- AlicenseAqualityCmaintenanceEnables AI agents to interact with the FlagForge REST API, allowing them to search solved CTF challenges, work on live event challenges, record evidence, submit flag candidates, and write markdown writeups.19ISC
- AlicenseAqualityBmaintenanceEnables AI assistants and agents to search bug bounty programs, retrieve policies and scopes, and check targets against active scope across HackerOne, YesWeHack, and Intigriti using personal API credentials.5MIT