gitbutlerapp/gitbutler · error
MCP root is not a file URI
Error message
MCP root is not a file URI: {} What it means
The MCP server converts each client-declared Root into a local filesystem path. After parsing the root's URI, `Url::to_file_path()` fails for any scheme other than `file://`, so the root cannot be mapped onto the local filesystem and this error is raised.
Solutions
- Configure the MCP client to declare roots as absolute `file://` URIs (e.g., `file:///home/user/project`).
- Inspect the client's root configuration and replace any http/ssh/custom-scheme root with a local directory path.
- If a remote root is intentional, mount or sync it locally first and point the root at the local copy.
Example fix
// before (client root config)
{ "uri": "https://example.com/project" }
// after
{ "uri": "file:///home/user/project" } Defensive patterns
Strategy: type-guard
Validate before calling
// client-side, before sending roots
for root of roots:
if !root.uri.startsWith("file:///") throw new Error(`root must be a file:// URI: ${root.uri}`) Type guard
fn is_file_root(root: &Root) -> bool {
Url::parse(&root.uri).map(|u| u.scheme() == "file").unwrap_or(false)
} Try / catch
match root_path(root) {
Err(e) if e.to_string().contains("not a file URI") =>
eprintln!("Skipping unsupported root {}", root.uri),
other => other,
} Prevention
- Always declare MCP roots as absolute file:// URIs.
- Validate root URIs in client config at startup.
- Sync remote/virtual roots to a local path before exposing them.
When it happens
Trigger: An MCP client sends a `roots/list` entry whose `uri` uses a non-file scheme (e.g., `https://`, `ssh://`, or a custom scheme) or a malformed file URI (e.g., `file:relative/path` without a host/authority), making `to_file_path()` return `Err(())`.
Common situations: MCP client configured with remote or virtual roots; IDE clients exposing project roots via http URIs; hand-written MCP configs where the root URI lacks the required `file:///absolute/path` form.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- At least one review number is required
- BUG: we do not create or work with symlinks
- Can only open the GUI on directories
- Cannot attempt to open anything but a directory
- Cannot attempt to open non-existing directory
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/8a7d393a2d7be2c5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/mcp/mod.rs:545
}
};
match open_repository(&path) {
Ok(resolved) => return Ok(resolved),
Err(err) => failures.push(format!("{}: {err:#}", path.display())),
}
}
bail!(
"None of the MCP client's filesystem roots identify a Git repository. {}",
failures.join("; ")
)
}
fn root_path(root: &Root) -> Result<PathBuf> {
let url = Url::parse(&root.uri)
.with_context(|| format!("MCP root is not a valid URI: {}", root.uri))?;
url.to_file_path()
.map_err(|()| anyhow::anyhow!("MCP root is not a file URI: {}", root.uri))
}
fn open_repository(repository: &Path) -> Result<ResolvedRepository> {
let repository = repository
.canonicalize()
.with_context(|| format!("Could not resolve repository at {}", repository.display()))?;
let ctx = but_ctx::Context::discover(&repository)
.with_context(|| format!("Could not open repository at {}", repository.display()))?;
let repository = ctx
.workdir_or_gitdir()
.context("Could not determine the repository root")?
.canonicalize()
.context("Could not resolve the repository root")?;
let name = repository
.file_name()
.and_then(|name| name.to_str())
.unwrap_or("repository")
.to_owned();View on GitHub (pinned to 58e5313667)