pub struct LspServerConfig {Show 13 fields
pub language_id: LanguageId,
pub command: LaunchCommand,
pub args: ServerArgs,
pub env: ServerEnv,
pub file_patterns: Vec<FilePattern>,
pub initialization_options: Option<Value>,
pub settings: Option<LspSettings>,
pub timeout_seconds: TimeoutSecs,
pub request_timeout_seconds: TimeoutSecs,
pub heuristics: Option<ServerHeuristics>,
pub name: Option<ServerId>,
pub handles: Option<ToolSet>,
pub indexing: IndexingPolicy,
}Expand description
Configuration for a single LSP server.
Serialization goes through a raw mirror of this struct, which reports an
invalid file_patterns, env or args entry with the id of the server
that holds it and builds the LaunchCommand from the command and
selection keys.
Fields§
§language_id: LanguageIdLanguage identifier (e.g., “rust”, “python”, “typescript”).
command: LaunchCommandCommand to start the LSP server, with whether mcpls may replace it.
args: ServerArgsArguments to pass to the LSP server command.
env: ServerEnvEnvironment variables for the LSP server process.
file_patterns: Vec<FilePattern>File patterns this server handles (glob patterns).
initialization_options: Option<Value>LSP initialization options (server-specific).
For typescript-language-server, None lets mcpls pin the tsserver
bundled next to the server (tsserver.path) so a workspace-supplied
tsserver is not run. Setting tsserver.path here overrides the pin,
for example to opt back in to the workspace’s TypeScript. Setting any
other options disables the pin: mcpls does not merge into user options.
TypeScript 7 and later ship no tsserver, so there is nothing to pin: with
only that installed the server fails to initialize, and the error says
so. A native tsc --lsp --stdio command gets no pin and no generated
options. See SECURITY.md for the trust model.
settings: Option<LspSettings>Per-server settings pushed after initialized via
workspace/didChangeConfiguration and served on
workspace/configuration. Top-level dotted keys are expanded into
nested objects; keys inside values are left untouched.
timeout_seconds: TimeoutSecsHandshake timeout in seconds: bounds the initialize request during
server startup. Does not affect individual tool-call requests sent
after initialization; see Self::request_timeout_seconds for that.
The LSP server’s shutdown request during teardown uses a separate,
fixed 5-second timeout that is not configurable by this field.
request_timeout_seconds: TimeoutSecsPer-request timeout in seconds, applied to each LSP request issued while translating an MCP tool call (hover, definition, references, etc.).
This bounds a single request attempt, not a whole tool call: on a
-32801 (ContentModified) or -32802 (ServerCancelled) response,
crate::lsp::LspClient::request retries up to 4 attempts with
backoff (one shared budget across both codes), so the worst-case
latency for one tool call is 4 * request_timeout_seconds + 3.5
seconds. Completion requests are further capped at 10 seconds
regardless of this value; see
crate::lsp::LspClient::completion_timeout.
heuristics: Option<ServerHeuristics>Heuristics for determining if this server should be spawned. If not specified, the server will always attempt to spawn.
name: Option<ServerId>Human-readable server identity used as the routing key.
Defaults to language_id when omitted (see Self::id). Must be
unique across all applicable servers in a workspace, regardless of
language: this is what lets two servers share one language_id
(e.g. pyright and pylsp both for python) without one silently
overwriting the other in the maps keyed by ServerId.
handles: Option<ToolSet>Tools this server handles.
None means this server is a catch-all: it serves every tool not
explicitly claimed by another server for the same language.
Some(list) restricts the server to exactly those tools.
indexing: IndexingPolicyWorkspace-indexing readiness policy for this server (P4 escape
hatch). Defaults to IndexingPolicy::Auto: readiness is tracked
normally from whatever signals the server sends (rust-analyzer’s
experimental/serverStatus, or a generic $/progress sequence).
Set to "disabled" for a server whose signal shape doesn’t fit this
tracker’s assumptions – see IndexingPolicy::Disabled.
Implementations§
Source§impl LspServerConfig
impl LspServerConfig
Sourcepub fn id(&self) -> ServerId
pub fn id(&self) -> ServerId
The routing identity of this server: name if set, otherwise language_id.
This is the key used across Translator’s client/server maps, so two
servers for the same language must set distinct names or they
collide (see ToolRouter::from_configs for the enforcement).
Sourcepub fn rust_analyzer() -> Self
pub fn rust_analyzer() -> Self
Create a default configuration for rust-analyzer.
Sourcepub fn typescript() -> Self
pub fn typescript() -> Self
Create a default configuration for TypeScript language server.
initialization_options stays None here; at startup mcpls fills in
the tsserver pin when it can resolve the server’s bundled tsserver (see
Self::initialization_options). The entry is ServerSelection::Auto,
so mcpls may start the native TypeScript server instead when TypeScript 7
is installed outside the workspace.