Skip to content

feat: use roots/list to automatically detect workspace directory#108

Merged
Vaiz merged 17 commits intomasterfrom
roots
Apr 5, 2026
Merged

feat: use roots/list to automatically detect workspace directory#108
Vaiz merged 17 commits intomasterfrom
roots

Conversation

@Vaiz
Copy link
Copy Markdown
Owner

@Vaiz Vaiz commented Apr 4, 2026

solves issue #106 for supported IDEs. It uses roots/list request to find out cwd for current project. The detection runs only once when MCP server is initialized.

the fix works for VS Code, doesn't work for Zed though - zed-industries/zed#53156

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automatic workspace root detection for the Rust MCP server by querying the MCP client’s roots/list after initialization, so tool commands can run in the project directory without requiring --workspace.

Changes:

  • Introduce src/workspace.rs to detect a Cargo workspace via roots/list and apply the detected root to executed commands.
  • Refactor workspace root storage from String to PathBuf and wire detection into server initialization.
  • Add percent-encoding (URI decoding) and enable Tokio’s time feature for detection timeouts.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/workspace.rs New workspace auto-detection logic + URI-to-path conversion + unit tests.
src/rmcp_server.rs Triggers workspace detection in on_initialized behind a flag.
src/main.rs Enables detection when --workspace isn’t provided and passes flag to server.
src/globals.rs Stores workspace root as PathBuf and adds try_set_workspace_root.
src/command.rs Applies workspace root from the new workspace module before running commands.
src/tools/mod.rs Stops re-exporting apply_workspace_root (now in workspace).
src/tools/cargo/doc.rs Updates path joining to use PathBuf root directly.
Cargo.toml Adds percent-encoding; enables tokio time feature.
Cargo.lock Records dependency graph changes (includes broad upgrades).
.vscode/mcp.json Adjusts local dev config args (log level).
.github/copilot-instructions.md Updates repo Copilot guidance text.
.github/agents/rust-docs.agent.md Adds a rust-docs agent definition.

Comment thread src/workspace.rs
Comment thread src/workspace.rs
@Vaiz Vaiz marked this pull request as ready for review April 5, 2026 16:07
@Vaiz Vaiz merged commit ba205b2 into master Apr 5, 2026
8 checks passed
@Vaiz Vaiz deleted the roots branch April 5, 2026 16:07
@github-actions github-actions Bot mentioned this pull request Apr 5, 2026
@Vaiz Vaiz linked an issue Apr 5, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong cwd in Zed IDE

2 participants