Skip to main content

Crate mcpls_core

Crate mcpls_core 

Source
Expand description

§mcpls-core

Core library for MCP (Model Context Protocol) to LSP (Language Server Protocol) translation.

This crate provides the fundamental building blocks for bridging AI agents with language servers, enabling semantic code intelligence through MCP tools.

§Architecture

The library is organized into several modules:

  • lsp - LSP client implementation for communicating with language servers
  • mcp - MCP tool definitions and handlers
  • bridge - Translation layer between MCP and LSP protocols
  • config - Configuration types and loading
  • error - Error types for the library

§Example

ⓘ
use mcpls_core::{serve, serve_with, Transport, ServerConfig};

#[tokio::main]
async fn main() {
    let config = ServerConfig::load().expect("failed to load config");
    // Stdio (default):
    let result = serve(config).await;
    // HTTP (requires `transport-http` feature):
    // let http = mcpls_core::HttpConfig::new("127.0.0.1:3000".parse().unwrap());
    // let result = serve_with(config, Transport::Http(http)).await;

    // See `serve`/`serve_with`'s "Shutdown" docs: process::exit avoids a
    // runtime-shutdown hang under the stdio transport.
    std::process::exit(if result.is_ok() { 0 } else { 1 });
}

Re-exports§

pub use config::ProjectConfigStatus;
pub use config::ProjectConfigTrust;
pub use config::ServerAllowlist;
pub use config::ServerConfig;
pub use config::WorkspaceTrust;
pub use error::Error;
pub use transport::Transport;
pub use transport::AllowedHost;transport-http
pub use transport::AllowedOrigin;transport-http
pub use transport::ConnectionLimit;transport-http
pub use transport::HeaderReadTimeout;transport-http
pub use transport::HttpConfig;transport-http
pub use transport::HttpPath;transport-http
pub use transport::InvalidAllowedHost;transport-http
pub use transport::InvalidAllowedOrigin;transport-http
pub use transport::InvalidHttpPath;transport-http
pub use transport::LeaseWindow;transport-http
pub use transport::ListenLease;transport-http
pub use transport::ProbeDeadline;transport-http
pub use transport::ProbeInterval;transport-http
pub use transport::RequestBodyLimit;transport-http
pub use transport::ResponseStreamDeadline;transport-http
pub use transport::SessionLimit;transport-http
pub use transport::StreamLiveness;transport-http
pub use transport::WriteStallTimeout;transport-http

Modules§

bridge
Translation layer between MCP and LSP protocols.
config
Configuration types and loading.
error
Error types for mcpls-core.
lsp
LSP client implementation.
mcp
MCP tool definitions and handlers.
transport
Transport selection for the MCP server.

Functions§

escape_control
Escape every control character, line/paragraph separator and bidi control in s (\n, \r, \t by name, the rest as \u{..}), borrowing s unchanged when it has none.
needs_control_escape
Whether c could forge a log line or reorder displayed text, i.e. whether escape_control rewrites it.
serve
Start the MCPLS server with the given configuration over stdio.
serve_with
Start the MCPLS server with an explicit transport.