Merge feat/mcp-server (9708154) into feat/mcp-auth
The base branch moved twelve commits while this work was in flight --
including the per-session live stream and its own contract bump -- so this
integrates rather than leaving a PR nobody can merge. Six files
conflicted; the interesting resolutions are the two that were not
textual.
**The contract is mcp-v3.1, not v2.1.** This branch bumped v2 -> v2.1 for
an additive change; `feat/mcp-server` bumped v2 -> v3 for the live stream,
also additive. Both point releases, both correct, and they cannot both be
the same document. So v3 stands as written and the HTTP transport is the
point release on top of it, by the same rule each of us applied
independently: v2 is still the only major bump, because it is still the
only one that removed anything.
**The counts are no longer literals.** This branch asserted `21 tools` and
`5 resources` in `checks/vm-mcp-http.nix` and `5` in `test_mcp_http.py`;
the stream added two tools and one fixed resource, so the surface is 23
and 6. Rather than re-hardcode numbers that will go stale again, the
check now counts against `--list-tools` and `--list-resources` -- the
server's own table -- and the unit test against `resources.FIXED`. That
is the lesson 9708154 ("count the unnarrowed resources against the
listing, not a literal") had already learned on the other side of this
merge, arrived at twice. A stale number here would have failed in a way
indistinguishable from the HTTP transport dropping tools, which is the
one thing those subtests exist to catch.
The rest were additive on both sides and both halves are kept: the TODO
table, the checks wiring, the README check rows, the architecture diagram
(their 23/10 counts with this branch's two-transport annotation).
`nix/module.nix` needed reconstructing -- git interleaved the bodies of
`hhstream-live` and `hhstream-mcp` because both units land between the
same surrounding lines -- so the live unit is taken verbatim and the MCP
unit placed after it, with this branch's options, tmpfiles entry,
firewall rule, two assertions and two warnings re-applied on top.
One thing deliberately NOT touched: the v3 change table cites `§6` for the
idle-clock exception, but the rule it means is `§8`. That is the other
branch's prose and its author's call, not something to quietly rewrite in
a merge.
Verified after resolution: 394 unit tests pass, and the module evaluates
with both units, the right ExecStart, one firewall port and both
warnings.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KchcvnbfhhZhUHy83YL3Ya
This commit is contained in:
commit
f83717ba71
37 files changed
+4241
-101
No files matched your search
@@ -35,6 +35,52 @@ hhstream-client --socket /run/hypr-stream/stream.sock --count 1 --out frame.png
|
||||
The socket is a plain file descriptor: the server serves every client that
|
||||
connects, and keeps running when one disconnects.
|
||||
|
||||
## Watching a session: one port, a phrase per session
|
||||
|
||||
A session can publish its own screen on a web page, so a person can watch what
|
||||
an agent is doing from a phone. One port for the whole machine, and a path that
|
||||
is four words and a short tail:
|
||||
|
||||
```bash
|
||||
hhstream session stream enable chromium-k3f9d2
|
||||
# http://127.0.0.1:9988/amber-otter-lantern-harbor-7k2qp/
|
||||
```
|
||||
|
||||
That URL is the whole interface — a browser `<img>` is the entire client, over
|
||||
MJPEG — and the phrase in it is its **only** protection. No TLS, no second
|
||||
factor: anyone who can reach the port and guess four words can watch. It is
|
||||
never written to the audit log, and `stream list` does not print it.
|
||||
|
||||
Four things worth knowing before switching one on:
|
||||
|
||||
- **It is per session and off by default.** A session does not stream because
|
||||
it exists; it streams because somebody enabled it. What is published is that
|
||||
session's own container output, never the main one — the main output carries
|
||||
every other session, and putting it behind one session's phrase is the
|
||||
mistake this refuses to make.
|
||||
- **The phrase survives a restart.** It lives in the session's record, so
|
||||
somebody you read it out to keeps the URL you gave them. `disable` then
|
||||
`enable` rotates it.
|
||||
- **Capture runs only while somebody is connected.** An enabled stream nobody
|
||||
is watching costs no `grim` and no CPU.
|
||||
- **Watching counts as activity.** This is the one exception to "`touch` is the
|
||||
only mark of activity": about once a minute the broker notices a connected
|
||||
viewer and resets that session's idle clock, so a long job you are watching
|
||||
on a phone is not reaped at three hours. An enabled stream with nobody
|
||||
watching keeps nothing alive.
|
||||
|
||||
```nix
|
||||
services.hyprland-headless-stream.sessions.stream = {
|
||||
enable = true; # runs hhstream-live; turns no stream on
|
||||
# bind = "0.0.0.0"; # and openFirewall, to reach it from another device
|
||||
# openFirewall = true;
|
||||
};
|
||||
```
|
||||
|
||||
Loopback by default, where the path to a phone is `ssh -L 9988:127.0.0.1:9988`.
|
||||
`hhstream session start <app> --stream` starts an application and prints its
|
||||
URL in one go, which is the usual way an agent sets one up.
|
||||
|
||||
## Driving it from an agent: the MCP server
|
||||
|
||||
`hhstream-mcp` is the `hhstream` CLI behind a [Model Context
|
||||
@@ -45,14 +91,16 @@ application without writing command lines. The interface is frozen in
|
||||
|
||||
It is split the way the protocol splits things:
|
||||
|
||||
- **Resources are the state** — eight of them, read by URI, and reading one
|
||||
- **Resources are the state** — ten of them, read by URI, and reading one
|
||||
changes nothing. `hhstream://status` is whether the desktop is up,
|
||||
`hhstream://sessions` is what is running, `hhstream://sessions/<id>/logs` is
|
||||
an application's own output, `hhstream://pointer` is who holds the input
|
||||
lease, `hhstream://screen` is a frame of the screen.
|
||||
- **Tools are the acts** — twenty-one, one per CLI verb that does something.
|
||||
lease, `hhstream://screen` is a frame of the screen, `hhstream://streams` is
|
||||
what is being published and who is watching.
|
||||
- **Tools are the acts** — twenty-three, one per CLI verb that does something.
|
||||
`session_start` puts an application on the screen, `pointer_acquire` takes the
|
||||
input lease, `keyboard_type` types, `session_kill` ends a session.
|
||||
input lease, `keyboard_type` types, `session_stream_enable` publishes the
|
||||
screen for a person to watch, `session_kill` ends a session.
|
||||
|
||||
A host decides what state to put in front of its model; the model decides what
|
||||
to do. That is the whole of the split, and it is why `shot` is still a tool
|
||||
@@ -104,7 +152,7 @@ account in the group.
|
||||
`hhstream-mcp --list-tools` and `--list-resources` print the two tables and
|
||||
exit, which is the quickest way to check an install.
|
||||
|
||||
If twenty-one tools is more than a client has room for, `--toolsets` narrows
|
||||
If twenty-three tools is more than a client has room for, `--toolsets` narrows
|
||||
what is offered to whichever families are wanted — `frames`, `sessions`,
|
||||
`pointer`, `keyboard`:
|
||||
|
||||
|
||||
Reference in new issue
Block a user