Skip to content
Back to search

mcp-rb

A lightweight Ruby framework for building MCP servers with a Sinatra-like DSL

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/funwarioisii--mcp-rb/badge.svg)](/listings/funwarioisii--mcp-rb)

HTML

<a href="/listings/funwarioisii--mcp-rb"><img src="/api/listings/funwarioisii--mcp-rb/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Add this line to your application's Gemfile:

gem 'mcp-rb'

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 150 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # MCP-RB
  2. > [!WARNING]
  3. > **This project is no longer maintained, and this repository will be archived.**
  4. >
  5. > Please use the official [MCP Ruby SDK](https://github.com/modelcontextprotocol/ruby-sdk) ([`mcp`](https://rubygems.org/gems/mcp) gem) instead.
  6. > It is actively developed under the Model Context Protocol organization and supports the latest protocol features, including clients, prompts, and the Streamable HTTP transport.
  7. >
  8. > ```ruby
  9. > gem "mcp"
  10. > ```
  11. >
  12. > Both `mcp-rb` and `mcp` are loaded with `require "mcp"` and define the top-level `MCP` module, so remove `mcp-rb` from your Gemfile when you switch.
  13. > See the [official documentation](https://ruby.sdk.modelcontextprotocol.io) to get started.
  14. A lightweight Ruby framework for implementing MCP (Model Context Protocol) servers with a Sinatra-like DSL.
  15. ## Installation
  16. Add this line to your application's Gemfile:
  17. ```ruby
  18. gem 'mcp-rb'
  19. ```
  20. ## Usage
  21. Here's a simple example of how to create an MCP server:
  22. ```ruby
  23. require 'mcp'
  24. name "hello-world"
  25. version "1.0.0"
  26. # Define a resource
  27. resource "hello://world" do
  28. name "Hello World"
  29. description "A simple hello world message"
  30. call { "Hello, World!" }
  31. end
  32. # Define a resource template
  33. resource_template "hello://{user_name}" do
  34. name "Hello User"
  35. description "A simple hello user message"
  36. call { |args| "Hello, #{args[:user_name]}!" }
  37. end
  38. # Define a tool
  39. tool "greet" do
  40. description "Greet someone by name"
  41. argument :name, String, required: true, description: "Name to greet"
  42. call do |args|
  43. "Hello, #{args[:name]}!"
  44. end
  45. end
  46. # Define a tool with nested arguments
  47. tool "greet_full_name" do
  48. description "Greet someone by their full name"
  49. argument :person, required: true, description: "Person to greet" do
  50. argument :first_name, String, required: false, description: "First name"
  51. argument :last_name, String, required: false, description: "Last name"
  52. end
  53. call do |args|
  54. "Hello, First: #{args[:person][:first_name]} Last: #{args[:person][:last_name]}!"
  55. end
  56. end
  57. # Define a tool with an Array argument
  58. tool "group_greeting" do
  59. description "Greet multiple people at once"
  60. argument :people, Array, required: true, items: String, description: "People to greet"
  61. call do |args|
  62. args[:people].map { |person| "Hello, #{person}!" }.join(", ")
  63. end
  64. end
  65. ```
  66. ## Supported specifications
  67. Reference: [MCP 2024-11-05](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
  68. - [Base Protocol](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/)
  69. - ping
  70. - stdio transport
  71. - [Server features](https://spec.modelcontextprotocol.io/specification/2024-11-05/server/)
  72. - Resources
  73. - resources/read
  74. - resources/list
  75. - resources/templates/list
  76. - Tools
  77. - tools/list
  78. - tools/call
  79. Any capabilities are not supported yet.
  80. ## Testing
  81. ```bash
  82. rake test
  83. rake test:unit # run only the unit tests, skipping tests that test a running server
  84. ```
  85. Test with MCP Inspector
  86. ```bash
  87. bunx @modelcontextprotocol/inspector $(pwd)/examples/hello_world.rb
  88. ```
  89. ## Formatting
  90. ```bash
  91. bundle exec standardrb --fix
  92. ```
  93. You can also use rake tasks:
  94. ```bash
  95. rake lint # Run standardrb to check code style
  96. rake lint:fix # Auto-fix standardrb issues
  97. ```
  98. ## Release
  99. To release a new version:
  100. 1. Update version in `lib/mcp/version.rb`
  101. 2. Update `CHANGELOG.md`
  102. 3. Create a git tag
  103. ```bash
  104. git add .
  105. git commit -m "Release vx.y.z"
  106. git tag vx.y.z
  107. git push --tags
  108. ```
  109. 1. Build and push to RubyGems
  110. ```bash
  111. gem build mcp-rb.gemspec
  112. gem push mcp-rb-*.gem
  113. ```
  114. ## Changelog
  115. See [CHANGELOG.md](CHANGELOG.md)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.