Add Experimental MCP Support #3396
Draft
+3,832
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Model Context Protocol (MCP) support to Ruby LSP
This PR adds support for the Model Context Protocol (MCP), enabling AI assistants to programmatically access Ruby project indexes and file contents that Ruby LSP already collects.
Connection Mechanism
The implementation uses a hybrid approach:
ruby-mcp-bridge
) connects the editor's MCP client to our HTTP serverArchitecture Diagram
Editor Setup
VS Code Configuration
Add to
.vscode/mcp.json
:See VS Code MCP documentation for more details.
Cursor Configuration
Add to
.cursor/mcp.json
:See Cursor MCP documentation for more details.
Notes For Manual Testing
This feature requires both the extension and server changes to work. So for testing:
gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "mcp"
Known Issues
gets
in the LSP communication channel. This issue may be specific to Cursor as it doesn't occur (or occurs much less frequently) in VS Code, and more often in certain projects (e.g.ruby/irb
) than others. The cause may be related to how Cursor handles MCP/LSP requests and requires more investigation.Supported Tools (TBD)
The MCP server provides four tools:
read_ruby_files - Access file contents, including from dependenciesThese tools enable AI assistants to understand Ruby code structure, navigate dependencies, and access relevant documentation that are not accessible through the editor's simple codebase indexing.