Fix(mcp): align Go tool text and list_files batch with Win32
The Go minimal server sent models after tools it does not have: read_file pointed at download_file and search_file, both absent from its nine-tool set, and the 2 MiB message named a download path that does not exist. It now names list_files, terminal_exec and the Windows controller server. Terminal errors lost the one piece of state the model needs to recover. A busy terminal now says the holder is the web console (no MCP session to close), and a cancelled exec carries the session_id to poll or release. list_files ids[] was advertised in the shared schema but answered -32005. It now implements the Win32 batch contract: 50 ids, ids past the 50 s deadline marked skipped rather than failed, results in input order. The deadline only gates starting a host; one already running finishes on its own timeout, so its result is never mislabelled as a client abort. Each entry takes the per-device lock the single-host path gets, so a host busy with another tool fails that entry with -32003 instead of running beside it. An empty ids array is a valid empty batch, as on Win32. The initialize instructions now describe only what this build implements. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
61b9031269
commit
31883edc09
6 files changed
+433
-32
No files matched your search
@@ -271,8 +271,10 @@ func (s *Server) terminalSessionFor(deviceID, sessionID string) (*termSession, b
|
||||
}
|
||||
switch {
|
||||
case errors.Is(err, hub.ErrTerminalBusy):
|
||||
// The holder is the web console: an existing MCP session is reused above,
|
||||
// so there is no MCP session_id to hand out or close here.
|
||||
return nil, false, errf(CodeBusy,
|
||||
"Device busy: the terminal for host %s is held by another viewer (web console or another MCP call); close it first", deviceID)
|
||||
"Device busy: the terminal on host %s is held by the web console (a human viewer); there is no MCP session_id to close — wait for the viewer to disconnect", deviceID)
|
||||
case errors.Is(err, hub.ErrDeviceOffline):
|
||||
return nil, false, errf(CodeOffline, "Host not found or offline: %s", deviceID)
|
||||
case errors.Is(err, errNoDeviceHub):
|
||||
@@ -349,9 +351,11 @@ func (s *Server) awaitAndDeliver(ctx context.Context, sess *termSession, p *pend
|
||||
sess.cond.Wait()
|
||||
}
|
||||
if ctx.Err() != nil {
|
||||
// The HTTP client is gone; the command keeps running (design §6.6).
|
||||
// The HTTP client is gone; the command keeps running (design §6.6). The
|
||||
// caller never saw a result, so the message has to carry the session id
|
||||
// it needs to poll or close the shell.
|
||||
return terminalExecOutput{}, errf(CodeTimeout,
|
||||
"Request cancelled; the command is still running, poll with session_id to collect its output")
|
||||
"Request cancelled; the command is still running on session_id=%s — poll terminal_exec with that session_id (empty command) or release it with terminal_close", sess.id)
|
||||
}
|
||||
|
||||
var out terminalExecOutput
|
||||
|
||||
Reference in new issue
Block a user