Skip to main content
Glama
Headscale MCP connector

Headscale MCP connector

by si-essence

headscale-mcp (Headscale MCP connector)

MCP connector for a self-hosted Headscale control server. It speaks the Headscale HTTP API over stdio and over stateless Streamable HTTP on localhost.

Headscale is BSD-3-Clause software. This connector is an independent HTTP client of that API. It is not affiliated with the Headscale project or with Tailscale. Bring your own API key from the server you run.

This connector covers all 29 operations in headscale.openapi.json (Headscale v0.29.6) plus one virtual policy diff. Operations are grouped into 8 toolsets. Enable a subset with HEADSCALE_TOOLSETS so the model only sees the tools you need.

Self-hosted Headscale only. There is no default base URL. HEADSCALE_URL is required and must be your server origin, for example http://127.0.0.1:8080. A trailing /api/v1 is stripped. Calls go to {HEADSCALE_URL}/api/v1. Hosts on tailscale.com and tailscale.io are refused. This connector does not speak the Tailscale SaaS API.

Setup

npm install
npm run ci
npm start
npm run start:http

npm start speaks stdio. npm run start:http serves Streamable HTTP at http://127.0.0.1:3000/mcp and GET /health. HTTP mode has no authentication. Keep it on localhost.

Create an API key with headscale apikeys create. The connector sends it as Authorization: Bearer and never prints it.

{
  "mcpServers": {
    "headscale": {
      "command": "node",
      "args": ["/workspace/connectors/headscale/dist/index.js"],
      "env": {
        "HEADSCALE_URL": "http://127.0.0.1:8080",
        "HEADSCALE_API_KEY": "...",
        "HEADSCALE_ALLOW_WRITES": "false",
        "HEADSCALE_TOOLSETS": "nodes,users,policy,meta",
        "HEADSCALE_CONTACT": "you@example.com"
      }
    }
  }
}

Docker (HTTP, no authentication, localhost only):

docker build -t headscale-mcp .
docker run -p 3000:3000 \
  -e HEADSCALE_URL=http://host.docker.internal:8080 \
  -e HEADSCALE_API_KEY=... \
  headscale-mcp

Do not put the API key in the image.

Regenerate the operations registry after a Swagger bump:

npm run gen:operations

src/operations.ts is generated. Do not edit it by hand.

Related MCP server: tailscale-mcp

Config

Variable

Meaning

HEADSCALE_URL

Required. Self-hosted Headscale origin. /api/v1 is stripped if present. Tailscale hosts are refused.

HEADSCALE_API_KEY

API key. Sent as Authorization: Bearer. Always redacted in output.

HEADSCALE_ALLOW_WRITES

Must be the literal true before a confirmed write is sent.

HEADSCALE_TOOLSETS

Comma list of toolsets, or all. Default nodes,users,policy,meta.

HEADSCALE_PER_MINUTE

Local request budget. Default 30.

HEADSCALE_TIMEOUT_MS

Upstream timeout. Default 20000.

HEADSCALE_CACHE_TTL_SEC

GET cache TTL. Default 60. Writes clear the cache.

HEADSCALE_CONTACT

Contact token in the User-Agent. Must not be the API key.

MCP_TRANSPORT

stdio or http. --http overrides.

PORT

HTTP port. Default 3000.

Safety

Reads run without confirm. check_policy is a read. Headscale validates the policy in a sandbox and does not save it. diff only GETs the current policy.

Every other non-GET is a write. A write needs confirm: true (a boolean, not the string "true") and HEADSCALE_ALLOW_WRITES=true. Otherwise the tool returns a dry-run preview of the method, path, query, and redacted body, and it sends no write. set_policy is the exception on the read side of a preview. Its preview GETs the current policy so the preview can include a line diff. It still does not PUT until both gates pass. A confirmed set_policy with an empty policy string is refused before any request.

Preview and tool descriptions warn on node delete and expire, user delete, pre-auth key create, delete, and expire, API key create, delete, and expire, node tags, approved routes, policy set (a bad policy can lock all nodes out), node register, auth approve, and the debug node creator.

