Skip to content

Add detect_dead_constants MCP tool#652

Draft
st0012 wants to merge 3 commits intoadd-pagination-support-rubydex-mcpfrom
explore-detect-dead-constants
Draft

Add detect_dead_constants MCP tool#652
st0012 wants to merge 3 commits intoadd-pagination-support-rubydex-mcpfrom
explore-detect-dead-constants

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 6, 2026

Summary

  • Adds a new detect_dead_constants MCP tool that finds Ruby classes, modules, and constants with zero resolved references across the codebase
  • Uses rubydex's semantic name resolution for high accuracy (resolved references, not string matching)
  • Supports kind filter, file_path prefix filter, and limit/offset pagination
  • Results sorted alphabetically by FQN for deterministic pagination
  • Excludes infrastructure declarations (Object, BasicObject, Module, Class)
  • Each result includes: fully qualified name, kind, file path, line number, and owning namespace
  • 13 unit tests covering dead/live contrast for classes, modules, constants, aliases, includes, superclass references, kind filtering, pagination, file path filtering, and owner info
  • E2E test updated to expect the new tool
  • SERVER_INSTRUCTIONS updated with dead code detection guide

st0012 added 3 commits March 5, 2026 17:31
Add offset/total pagination to search_declarations, get_descendants,
and find_constant_references. Uses a two-pass paginate! macro: filter
pass counts total, map pass builds JSON only for the requested page.

- search_declarations: response wrapped in {results, total} envelope
- get_descendants: gains limit (default 100, max 500) and offset
- find_constant_references: gains offset; total always present
- limit=0 treated as default to guard against accidental empty pages
- Tool descriptions and server instructions mention pagination
- Add GraphTest::into_graph() for test graph injection
- Add 26 unit tests calling tool handlers directly (no process spawn)
- Windows-compatible test URIs via test_root()/test_uri() helpers
Add MCP Server section covering the two-pass pagination approach,
result ordering guarantees (stable within a session, may vary across
restarts due to parallel indexing), and key file references.
Find Ruby classes, modules, and constants with zero resolved references
across the codebase. Uses rubydex's semantic resolution for high accuracy
compared to string-matching approaches.

- Params: kind filter, file_path prefix, limit/offset pagination
- Response: name, kind, file, line, owner per dead constant
- Excludes infrastructure declarations (Object, BasicObject, Module, Class)
- Sorted by FQN for deterministic pagination
- 13 tests covering classes, modules, constants, aliases, includes,
  superclass references, kind filtering, pagination, and file path filtering
@st0012 st0012 force-pushed the explore-detect-dead-constants branch from 78806c4 to 9fc7b28 Compare March 6, 2026 17:11
@st0012 st0012 force-pushed the add-pagination-support-rubydex-mcp branch 2 times, most recently from ab1dff0 to ecd1dc0 Compare March 6, 2026 21:19
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.

1 participant