This gem makes accessing ruby gem documentation easy for users with a CLI tool and AI agents with a MCP server.
There are three documentation sources this gem supports.
- local gems served with the yard gem via
yard server --gemsoryard server --gemfileaccessible at http://localhost:8808. - https://gemdocs.org - a good ruby gem documentation host
- Locally compiled documentation for gems defined in your
Gemfile.lockusing thedocument-bundlecommand. The MCP server uses this.
- If ran from a directory with a Gemfile.lock, it will open the documentation for the version specified in Gemfile.lock. When using the online source, you can specify
--latestor--versionoptions. - Defaults to open the latest version of the documentation if not
--localor aGemfile.lockis not found in the current directory. - Can specify a version of the docs to view
- When ran with
--local, it will either serve docs for all gems you have installed or the versions specified in your Gemfile.
Install the gem and add to the application's Gemfile by executing:
bundle add open_gemdocs --group developmentIf bundler is not being used to manage dependencies, install the gem by executing:
gem install open_gemdocsCurrently, this only works on Macs because of the open command. It opens the documentation for a gem in your default web browser.
To see the available options.
open-gem-docs --helpIf you are in a directory with a Gemfile.lock, it will open the documentation for the version of the gem you are using unless you specify --latest or --version options.
If you are not in a directory with a Gemfile.lock, it will open the latest version of the documentation.
open-gem-docs rspec(Assuming you are in a directory with a Gemfile.lock, it will open the rspec docs for the version you are using.)
Open a specific version (regardless of what is in your Gemfile.lock)
open-gem-docs -v 3.12.0 rspecOpen the latest version of the documentation
open-gem-docs --latest rspecTo use a local documentation server. Run the following command from a directory where Gemfile.lock exists. This will serves the documentation for your currently installed gems.
open-gem-docs --localYou can also jump directly to a local doc gem page:
open-gem-docs --local rspecIf you prefer the --local option to be the default, you can use the open-local-docs command instead of open-gem-docs.
Example using the open-local-docs command:
open-local-docs rspecPre-processing the gem docs makes lookups faster.
Change directory to a repository with a Gemfile.lock and run the following command:
document-bundle
The MCP server provides the following tools:
- search_gems - Search for installed Ruby gems by name
- get_gem_info - Get detailed information about a specific gem
- start_yard_server - Start the Yard documentation server
- stop_yard_server - Stop the Yard documentation server
- get_yard_server_status - Check if the Yard server is running
- get_gem_documentation_url - Get the local documentation URL for a gem
- fetch_gem_docs - Fetch documentation content from the Yard server
claude mcp add open-gem-docs -- open-gem-docs-mcp-stdio
- Test the MCP server with different AI agents
- Support agents launched in directories that do not have a Gemfile.lock
- Experiment with providing direct gem source files to see if that is more beneficial for the AI agent.
- The MCP server only supports Mac and linux platforms currently due to bash commands it uses.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/mrinterweb/open_gemdocs.
The gem is available as open source under the terms of the MIT License.