Repository navigation
fix(cli): stop cleanly on SIGTERM with MCP clients connected; one endpoint for several Hosts - #140
Open
Eternal-Wanderer-Vegetable wants to merge 1 commit into
Open
Eternal-Wanderer-Vegetable wants to merge 1 commit into
Eternal-Wanderer-Vegetable wants to merge 1 commit into
Conversation
…point for several Hosts Found while driving command_tools from an external Python MCP client (SDK 1.30.0 and 2.3.0) against one daemon running NoneBot, Koishi and AstrBot. - daemon: handle SIGTERM like Ctrl-C so Hosts and their Workers stop gracefully instead of being left running. - http: bind rmcp Streamable HTTP sessions to the shutdown token and bound the HTTP drain to 10 s; an open SSE stream no longer blocks shutdown (this also fixes POST /v1/shutdown hanging while a client is connected). - astrbot host: a command without a docstring no longer exposes the functools.partial class docstring as its MCP tool description. - samples: configure.py accepts repeated --host to put several Hosts behind one daemon/endpoint (--profile/--port); set_plugin.py takes --profile; mcp_client.py knows the combined profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issues found while driving
command_toolsfrom an external, generic Python MCP client (SDK 1.30.0 and 2.3.0) against one daemon running the NoneBot, Koishi and AstrBot Hosts. Nothing here is specific to any bot; every fix applies to any MCP client.kill/systemd/docker stop left Hosts and their isolated Workers runningdaemon.rs: SIGTERM requests the same graceful shutdown as Ctrl-C (Unix)POST /v1/shutdownhung the same wayhttp.rs: Streamable HTTP sessions use a child of the shutdown token;daemon.rs: HTTP drain is bounded to 10 s, then Hosts are stoppedpartial(func, *args, **keywords) - new function with partial application…as their MCP tool descriptionhosts/astrbot/.../commands.py:handler_descriptionunwrapsfunctools.partialand uses the real docstring or an empty stringconfigure.pyaccepts repeated--host(combined profile on127.0.0.1:26780,--profile/--port);set_plugin.py --profile;mcp_client.py --host combined. Single-Host output is unchangedThe guides (
plugin-installation.md,bot-integration.md, sample README) document the combined profile, shutdown behaviour, and the client-side handling ofConnection closed(-32000) after a Core restart.Related issues
Follow-ups found during this work: #141 (session DELETE 202 vs SDK), #142 (pre-existing clippy errors), #143 (released packages cannot run untrusted Workers behind one endpoint).
Verification
Local, WSL Ubuntu 24.04 with Docker 29.1.3:
cargo fmt --checkpasses;ligamina-clidaemon unit tests 8/8, including newsigterm_requests_graceful_shutdownandinternal_token_requests_shutdown; Windowscargo check -p ligamina-cli --all-targetspasses (non-Unix branch).python -m unittest lab.tests.test_plugin_installation_configure: 6/6 (new).hosts/astrbot/tests/bridge_smoke.pypasses, including a new description check.bash init.sh docspasses.猜数字and组队昵称. Host-crash and full-daemon-restart recovery both work. SIGTERM with an uncooperative client still connected exits in 1.2 s, with no leftover containers.set_plugin.py --profile combineddisable/enable changed the game tools 2 → 0 → 2.Not verified locally (environment gaps, not caused by this change, left to CI):
cargo test --workspace --locked, the twocommand_toolsintegration tests failed: the WSL box has no Linux Node, so the Koishi TypeScript build ran with the Windows npm on PATH.Ligamina-artifact-cachedirectory.report.rsandligamina-core) are untouched.Known and left as is: on session DELETE, rmcp answers
202, and the Python SDK logs "Session termination failed: 202" (it expects 200/204). There is no functional impact.🤖 Generated with Claude Code