Reconnect to xats by ui_pid
reconnectRecover a forgotten xats team/name identity by UI process ID and rebind the channel in one call after a context clear or fresh MCP session.
Instructions
Recover this session's prior xats identity when you no longer remember your own (team, name) — for example after a context clear, where the Claude UI process ($PPID) is unchanged but the MCP/channel session is fresh and bind_channel returns unknown_agent. Prefer this over the bind_channel→register_agent fallback for re-establishing on a fresh session: it re-establishes the identity AND rebinds the channel in one call. Route by whether you still remember your (team, name): if you DO remember it after a restart + resume (you closed Claude Code and resumed the conversation, so $PPID has CHANGED but the context survived), call register_agent with that remembered (team, name) and the current $PPID instead of reconnect — reconnect would reverse-look-up the changed $PPID, find no match, and return need_register. Use reconnect only when you do NOT remember your (team, name). Invoke this when the user asks to "reconnect xats", "re-register xats", "重连 xats", or "重新注册 xats". ui_pid is the Claude UI process id — pass $PPID from a Bash tool call inside Claude Code (the same value register_agent takes as ui_pid). The daemon reverse-looks-up the most recent local claude-code agent row whose runtime_ui_pid matches ui_pid, then re-establishes that identity (cross-session takeover + channel/pane auto-bind) reusing the existing agent_id. On a single match: returns { ok, agent_id, name, team, channel_session_id, last_seen_at }. On zero matches: returns { need_register, reason } — reconnect does NOT auto-register; call register_agent to create a new identity. On multiple matches (e.g. the same UI process previously registered under two names): returns { ambiguous, candidates } ordered by last_seen_at descending — surface them so the user can pick, then register_agent with the chosen name. Each candidate/match carries last_seen_at; if it looks stale the matched ui_pid may have been reused by an unrelated process — surface it to the user before trusting the recovered identity. Scope is the daemon's configured local device label for claude-code only; codex (thread_id-based) reconnect is out of scope.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"ui_pid": "<ui_pid>"
},
"name": "reconnect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ui_pid | Yes | The Claude UI process id (`$PPID` from a Bash tool call inside Claude Code). The daemon reverse-looks-up the prior local claude-code identity registered under this runtime_ui_pid. |