[Bug] MCP tools called without `repo` silently resolve to the workspace default_repo, not the caller's repo

Open
#6,468 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
40/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by tracing how MCP tool calls resolve an omitted repo parameter and how the server gets its default repository; the issue names repowise mcp, the workspace default_repo, and repo-scoped tools such as get_change_risk. Compare omitted and explicit repo calls, then add coverage for the chosen mitigation. Done means calls cannot silently return data from a different repository.

Written by the indexing model from the issue text.

Description

Summary

MCP tool calls that omit the `repo` parameter are answered from the workspace `default_repo` index (the serve anchor), not from the repository the caller is working in. The wrong-repo answer returns with no warning, so callers silently consume index data for a different repository.

Observed on repowise 0.61.0, `repowise mcp` running as a supervised long-running daemon, Windows 11.

Mechanism

  • `repowise mcp ` is spawned once per machine against the workspace serve anchor (`.repowise-workspace.yaml` `default_repo`), so the daemon's env lookup and default scope sit on that repo.
  • Tool calls carry an optional `repo` argument. Supplied → correct resolution. Omitted (`repo=None`) → the server falls back to the anchor/default. There is no per-session caller-cwd binding and no fail-closed behaviour.
  • One daemon serves MCP clients started from many repos (agent/IDE sessions in any of the 17 workspace members), so "the caller's repo" is only recoverable from per-call context.

Reproduction / field evidence

  1. `get_change_risk` called without `repo` while the caller was working in repo A answered with repo B (the workspace default) — including another repo's HEAD. The same call with `repo='A'` resolved `origin/master..HEAD` correctly.
  2. Daemon child log carries `impacted_tests_head_start_failed` — `ValueError: unknown revision 'master'`, `'origin/master'`, `''` (~7 occurrences over 3 days): calls reaching the serve with a base/head revision valid in the caller's repo but absent from the resolved default repo — the same wrong-repo signature one layer down.

Impact

Any caller that forgets `repo` gets plausible-looking but wrong-repository data — a silent data-integrity failure, not an error. Change-risk, impacted-tests and risk findings can describe the wrong codebase.

Suggested fixes (any one mitigates)

  • Fail closed: reject `repo=None` on repo-scoped tools with a clear "repo required" error; or
  • Per-session binding: resolve the caller's repo from MCP session context (client cwd / initialize params); or
  • Warn loudly: include `resolved_repo` + `repo_source: 'default'` in every response so clients can detect the fallback.

Local mitigation in place on our side: callers always pass `repo=` explicitly and verify the returned repo field before trusting the answer.

Related: #5334 covered which repo the daemon serves; this is the per-call resolution layer on top of it.

Dominant language
Python
Stars
7.1k
Forks
756
Avg merge
21h 5m
Merged PRs (30d)
797

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from repowise-dev/repowise

All issues in repowise-dev/repowise

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.