gitbutlerapp/gitbutler · error

None of the MCP client's filesystem roots identify a Git…

Error message

None of the MCP client's filesystem roots identify a Git repository. {}

What it means

The server iterates the MCP client's filesystem roots trying to open each as a Git repository. If every root fails to open (none is a git repo), it bails listing the per-root failure reasons. This tells the caller that exposed roots exist but none is a usable Git repository.

Solutions

  1. Pass the `repository` argument explicitly pointing at a valid Git repository
  2. Expose a folder that is inside a Git repository as a filesystem root in the client
  3. Run `git init` (or open an existing clone) in the folder exposed as a root, and check path permissions

Example fix

// before
roots: ["/home/user"] // not a git repo
// after
roots: ["/home/user/my-project"] // a git repository
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
if (!existsSync(path.join(rootPath, '.git')) && !existsSync(path.join(rootPath, 'HEAD'))) throw new Error(`${rootPath} is not a git repo`);

Try / catch

try { await callTool(name, args); } catch (e) { if (/not identify a Git repository/.test(e.message)) args.repository = pickRepoRoot(e); }

Prevention

When it happens

Trigger: All roots returned by the MCP client point at directories where open_repository fails — non-git directories, bare/unreadable repos, or paths that error on open.

Common situations: Pointing the MCP client at a home/parent directory instead of a repo; target folder without a .git directory; permission problems on the repository path.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/0b67d5a0cd11974e. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/mcp/mod.rs:535

        );
    }

    let mut failures = Vec::new();
    for root in roots {
        let path = match root_path(root) {
            Ok(path) => path,
            Err(err) => {
                failures.push(err.to_string());
                continue;
            }
        };
        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()))?;

View on GitHub (pinned to 58e5313667)