Skip to main content

LspServerConfig

Struct LspServerConfig 

Source
pub struct LspServerConfig {
Show 13 fields pub language_id: LanguageId, pub command: LaunchCommand, pub args: Vec<String>, 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 entry with the id of the server that holds it and builds the LaunchCommand from the command and selection keys.

Fields§

§language_id: LanguageId

Language identifier (e.g., “rust”, “python”, “typescript”).

§command: LaunchCommand

Command to start the LSP server, with whether mcpls may replace it.

§args: Vec<String>

Arguments to pass to the LSP server command.

§env: ServerEnv

Environment 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: TimeoutSecs

Handshake 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: TimeoutSecs

Per-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: IndexingPolicy

Workspace-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

Source

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).

Source

pub fn rust_analyzer() -> Self

Create a default configuration for rust-analyzer.

Source

pub fn pyright() -> Self

Create a default configuration for pyright.

Source

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.

Source

pub fn gopls() -> Self

Create a default configuration for gopls.

Source

pub fn clangd() -> Self

Create a default configuration for clangd.

Source

pub fn zls() -> Self

Create a default configuration for zls.

Trait Implementations§

Source§

impl Clone for LspServerConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LspServerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LspServerConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for LspServerConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more