Creating a pre-auth key or an API key returns the secret once, with a note that it is shown only once. List and get responses, and every preview, keep the id or prefix and mask the secret. The caller's own HEADSCALE_API_KEY is redacted everywhere, including inside that one-time response.

Node ids and user ids stay strings and must be numeric. The spec has no pagination parameters.

Errors use a stable prefix. [unauthorized] is 401. [forbidden] is 403. [not-found] is 404. [invalid] is 400 or 422. [rate-limit] is 429 and includes Retry-After. Server errors, network errors, and timeouts have their own codes. Stack traces and filesystem paths are stripped. Responses larger than 1 MB are rejected.

Tools

Default HEADSCALE_TOOLSETS publishes 4 tools. HEADSCALE_TOOLSETS=all publishes 8 tools (30 actions). Each tool takes action plus params, query, body, and confirm when the tool has writes.

Toolset

Tool

Actions

Default

nodes

headscale_nodes

9

yes

users

headscale_users

4

yes

policy

headscale_policy

4

yes

meta

headscale_meta

1

yes

preauth_keys

headscale_preauth_keys

4

no

api_keys

headscale_api_keys

4

no

auth

headscale_auth

3

no

debug

headscale_debug

1

no

debug is only enabled by all. debug_create_node inserts a node without a real client. It is for tests. The tool description says so.

Policy actions are get_policy, check_policy, diff, and set_policy. diff takes a proposed HuJSON or JSON policy string and returns added and removed line counts plus a compact line diff.

Example. List users, preview a create, then confirm it:

{ "action": "list_users" }
{ "action": "create_user", "body": { "name": "lab" } }
{ "action": "create_user", "body": { "name": "lab" }, "confirm": true }

Live check

npm run live-check talks to a real Headscale when HEADSCALE_URL and HEADSCALE_API_KEY are set. It creates throwaway users, keys, and a debug node, checks previews first, then deletes them. It reads policy, checks and diffs a permissive policy, sets that policy, and restores the previous policy. If the previous policy was empty, it writes the same permissive default back. If those variables are unset, it prints a skip message and exits 0. It prints pass and fail lines only.

LIVE-CHECK.md says what the script covers. This session did not run it against a server.

What this is not

This is not a Tailscale.com or Tailscale SaaS client. Those hosts are rejected.

This is not a WireGuard or Tailscale node. It does not join a tailnet, ship DERP, or install tailscaled.

This is not a full replacement for the headscale CLI install path. Server bootstrap, config files, and database migrations stay on the host.

debug_create_node is not a supported way to enroll production devices. Use register or a pre-auth key for that, and treat the debug tool as test-only.

Compared with a small community server that exposes about 17 tools and no ACL actions, this connector covers the v0.29.6 Swagger, gates writes, and adds policy get, check, diff, and set.

Attribution

Headscale is BSD-3-Clause. This connector does not copy Headscale source. It calls the HTTP API described by the Swagger file in this repo.

License

MIT, see LICENSE. This is an independent, unofficial connector and is not endorsed by the Headscale project or its owners.

headscale.openapi.json is generated from juanfont/headscale (BSD-3-Clause, Copyright (c) 2020, Juan Font).

Available Tools

4 tools
headscale_metaA
Read-only

headscale_meta calls the meta toolset on a self-hosted Headscale server (1 actions). Authorization is Bearer. Actions: health: GET /api/v1/health. Report database connectivity.

Inputs: action (required), body, query, params.

headscale_nodesA
DestructiveIdempotent

