MCPcopy Index your code
hub / github.com/Shopify/rubydex

github.com/Shopify/rubydex @v0.2.7

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.7 ↗ · + Follow
2,167 symbols 9,629 edges 110 files 304 documented · 14%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rubydex

This project is a high-performance static analysis toolkit for the Ruby language. The goal is to be a solid foundation to power a variety of tools, such as type checkers, linters, language servers and more.

Usage

Both Ruby and Rust APIs are made available through a gem and a crate, respectively. Here's a simple example of using the Ruby API:

# Create a new graph representing the current workspace
graph = Rubydex::Graph.new
# Configuring graph LSP encoding
graph.encoding = "utf16"
# Index the entire workspace with all dependencies
graph.index_workspace
# Or index specific file paths
graph.index_all(["path/to/file.rb"])
# Transform the initially collected information into its semantic understanding by running resolution
graph.resolve
# Get all diagnostics acquired during the analysis
graph.diagnostics

# Iterating over graph nodes
graph.declarations
graph.documents
graph.constant_references
graph.method_references

# Analyzing require paths
graph.resolve_require_path("rails/engine", load_paths) # => document pointed by `rails/engine`
graph.require_paths(load_paths) # => array of all indexed require paths

# Querying
graph["Foo"] # Get declaration by fully qualified name
graph.search("Foo#b") # Name search
graph.resolve_constant("Bar", ["Foo", "Baz::Qux"]) # Resolve constant reference based on nesting

# Declarations
declaration = graph["Foo"]

# All declarations include
declaration.name
declaration.unqualified_name
declaration.definitions
declaration.owner

# Namespace declarations include
declaration.member("bar()")
declaration.member("@ivar")
declaration.singleton_class
declaration.ancestors
declaration.descendants

# Documents
document = graph.documents.first
document.uri
document.definitions # => list of definitions discovered in this document

# Definitions
definition = declaration.definitions.first
definition.location
definition.comments
definition.name
definition.deprecated?
definition.name_location

# Locations
location = definition.location
location.path

# Diagnostics
diagnostic = graph.diagnostics.first
diagnostic.rule
diagnostic.message
diagnostic.location

MCP Server (Experimental)

Rubydex can run as an MCP (Model Context Protocol) server, enabling AI assistants like Claude to semantically query your Ruby codebase.

Setup

  1. Add Rubydex to the Ruby project you want to index: ruby gem "rubydex"

  2. Install the bundle: bash bundle install

  3. Configure your MCP client to run bundle exec rubydex_mcp.

Using Claude Code as an example: bash claude mcp add --scope project rubydex -- bundle exec rubydex_mcp

Using Codex as an example: bash codex mcp add rubydex -- bundle exec rubydex_mcp

Start your MCP client from that project directory. The MCP server indexes the project at startup and provides semantic code intelligence tools through the tools below.

Available MCP Tools

Tool Description
search_declarations Fuzzy search for classes, modules, methods, constants
get_declaration Full details by fully qualified name with docs, ancestors, members
get_descendants What classes/modules inherit from or include this one
find_constant_references All precise, resolved constant references across the codebase
get_file_declarations List declarations defined in a specific file
codebase_stats High-level statistics about the indexed codebase

Contributing

See the contributing documentation.

Extension points exported contracts — how you extend this code

Job (Interface)
Unit of work scheduled on a `JobQueue`. # Example ``` use std::sync::Arc; use rubydex::job_queue::{Job, JobQueue}; st [2 …
rust/rubydex/src/job_queue.rs
ToDot (Interface)
(no doc) [3 implementers]
rust/rubydex/src/dot.rs

Core symbols most depended-on inside this repo

resolve
called by 445
rust/rubydex/src/resolution.rs
new
called by 273
rust/rubydex/src/query.rs
get
called by 264
rust/rubydex/src/model/id.rs
location
called by 228
lib/rubydex/reference.rb
name
called by 227
rust/rubydex/src/model/name.rs
push
called by 174
rust/rubydex/src/job_queue.rs
write!
called by 142
test/helpers/context.rb
with_context
called by 125
rust/rubydex/src/test_utils/context.rs

Shape

Function 1,031
Method 897
Class 191
Enum 46
Interface 2

Languages

Rust79%
Ruby15%
C6%
C++1%

Modules by API surface

rust/rubydex/src/resolution_tests.rs215 symbols
rust/rubydex/src/indexing/ruby_indexer_tests.rs172 symbols
rust/rubydex/src/model/graph.rs140 symbols
rust/rubydex/src/query.rs120 symbols
rust/rubydex/src/operation/ruby_builder.rs120 symbols
test/graph_test.rb96 symbols
rust/rubydex/src/indexing/ruby_indexer.rs92 symbols
rust/rubydex/src/indexing/rbs_indexer.rs64 symbols
rust/rubydex/src/model/definitions.rs52 symbols
rust/rubydex/src/model/declaration.rs51 symbols
rust/rubydex-mcp/src/server.rs50 symbols
rust/rubydex-sys/src/graph_api.rs48 symbols

For agents

$ claude mcp add rubydex \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact