Server Monitoring and Control
In this chapter you learn the four tools that look at the language servers themselves: what they say, what they can do, and how to restart one that has gone wrong. Reach for them when a tool answers oddly or not at all.
Prerequisites
- You know the tool conventions.
get_tool_support
Reports which tools are usable for which languages in the current session, without making a call that is certain to fail. Call it before using a tool on a language you have not used yet.
Argument: optional file_path, which restricts the report to that file’s language.
{ "file_path": "/work/app/src/main.rs" }
Per tool, coverage is all, some, none, unknown (a server is still initializing) or always (needs no language server). routes groups languages by status:
status | Meaning |
|---|---|
supported | The call will be dispatched to a server that advertises the capability |
push_only | The server publishes diagnostics but has no pull provider, so get_diagnostics answers from the push cache |
capability_not_advertised | The server does not advertise the feature |
initializing | The server has not finished starting; in a per-server route (below) it also names the server |
unavailable | Only in a per-server route: the member failed to start or its process died; the check never restarts it, so call restart_server |
no_server | No server is routed for this tool |
A tool that is sent to several servers at once, today workspace_symbol_search when two or more servers are eligible, lists one route per eligible server in config order instead of grouping by language. Each route names its server, carries no languages list (a grouped route lists its languages), and has the status supported, capability_not_advertised, initializing or unavailable:
{
"name": "workspace_symbol_search",
"coverage": "all",
"routes": [
{ "server": "rust-analyzer", "status": "supported" },
{ "server": "pyright", "status": "unavailable" }
]
}
coverage follows the aggregate of the set, not the per-server list: it is all as soon as one member is supported, whatever the others report (as in the example), unknown when none is but one is initializing, and none otherwise. Read the routes to see which servers will not answer. A server that untrusted-workspace mode refused is not listed. With a single eligible server the entry keeps its usual shape.
supported means the call will be dispatched, not that it will succeed: indexing, push-only diagnostics and respawn backoff can still fail it.
get_server_logs
Returns recent log messages from the language servers. Arguments: limit (default 50) and min_level, exactly one of error, warning, info, log or debug in lowercase. Levels run from most to least severe in that order, and min_level keeps entries at least as severe as the value you give. Each entry reports its level in the same five spellings: LSP Log messages read log, and an unrecognized message type reads debug.
{ "limit": 20, "min_level": "warning" }
Use it when completion or hover fails, to see messages such as a project that could not be loaded.
get_server_messages
Returns the user-facing messages servers sent with window/showMessage, such as status updates and prompts. Argument: limit (default 20). It has no min_level. Each message’s message_type uses the same five levels as the server logs; an LSP Debug message or a custom type reads debug.
{ "limit": 10 }
restart_server
Restarts language servers: it stops the old process (a graceful shutdown, then a kill of its whole process group) and starts a fresh one, discarding its in-memory state. Use it when a server is wedged or serves a stale index, for example after editing Cargo.toml or package.json.
Give either servers (a list of server ids, taken from name or language_id) or all: true.
{ "servers": ["rust"] }
Per server, status is:
status | Meaning |
|---|---|
restarted | A new process runs; indexing_state is unknown, loading or ready |
failed | The restart failed with a typed reason (see below) |
throttled | Restarted too recently; retry after retry_in_ms |
initializing | The server is still starting |
not_running | The server never started; fix the cause and restart mcpls |
Why a restart fails
A failed entry carries reason, an object with a kind and, for most kinds, a message:
{ "status": "failed", "reason": { "kind": "refused", "message": "..." } }
reason.kind | Meaning | Old process |
|---|---|---|
refused | A check made before the old process was stopped rejected the restart, for example an untrusted-workspace refusal of the launcher | Still running and serving |
spawn_failed | The replacement could not be started, for example the executable is gone | Stopped; the server stays registered and the next tool call retries the spawn |
initialize_failed | The replacement started but did not complete the handshake | Stopped; same retry |
shutting_down | mcpls is shutting down, so no replacement was started | Stopped |
A refused restart does not start the 5 second per-server cooldown, so you can fix the cause and call again at once. Every other outcome that stopped the old process starts it, and a repeat call within 5 seconds answers throttled.
Cancelling a call
If the client cancels a restart_server call, the restarts it already began still finish, so no server is left half restarted.
This tool is destructive: it kills processes the server started, including daemons other clients may share. It is neither read-only nor idempotent. Requests in flight on the old process fail with the retryable -32054 error, and the first whole-workspace query afterwards may wait while the new server indexes.
What’s Next
If something does not work as described, go to Troubleshooting.