Myrr — Agent-friendly content for your Rails app
myrr-rb is the Ruby/Rails client for Myrr, a protocol that makes web content natively accessible to AI agents.
Myrr Port
Myrr Port is the default, zero-configuration mode of myrr-rb. It adds agent-friendly markdown responses to your Rails app without a Go server, a database, or any configuration.
What it does
- Counts tokens on every
text/markdownresponse - Adds an
X-Token-Countheader so agents know the size of your content - Works alongside normal HTML — browsers see HTML, agents see markdown
How it works
Rails 8.1 ships native markdown support: format.md in respond_to, .md.erb template resolution, and content negotiation via Accept: text/markdown, .md extension, or ?format=md. Myrr Port defers entirely to Rails for this — we just count the tokens.
For pre-Rails-8.1 apps, the text/markdown MIME type is registered automatically.
Getting started
- Add the gem to your Gemfile:
gem "myrr-rb"
- Run the installer:
rails generate myrr:install
- Create markdown views alongside your HTML views. For example, if you have
app/views/articles/show.html.erb, createapp/views/articles/show.md.erb:
# <%= @article.title %>
<%= @article.body %>
- Add
format.mdto your controller'srespond_toblock:
def show
@article = Article.find(params[:id])
respond_to do |format|
format.html
format.md
end
end
- An agent requesting with
Accept: text/markdownnow receives:
Content-Type: text/markdown
X-Token-Count: 142
No configuration needed. Everything works out of the box.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.
License
The gem is available as open source under the terms of the MIT License.