Summary
get_diagnostics can abort the mcpls stdio server when the target file path contains URI-reserved characters such as [ and ].
This happens with common framework route filenames like:
The client then sees the MCP transport close instead of receiving an error response.
Reproduction
Call get_diagnostics for an existing file whose path contains brackets, for example:
/tmp/project/routes/api/[...].ts
Using an MCP stdio probe against mcpls, the process aborts before returning a tool response.
Observed behavior
mcpls panics while converting the filesystem path to an LSP URI:
thread 'tokio-rt-worker' panicked at crates/mcpls-core/src/bridge/state.rs:
failed to create URI from path: ParseError { ... kind: UnexpectedChar }
From the MCP client side this appears as a closed stdio transport.
Expected behavior
mcpls should create a valid percent-encoded LSP file:// URI, return diagnostics normally, or return a structured tool error without aborting the server.
Suspected root cause
path_to_uri formats file URIs directly as file://{path}. That leaves URI-reserved path characters raw. lsp_types::Uri::from_str rejects the raw brackets, and the following expect panics.
Local validation
A local patch that builds the file URL with Url::from_file_path, percent-encodes the remaining RFC3986-invalid path characters, and adds bracketed-path round-trip coverage fixes the crash.
Validated locally with:
cargo +nightly fmt --check
cargo +1.95 test -p mcpls-core path_to_uri
cargo +1.95 test -p mcpls-core
cargo +1.95 clippy -p mcpls-core --all-targets --all-features -- -D warnings
A post-fix MCP stdio probe against the same bracketed path returned a normal get_diagnostics response instead of aborting.
Summary
get_diagnosticscan abort themcplsstdio server when the target file path contains URI-reserved characters such as[and].This happens with common framework route filenames like:
The client then sees the MCP transport close instead of receiving an error response.
Reproduction
Call
get_diagnosticsfor an existing file whose path contains brackets, for example:Using an MCP stdio probe against
mcpls, the process aborts before returning a tool response.Observed behavior
mcplspanics while converting the filesystem path to an LSP URI:From the MCP client side this appears as a closed stdio transport.
Expected behavior
mcplsshould create a valid percent-encoded LSPfile://URI, return diagnostics normally, or return a structured tool error without aborting the server.Suspected root cause
path_to_uriformats file URIs directly asfile://{path}. That leaves URI-reserved path characters raw.lsp_types::Uri::from_strrejects the raw brackets, and the followingexpectpanics.Local validation
A local patch that builds the file URL with
Url::from_file_path, percent-encodes the remaining RFC3986-invalid path characters, and adds bracketed-path round-trip coverage fixes the crash.Validated locally with:
A post-fix MCP stdio probe against the same bracketed path returned a normal
get_diagnosticsresponse instead of aborting.