headscale_nodes calls the nodes toolset on a self-hosted Headscale server (9 actions). Authorization is Bearer. Writes need confirm set to the boolean true and HEADSCALE_ALLOW_WRITES=true. Omit confirm for a dry-run preview that does not send the write. Warnings: This rewrites node IP assignments and can disrupt existing nodes. This deletes a node and removes it from the tailnet. This expires a node and disconnects it. This registers a node and can admit a device onto the tailnet. This approves subnet routes and can expose those networks to the tailnet. This changes node tags and can change which networks the node can reach. Actions: backfill_node_ips: POST /api/v1/node/backfillips. Backfill node IP addresses. delete_node: DELETE /api/v1/node/{nodeId}. Delete a node. expire_node: POST /api/v1/node/{nodeId}/expire. Expire a node. get_node: GET /api/v1/node/{nodeId}. Get one node. Node key material is redacted. list_nodes: GET /api/v1/node. List nodes. Node key material is redacted. register_node: POST /api/v1/node/register. Register a node with a registration key. rename_node: POST /api/v1/node/{nodeId}/rename/{newName}. Rename a node. set_approved_routes: POST /api/v1/node/{nodeId}/approve_routes. Approve subnet routes for a node. set_tags: POST /api/v1/node/{nodeId}/tags. Set tags on a node.

Inputs: action (required), body, query, params, +1 more.

headscale_policyA
DestructiveIdempotent

headscale_policy calls the policy toolset on a self-hosted Headscale server (4 actions). Authorization is Bearer. Writes need confirm set to the boolean true and HEADSCALE_ALLOW_WRITES=true. Omit confirm for a dry-run preview that does not send the write. Warnings: A bad policy can lock all nodes out of the tailnet. Actions: check_policy: POST /api/v1/policy/check. Validate a policy. Headscale does not save it. diff: GET /api/v1/policy. Compare a proposed policy with the saved policy. Sends only the policy read. get_policy: GET /api/v1/policy. Get the current policy. set_policy: PUT /api/v1/policy. Replace the tailnet policy.

Inputs: action (required), body, query, params, +1 more.

headscale_usersA
DestructiveIdempotent

headscale_users calls the users toolset on a self-hosted Headscale server (4 actions). Authorization is Bearer. Writes need confirm set to the boolean true and HEADSCALE_ALLOW_WRITES=true. Omit confirm for a dry-run preview that does not send the write. Warnings: This deletes a user and the nodes and keys that belong to that user. Actions: create_user: POST /api/v1/user. Create a user. delete_user: DELETE /api/v1/user/{id}. Delete a user. list_users: GET /api/v1/user. List users. rename_user: POST /api/v1/user/{oldId}/rename/{newName}. Rename a user.

Inputs: action (required), body, query, params, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 4 tools

    Disambiguation5/5

    The four tools map to clearly distinct domains: server health (meta), tailnet policy, nodes, and users. There is no overlap in resource or action scope, so an agent can select the correct toolset unambiguously.

    Naming Consistency5/5

    All tools follow the same headscale_<resource> pattern with singular, predictable nouns (meta, policy, nodes, users). The convention is uniform across the entire surface.

    Tool Count5/5

    Four resource-grouped tools cleanly encapsulate 18 underlying actions without bloating the top-level surface. Each tool earns its place, and the grouping mirrors the Headscale API structure.

    Completeness3/5

    Core areas (health, policy, nodes, users) are covered, but pre-auth key management is missing even though register_node requires a registration key, creating a workflow dead end. API key management is also absent, so the surface is not fully lifecycle-complete for Headscale administration.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables administrators to manage Keycloak realms, users, roles, clients, groups, and more through its Admin REST API, with safe-by-default configuration and destructive operation confirmation.
      56
      77 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an MCP client to inspect and administer a Tailscale node through the local tailscale CLI and the wider tailnet through the control-plane REST API, exposing 186 read, write, and destructive tools plus resources, prompts, and completions. Tier and preset dials keep dangerous operations unlisted until explicitly enabled, and both surfaces degrade gracefully when the CLI or a credential is absent.
      20
      Apache 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Enables managing a self-hosted media library through its HTTP API, with scoped toolsets, confirm-gated writes, dry-run previews, and read caching. Supports libraries, items, collections, playlists, podcasts, sessions, stats, tags, genres, and administrative operations.
      13
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables interaction with self-hosted Miniflux instances through the HTTP API, covering feeds, categories, entries, enclosures, icons, OPML, users, and API keys. Write operations are confirm-gated with dry-run previews and secret redaction.
      7
      MIT