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: WorkspaceConfigWorkspace configuration.
lsp_servers: Vec<LspServerConfig>LSP server configurations.
project_config_ignored: boolWhether 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
impl ServerConfig
Sourcepub fn build_effective_extension_map(&self) -> HashMap<String, String>
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.
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load configuration from the default path, treating a CWD-discovered
./mcpls.toml as untrusted.
Default paths checked in order:
$MCPLS_CONFIGenvironment variable (always trusted)./mcpls.toml(current directory) — skipped; seeload_with_trustto opt in- Platform user-config directory:
- Linux:
$XDG_CONFIG_HOME/mcpls/mcpls.toml, else~/.config/mcpls/mcpls.toml - macOS:
~/Library/Application Support/mcpls/mcpls.toml
- Linux:
%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.
Sourcepub fn load_with_trust(trust: ProjectConfigTrust) -> Result<Self>
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.
Sourcepub fn load_from(path: &Path) -> Result<Self>
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.
Sourcepub fn validate(&self) -> Result<()>
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
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more