Skip to main content

ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig {
    pub workspace: WorkspaceConfig,
    pub lsp_servers: Vec<LspServerConfig>,
    pub project_config_ignored: bool,
}
Expand description

Main configuration for the MCPLS server.

Fields§

§workspace: WorkspaceConfig

Workspace configuration.

§lsp_servers: Vec<LspServerConfig>

LSP server configurations.

§project_config_ignored: bool

Whether a CWD-discovered ./mcpls.toml was ignored as untrusted during this load (see ProjectConfigTrust).

Load-time metadata, not user-configurable: never read from or written to a TOML file. Consumed by McplsServer::get_info (the ServerHandler implementation in crate::mcp::server) to surface the ignore decision in-band to MCP clients, supplementing the tracing::warn! emitted at load time (which is stderr-only and typically invisible to an MCP client).

Implementations§

Source§

impl ServerConfig

Source

pub fn build_effective_extension_map(&self) -> HashMap<String, String>

Build the effective extension map used for language detection.

Starts with workspace mappings and overlays mappings inferred from configured LSP server file_patterns.

Source

pub fn load() -> Result<Self>

Load configuration from the default path, treating a CWD-discovered ./mcpls.toml as untrusted.

Default paths checked in order:

  1. $MCPLS_CONFIG environment variable (always trusted)
  2. ./mcpls.toml (current directory) — skipped; see load_with_trust to opt in
  3. Platform user-config directory:
    • Linux: $XDG_CONFIG_HOME/mcpls/mcpls.toml, else ~/.config/mcpls/mcpls.toml
    • macOS: ~/Library/Application Support/mcpls/mcpls.toml
  4. %APPDATA%\mcpls\mcpls.toml (Windows)

If no configuration file exists, creates a default configuration file in the user’s config directory with all default language extensions.

This is a thin wrapper around load_with_trust(ProjectConfigTrust::Untrusted) — the safe default for library callers that haven’t made a trust decision.

§Errors

Returns an error if parsing an existing config fails. If config creation fails, returns default config with graceful degradation.

Source

pub fn load_with_trust(trust: ProjectConfigTrust) -> Result<Self>

Load configuration from the default path, with explicit control over whether a CWD-discovered ./mcpls.toml is honored.

Behaves like load, except a ./mcpls.toml found in the current directory is only loaded when trust is ProjectConfigTrust::Trusted. When untrusted, the file is skipped entirely (including its [workspace] section) and a warning is logged naming the ignored path; discovery falls through to the global config tier or built-in defaults, so project-marker heuristics (e.g. Cargo.toml → rust-analyzer) still apply normally. The returned config’s project_config_ignored is set to true in that case, so callers with access to the loaded config (e.g. McplsServer::get_info) can surface the ignore decision in-band, not just via the stderr-only warning.

$MCPLS_CONFIG and an explicit path are unaffected by trust and are always loaded: naming a path is itself the user’s consent.

§Errors

Returns an error if parsing an existing config fails. If config creation fails, returns default config with graceful degradation.

Source

pub fn load_from(path: &Path) -> Result<Self>

Load configuration from a specific path.

§Errors

Returns an error if the file doesn’t exist, exceeds the maximum allowed config file size, or parsing fails.

Source

pub fn validate(&self) -> Result<()>

Validate the configuration.

This covers only workspace-independent rules — checks that hold regardless of which servers end up applicable in a given workspace. Workspace-scoped routing rules (duplicate ServerId, conflicting handles claims across applicable servers) are enforced later, by ToolRouter::from_configs over the post-heuristics config subset in serve_with — see that function’s module docs for why the split exists (two servers for one language with mutually exclusive heuristics is a legitimate config that must still load here).

Self::load_from always calls this, and so do crate::serve and crate::serve_with for every ServerConfig regardless of origin — a caller-constructed config (not loaded via TOML) gets the same diagnosable Error::InvalidConfig rejection as one loaded from disk, instead of only failing later via silent accessor-level clamping (see crate::lsp::LspClient::request_timeout). Remains pub so a caller can also validate a config up front, before handing it to serve/serve_with (which consume it by value and run until shutdown).

§Errors

Returns Error::InvalidConfig on the first rule violated.

§Examples
use mcpls_core::config::ServerConfig;

let config = ServerConfig::default();
assert!(config.validate().is_ok());

Trait Implementations§

Source§

impl Clone for ServerConfig

Source§

fn clone(&self) -> ServerConfig

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 ServerConfig

Source§

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

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

impl Default for ServerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ServerConfig

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 ServerConfig

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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