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
@@ -117,7 +117,7 @@ def test_tools_list_returns_every_tool_with_a_title_and_a_description(session):
|
||||
|
||||
listed = run(go).tools
|
||||
assert {tool.name for tool in listed} == set(tools.BY_NAME)
|
||||
assert len(listed) == 21
|
||||
assert len(listed) == 23
|
||||
for tool in listed:
|
||||
assert tool.title, tool.name
|
||||
assert tool.description and len(tool.description) > 40, tool.name
|
||||
@@ -527,6 +527,53 @@ def test_a_tool_outside_the_selection_cannot_be_called_by_name(session):
|
||||
assert fake.calls == []
|
||||
|
||||
|
||||
def test_the_stream_url_round_trips_through_a_resource_read(session):
|
||||
"""The phrase reaching an agent is the point of the whole feature."""
|
||||
|
||||
reply = {
|
||||
"ok": True,
|
||||
"id": "s-1",
|
||||
"stream": {
|
||||
"enabled": True,
|
||||
"attached": True,
|
||||
"output": "hh-s-1",
|
||||
"fps": 5,
|
||||
"viewers": 1,
|
||||
"url": "http://127.0.0.1:9988/amber-otter-lantern-harbor-7k2qp/",
|
||||
},
|
||||
}
|
||||
fake, connected = session(stdout=json.dumps(reply, indent=2))
|
||||
|
||||
async def go():
|
||||
async with connected as client:
|
||||
await client.initialize()
|
||||
return await client.read_resource(AnyUrl("hhstream://sessions/s-1/stream"))
|
||||
|
||||
content = run(go).contents[0]
|
||||
assert json.loads(content.text)["stream"]["url"] == reply["stream"]["url"]
|
||||
assert fake.calls == [["session", "stream", "status", "--json", "--", "s-1"]]
|
||||
|
||||
|
||||
def test_enabling_a_stream_through_a_tool_call_returns_its_url(session):
|
||||
reply = {
|
||||
"ok": True,
|
||||
"id": "s-1",
|
||||
"stream": {"attached": True, "url": "http://127.0.0.1:9988/a-b-c-d-12345/"},
|
||||
}
|
||||
fake, connected = session(stdout=json.dumps(reply, indent=2))
|
||||
|
||||
async def go():
|
||||
async with connected as client:
|
||||
await client.initialize()
|
||||
return await client.call_tool("session_stream_enable", {"id": "s-1"})
|
||||
|
||||
result = run(go)
|
||||
assert not result.isError
|
||||
assert result.content[0].text.startswith(reply["stream"]["url"])
|
||||
assert result.structuredContent == reply
|
||||
assert fake.calls == [["session", "stream", "enable", "--json", "--", "s-1"]]
|
||||
|
||||
|
||||
def test_content_for_a_text_only_result_has_no_image_block():
|
||||
blocks = server.content_for(tools.Result(text="hello"))
|
||||
assert [block.type for block in blocks] == ["text"]
|
||||
|
||||
Reference in new issue
Block a user