Skip to content

MCP: add system.log + system.info + viewer.shutdown#5997

Merged
Grantim merged 1 commit into
masterfrom
mcp-system-namespace
Apr 27, 2026
Merged

MCP: add system.log + system.info + viewer.shutdown#5997
Grantim merged 1 commit into
masterfrom
mcp-system-namespace

Conversation

@Grantim
Copy link
Copy Markdown
Contributor

@Grantim Grantim commented Apr 27, 2026

Follow-up to the merged scene/viewer/ui/tools MCP work (#5972, #5980, #5982, #5996). Adds two system.* tools for host-environment observability and one viewer.shutdown for clean process exit.

Tools

  • system.log({maxLines}) — last N pre-formatted spdlog lines (default 100, cap 1000) from the existing rotating-file sink. Opens the file fresh each call; no new sink. Returns [] when file logging is disabled. LLM substring-matches [error] / [warn] client-side if it wants level filtering.
  • system.info — snapshot of MR::GetSystemInfoJson() (the same data behind the About dialog): Version, OS Version, CPU Info, Graphics Info, Memory Info, Window Info, Process Memory. Version is prefixed with \"Debug:\" on Debug builds.
  • viewer.shutdown — calls Viewer::stopEventLoop() from the GUI thread; the MCP response flushes before the event loop exits next frame. The gateway's existing launch tool brings MI back up.

system.runPython is intentionally not in this PR — it'll land on the private MeshInspectorCode layer where access can be gated on user permission.

Verification (live)

  • system.log default → 100 lines including MCP server started on port 7887.
  • system.log {maxLines:5} → exactly 5 lines.
  • system.info{Version: \"Debug: Apr 24 2026\", OS Version: ..., CPU Info: ..., Graphics Info: ..., Memory Info: ..., Window Info: ..., Process Memory: ...}.
  • viewer.shutdown{} response delivered, MI process exits with code 0; the gateway's launch brings it back.

🤖 Generated with Claude Code

system.log returns the last N lines (default 100, capped at 1000) of the
existing rotating-file spdlog output — opens the file fresh each call, no
new sink. Lines come pre-formatted; LLM substring-matches `[error]` etc.
client-side if it wants level filtering.

system.info wraps the existing GetSystemInfoJson() (Version/OS/CPU/GPU/
memory/window). Json::Value -> nlohmann::json via StreamWriterBuilder.

viewer.shutdown calls Viewer::stopEventLoop() so the MCP response can
flush before the event loop exits on the next frame. Re-launch via the
gateway's `launch` tool.

system.runPython is intentionally not here — it'll land on the private
MeshInspectorCode layer where access can be gated on user permission.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Grantim Grantim requested a review from Fedr April 27, 2026 18:11
@Grantim Grantim merged commit f0fe83c into master Apr 27, 2026
35 checks passed
@Grantim Grantim deleted the mcp-system-namespace branch April 27, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants