OpenGemdocs
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 --gems
oryard server --gemfile
accessible at http://localhost:8808. - https://gemdocs.org - a good ruby gem documentation host
- Locally compiled documentation for gems defined in your
Gemfile.lock
using thedocument-bundle
command. 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
--latest
or--version
options. - Defaults to open the latest version of the documentation if not
--local
or aGemfile.lock
is 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.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add open_gemdocs --group development
If bundler is not being used to manage dependencies, install the gem by executing:
gem install open_gemdocs
CLI Usage
Currently, 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 --help
Example usage
If 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 rspec
Open the latest version of the documentation
open-gem-docs --latest rspec
To 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 --local
You can also jump directly to a local doc gem page:
open-gem-docs --local rspec
If 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 rspec
Process Gem documentation sources
Pre-processing the gem docs makes lookups faster.
Change directory to a repository with a Gemfile.lock
and run the following command:
document-bundle
Available MCP Tools
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
Using with Claude Code
claude mcp add open-gem-docs -- open-gem-docs-mcp-stdio
ToDo
- 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.
Limitations
- The MCP server only supports Mac and linux platforms currently due to bash commands it uses.
Development
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.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mrinterweb/open_gemdocs.
License
The gem is available as open source under the terms of the MIT License.