Commit Graph
5 Commits
Author SHA1 Message Date
yuanyuanxianganddeepseek-flash 3d18b2119a Fix(mcp): put listing rows and host ids into text blocks
MCP clients that surface only content[].text saw just count summaries from
list_hosts and get_audit_log; the 64-bit host id lived only in
structuredContent. Without the id, read_file, get_host_detail and
terminal_exec cannot be addressed, so the tools were unusable from those
clients.

Append a tab-separated table after the summary for every list-shaped local
tool: list_hosts (id first, then name/ip/group/os/online/clientType/
last_seen), get_audit_log (time/type/msg), list_files (drives and directory
entries) and get_host_detail (compact host JSON; id/ok/detail rows for a
batch call). Only the returned page is rendered, cells are flattened to one
line, and the truncation note stays on its own line before the table.

structuredContent is unchanged and remains the authoritative copy. Tests
cover row contents, paging, escaping and truncation ordering; a live run
against a Debug client confirmed the id is now visible in text. The MFC
server needs no equivalent change: BuildResult already appends the full
structuredContent as a second text item, so text-only clients there already
receive host ids. Go's envelope emits a single text item, which is why the
rows go into it.

Co-Authored-By: deepseek-flash
2026-11-13 11:25:57 +01:00
yuanyuanxianganddeepseek-flash d4f10db1f2 Feature(Go): verify_tools --subset and MCP deployment docs
Add a third mode to verify_tools.py that validates the Go server end to
end: it fetches /mcp tools/list and requires the name set to equal the
nine implemented tools exactly (seven in readonly mode), compares
description / inputSchema / outputSchema field by field against
mcp/tools.json, and also checks the published order. Unlike --live,
extra or missing tools are failures, not notes.

The field-comparison loop is factored into report_field_diffs so
--offline / --live and --subset share one comparison, diff printer and
FIELDS tuple.

Document and deploy the endpoint: the systemd env example gains
YAMA_MCP_TOKEN / READONLY / TERM_IDLE / MAX_CONCURRENCY / READ_MAX,
the design doc moves to implemented and its section 10 now matches the
code (embedded tools_minimal.json, the three packet dispatch groups).
The tools README explains gen_go_tools.py --check and --subset.

Verified against a freshly built debug Go server on 16543/18090:
read-write mode passes with 9 tools, YAMA_MCP_READONLY=1 passes with 7,
and both mismatch directions (extra tools, missing tools) fail with
exit 1. gen_go_tools.py --check stays clean; no Go code changed.

Co-Authored-By: deepseek-flash
2026-11-12 23:09:33 +01:00
yuanyuanxianganddeepseek-flash 774c0d2545 Feature(Go): four local MCP read tools and a shared audit query package
Implement milestone M2 of the minimal MCP plan: the tools that answer from
the server's own state instead of opening a device channel.

- Extract the audit-log scanner from web into package auditquery so the
  admin page and get_audit_log share one implementation. The web handler
  keeps its 500-row cap, the MCP tool uses the protocol's 1000-row cap.
  Query gains json tags for the web snake_case wire format (device_id,
  warn_only) and reports TotalAll before filters.
- Add package buildinfo and inject Version/Commit with -X from build.ps1
  and the Makefile; go-winres refreshes Windows resources from the git tag
  when available. An unversioned build reports "", and only initialize
  substitutes "dev".
- list_hosts: online/offline pools, include_offline merge, every
  documented filter, limit/offset paging with total/totalAll/hasMore, and
  schema-named host fields (authStatus/tls/remark are never fabricated).
- get_host_detail: single id or a batch of up to 50, online lookup then
  the last history record, capabilities from protocol.SupportsCap plus the
  Windows/registry/virtual-desktop rules; v2 is not listed.
- get_server_status: version, uptime, online/offline counts, port and
  bind. sessions stays absent until the MCP session table lands in M3.
- get_audit_log: case-insensitive event substring, keyword, paging;
  hasMore turns false at the MaxOffset clamp so paging cannot loop.

Wire hub, history, audit path and listen address through mcp.Config from
cmd/main.go. Tests cover pools/filters/paging, capability bits, batch
failures, audit paging and the unversioned build.

Co-Authored-By: deepseek-flash
2026-11-12 20:55:18 +01:00
yuanyuanxianganddeepseek-flash 3f1957a9c9 Feature(Go): MCP endpoint with bearer auth and tools/list
Add a stateless POST /mcp endpoint to the Go server, mounted by the web
server and built from an environment-driven Config in cmd.

The endpoint gates on YAMA_MCP_TOKEN: without it the route is not
registered and /mcp 404s. Requests use a constant-time bearer compare,
and transport failures stay transport failures (401 with a
WWW-Authenticate challenge, 405 for anything but POST, 413 above 8 MiB,
204 for notifications). Everything after a parsed JSON-RPC request is
HTTP 200, including -32600 for batch arrays and -32601 for unknown
methods or tools.

tools/list returns the nine minimal tools verbatim from an embedded
copy of the canonical schemas. tools/mcp_tools/gen_go_tools.py extracts
them from mcp/tools.json, preserving order and only the four published
fields, and its --check mode detects drift. Readonly mode hides and
refuses terminal_exec/terminal_close (-32006); tools that are listed but
not implemented yet answer -32000 until their milestone lands.

Also sync design §3.2 and the M2/M7/M8 plan text to tools.json, which
is the sole schema contract: files not entries, line-based read_file,
no since, camelCase capabilities, max_width [64,1920] defaulting to
1024, and outputSchema included in the M8 subset comparison.

Co-Authored-By: deepseek-flash
2026-11-12 20:35:03 +01:00
yuanyuanxianganddeepseek-flash 5f124fcb3a Docs(mcp): add Go minimal MCP design and implementation plan
Add the v1.0 design for the Go-side minimal MCP server (nine read-only
tools over hub, audit log, terminal and file channels) and the staged
plan that turns it into eight commits.

Record the five decisions settled before construction: extract the audit
query scanner into server/go/auditquery, inject version and commit via a
buildinfo package plus go-winres, treat mcp/tools.json as the only tool
schema contract, verify against a real client, and expose seven tools in
readonly mode.

Add the M0 findings: TestRun.exe cannot log in, because it needs
ServerDll.dll loaded through MemoryDllRunner and the release build deletes
itself when started outside its install path. A Debug ghost.exe came
online against a local Go server in trial signer mode within ten seconds.

Co-Authored-By: deepseek-flash
2026-11-12 20:17:54 +01:00