Skip to content

feat: add MCP trace tools#176

Merged
BartWaardenburg merged 2 commits intofallow-rs:mainfrom
M-Hassan-Raza:feat/mcp-trace-tools
Apr 24, 2026
Merged

feat: add MCP trace tools#176
BartWaardenburg merged 2 commits intofallow-rs:mainfrom
M-Hassan-Raza:feat/mcp-trace-tools

Conversation

@M-Hassan-Raza
Copy link
Copy Markdown
Contributor

What

  • add MCP tools for tracing exports, files, dependencies, and duplicate-code groups
  • reuse the existing CLI trace paths instead of adding a second analysis path
  • validate required trace inputs at the MCP contract layer
  • cover the new tools with arg-builder, schema, params, and e2e tests

Why

  • agents can now ask for evidence before deleting exports, files, deps, or duplicated blocks
  • this makes MCP output more useful for code review and cleanup workflows without bloating the analyzer core

Validation

  • cargo build -p fallow-cli -p fallow-mcp
  • cargo test -p fallow-mcp
  • cargo clippy -p fallow-mcp --tests -- -D warnings
  • cargo fmt --all -- --check

@BartWaardenburg BartWaardenburg merged commit 01e5ff1 into fallow-rs:main Apr 24, 2026
17 checks passed
BartWaardenburg added a commit that referenced this pull request Apr 25, 2026
`fallow dead-code --trace-dependency PACKAGE` and the MCP `trace_dependency`
tool reported `is_used=false, import_count=0` for packages invoked only via
package.json scripts (microbundle, vitest, eslint) and CI configs
(.github/workflows/*.yml, .gitlab-ci.yml). The unused-deps detector already
ignores those because it cross-references `script_used_packages` produced by
the script analyzer; the trace path bypassed that data, so the two surfaces
disagreed. An agent reading the trace would conclude the dep is safe to remove
and break the build.

Thread `script_used_packages` from `AnalysisOutput` through to
`trace_dependency` and add `used_in_scripts: bool` to `DependencyTrace`.
`is_used` is now `import_count > 0 || used_in_scripts`, matching the
unused-deps detector's view. Human format adds a 'Referenced from package.json
scripts or CI configs' footer when the flag is set; MCP tool description
mentions the new field; rules doc updated.

Verified end-to-end on benchmarks/fixtures/real-world/preact via MCP stdio:
microbundle now reports `is_used=true, used_in_scripts=true`, mobx still
`is_used=false`, preact (real import) still `is_used=true, import_count=191`.

Surfaced during the post-merge dogfood of PR #176 / #177.
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.

2 participants