Default port is now 1984 everywhere
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
This commit is contained in:
1 parent
dbe8a8d4e0
commit
bdccace271
9 files changed
+35
-35
No files matched your search
@@ -18,15 +18,15 @@ export SKYG_AUTH__DB_PATH=/tmp/slinuxm-demo/db.sqlite
|
||||
BIN=target/release/slinuxm
|
||||
|
||||
TOKEN=$($BIN token create demo) # printed once, never stored in plaintext
|
||||
$BIN serve & # http://127.0.0.1:9109, loopback only
|
||||
$BIN serve & # http://127.0.0.1:1984, loopback only
|
||||
|
||||
curl -s http://127.0.0.1:9109/healthz # public
|
||||
curl -s -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:9109/api/v1/systemd/units?state=failed'
|
||||
curl -s -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:9109/api/v1/journal?priority=err&lines=20'
|
||||
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:9109/api/v1/docker/ps # 503 if Docker is not running
|
||||
curl -s http://127.0.0.1:1984/healthz # public
|
||||
curl -s -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:1984/api/v1/systemd/units?state=failed'
|
||||
curl -s -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:1984/api/v1/journal?priority=err&lines=20'
|
||||
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:1984/api/v1/docker/ps # 503 if Docker is not running
|
||||
```
|
||||
|
||||
Point an MCP client at `http://127.0.0.1:9109/mcp` with the same bearer header (see [MCP](#mcp)). Stop the server with `kill %1`.
|
||||
Point an MCP client at `http://127.0.0.1:1984/mcp` with the same bearer header (see [MCP](#mcp)). Stop the server with `kill %1`.
|
||||
|
||||
The service listens on loopback by default. To reach it from another machine set `server.bind`, keep auth on, and use [TLS](#tls). For a permanent install as a systemd service, see [Install](#install) and [Tokens](#tokens).
|
||||
|
||||
@@ -80,7 +80,7 @@ Notes:
|
||||
|
||||
## REST
|
||||
|
||||
Base: `http://127.0.0.1:9109`. Errors are `{"error":{"code","message"}}`.
|
||||
Base: `http://127.0.0.1:1984`. Errors are `{"error":{"code","message"}}`.
|
||||
|
||||
| Route | Notes |
|
||||
|---|---|
|
||||
@@ -96,13 +96,13 @@ Base: `http://127.0.0.1:9109`. Errors are `{"error":{"code","message"}}`.
|
||||
|
||||
```sh
|
||||
TOKEN=slinuxm_...
|
||||
curl -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:9109/api/v1/systemd/units?state=failed'
|
||||
curl -N -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:9109/api/v1/journal/follow?priority=err'
|
||||
curl -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:1984/api/v1/systemd/units?state=failed'
|
||||
curl -N -H "Authorization: Bearer $TOKEN" 'http://127.0.0.1:1984/api/v1/journal/follow?priority=err'
|
||||
```
|
||||
|
||||
## MCP
|
||||
|
||||
Endpoint: `http://127.0.0.1:9109/mcp` (Streamable HTTP). Eight tools (`list_systemd_units`, `get_systemd_unit`, `list_systemd_timers`, `get_journal_logs`, `tail_journal`, `list_containers`, `get_container`, `get_container_logs`), two prompts (`diagnose_unit`, `container_health_report`) two resources (`systemd://units/failed`, `docker://containers`) and two resource templates (`systemd://unit/{name}`, `docker://container/{name}`, same JSON as `get_systemd_unit` and `get_container`; percent-encode unusual characters in the name). Log content is untrusted data and is labelled as such in tool results.
|
||||
Endpoint: `http://127.0.0.1:1984/mcp` (Streamable HTTP). Eight tools (`list_systemd_units`, `get_systemd_unit`, `list_systemd_timers`, `get_journal_logs`, `tail_journal`, `list_containers`, `get_container`, `get_container_logs`), two prompts (`diagnose_unit`, `container_health_report`) two resources (`systemd://units/failed`, `docker://containers`) and two resource templates (`systemd://unit/{name}`, `docker://container/{name}`, same JSON as `get_systemd_unit` and `get_container`; percent-encode unusual characters in the name). Log content is untrusted data and is labelled as such in tool results.
|
||||
|
||||
Generic client config (header-capable clients):
|
||||
|
||||
@@ -110,21 +110,21 @@ Generic client config (header-capable clients):
|
||||
{
|
||||
"mcpServers": {
|
||||
"linux-tracker": {
|
||||
"url": "http://127.0.0.1:9109/mcp",
|
||||
"url": "http://127.0.0.1:1984/mcp",
|
||||
"headers": { "Authorization": "Bearer slinuxm_..." }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Claude Code: `claude mcp add --transport http linux-tracker http://127.0.0.1:9109/mcp --header "Authorization: Bearer $TOKEN"`.
|
||||
Claude Code: `claude mcp add --transport http linux-tracker http://127.0.0.1:1984/mcp --header "Authorization: Bearer $TOKEN"`.
|
||||
|
||||
Inspector: `npx @modelcontextprotocol/inspector`, transport Streamable HTTP, add the bearer header.
|
||||
|
||||
Raw handshake with curl:
|
||||
|
||||
```sh
|
||||
curl -si -X POST http://127.0.0.1:9109/mcp \
|
||||
curl -si -X POST http://127.0.0.1:1984/mcp \
|
||||
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
|
||||
-H 'Accept: application/json, text/event-stream' \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
|
||||
@@ -132,7 +132,7 @@ curl -si -X POST http://127.0.0.1:9109/mcp \
|
||||
|
||||
### Origin and Host checks
|
||||
|
||||
`/mcp` validates `Origin` and `Host` to defend against DNS rebinding from browsers. Loopback names, `server.bind` and the configured port are accepted by default. Requests without an `Origin` header (non-browser clients) pass this check, so the bearer token remains the real gate. If you bind to `0.0.0.0` or serve behind a name, add the names clients use to `server.allowed_hosts` (for example `["monitor.lan:9109"]`) and any browser origins to `server.allowed_origins`. With `auth.enabled = false` (loopback only), REST requests are checked against a Host allowlist (loopback names, `server.bind` and `server.allowed_hosts`) and get `403` otherwise, to blunt DNS rebinding. There is no Origin check on REST and no token in that mode, so keep auth enabled on any multi-user host. If the host is reachable beyond a trusted network, enable native TLS (see the TLS section) or terminate TLS in a reverse proxy.
|
||||
`/mcp` validates `Origin` and `Host` to defend against DNS rebinding from browsers. Loopback names, `server.bind` and the configured port are accepted by default. Requests without an `Origin` header (non-browser clients) pass this check, so the bearer token remains the real gate. If you bind to `0.0.0.0` or serve behind a name, add the names clients use to `server.allowed_hosts` (for example `["monitor.lan:1984"]`) and any browser origins to `server.allowed_origins`. With `auth.enabled = false` (loopback only), REST requests are checked against a Host allowlist (loopback names, `server.bind` and `server.allowed_hosts`) and get `403` otherwise, to blunt DNS rebinding. There is no Origin check on REST and no token in that mode, so keep auth enabled on any multi-user host. If the host is reachable beyond a trusted network, enable native TLS (see the TLS section) or terminate TLS in a reverse proxy.
|
||||
|
||||
## TLS
|
||||
|
||||
@@ -155,7 +155,7 @@ Self-signed example:
|
||||
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 365 \
|
||||
-keyout key.pem -out cert.pem -subj '/CN=monitor.lan' \
|
||||
-addext 'subjectAltName=DNS:monitor.lan,DNS:localhost,IP:127.0.0.1'
|
||||
curl --cacert cert.pem -H "Authorization: Bearer $TOKEN" https://localhost:9109/api/v1/systemd/units
|
||||
curl --cacert cert.pem -H "Authorization: Bearer $TOKEN" https://localhost:1984/api/v1/systemd/units
|
||||
```
|
||||
|
||||
Rotation: replace the files and send `SIGHUP` (`kill -HUP $(pidof slinuxm)`, or `systemctl kill -s HUP <unit>`). New connections get the new certificate; established ones are not dropped. The certificate and key are read as two separate files, so rotation tooling must send SIGHUP only after BOTH are in place; if the pair is unreadable or mismatched (for example the cert was replaced but the key not yet), the old certificate stays, an error is logged, and you send SIGHUP again once the files are consistent. Any intermediate certificates must be in the `cert_file` chain. Both the TLS and the plain listener are HTTP/1.1 only, share one accept loop, cap concurrent connections at 1024 and close connections that send no request header within 30 seconds. SIGHUP is harmless when TLS is disabled (it is logged and ignored). For ACME, point `cert_file` and `key_file` at the client's output (for example certbot's `live/<name>/fullchain.pem` and `privkey.pem`, or the NixOS `security.acme` directory) and send SIGHUP from the renewal hook. For sops-nix or systemd `LoadCredential`, point at the decrypted or credential path (`/run/credentials/<unit>/...`) so the service user needs no access to the original key file.
|
||||
|
||||
Reference in new issue
Block a user