Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate a complete Model Context Protocol server project in Ruby using the official MCP Ruby SDK gem.
.claude/skills/ruby-mcp-server-generator/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 83% | 8 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 206% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 239% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 153% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 155% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 93% | 0% |
Generate a complete, production-ready MCP server in Ruby using the official Ruby SDK.
When asked to create a Ruby MCP server, generate a complete project with this structure:
my-mcp-server/
├── Gemfile
├── Rakefile
├── lib/
│ ├── my_mcp_server.rb
│ ├── my_mcp_server/
│ │ ├── server.rb
│ │ ├── tools/
│ │ │ ├── greet_tool.rb
│ │ │ └── calculate_tool.rb
│ │ ├── prompts/
│ │ │ └── code_review_prompt.rb
│ │ └── resources/
│ │ └── example_resource.rb
├── bin/
│ └── mcp-server
├── test/
│ ├── test_helper.rb
│ └── tools/
│ ├── greet_tool_test.rb
│ └── calculate_tool_test.rb
└── README.mdrubysource 'https://rubygems.org' gem 'mcp', '~> 0.4.0' group :development, :test do gem 'minitest', '~> 5.0' gem 'rake', '~> 13.0' gem 'rubocop', '~> 1.50' end
rubyrequire 'rake/testtask' require 'rubocop/rake_task' Rake::TestTask.new(:test) do |t| t.libs << 'test' t.libs << 'lib' t.test_files = FileList['test/**/*_test.rb'] end RuboCop::RakeTask.new task default: %i[test rubocop]
ruby# frozen_string_literal: true require 'mcp' require_relative 'my_mcp_server/server' require_relative 'my_mcp_server/tools/greet_tool' require_relative 'my_mcp_server/tools/calculate_tool' require_relative 'my_mcp_server/prompts/code_review_prompt' require_relative 'my_mcp_server/resources/example_resource' module MyMcpServer VERSION = '1.0.0' end
ruby# frozen_string_literal: true module MyMcpServer class Server attr_reader :mcp_server def initialize(server_context: {}) @mcp_server = MCP::Server.new( name: 'my_mcp_server', version: MyMcpServer::VERSION, tools: [ Tools::GreetTool, Tools::CalculateTool ], prompts: [ Prompts::CodeReviewPrompt ], resources: [ Resources::ExampleResource.resource ], server_context: server_context ) setup_resource_handler end def handle_json(json_string) mcp_server.handle_json(json_string) end def start_stdio transport = MCP::Server::Transports::StdioTransport.new(mcp_server) transport.open end private def setup_resource_handler mcp_server.resources_read_handler do |params| Resources::ExampleResource.read(params[:uri]) end end end end
ruby# frozen_string_literal: true module MyMcpServer module Tools class GreetTool < MCP::Tool tool_name 'greet' description 'Generate a greeting message' input_schema( properties: { name: { type: 'string', description: 'Name to greet' } }, required: ['name'] ) output_schema( properties: { message: { type: 'string' }, timestamp: { type: 'string', format: 'date-time' } }, required: ['message', 'timestamp'] ) annotations( read_only_hint: true, idempotent_hint: true ) def self.call(name:, server_context:) timestamp = Time.now.iso8601 message = "Hello, #{name}! Welcome to MCP." structured_data = { message: message, timestamp: timestamp } MCP::Tool::Response.new( [{ type: 'text', text: message }], structured_content: structured_data ) end end end end
ruby# frozen_string_literal: true module MyMcpServer module Tools class CalculateTool < MCP::Tool tool_name 'calculate' description 'Perform mathematical calculations' input_schema( properties: { operation: { type: 'string', description: 'Operation to perform', enum: ['add', 'subtract', 'multiply', 'divide'] }, a: { type: 'number', description: 'First operand' }, b: { type: 'number', description: 'Second operand' } }, required: ['operation', 'a', 'b'] ) output_schema( properties: { result: { type: 'number' }, operation: { type: 'string' } }, required: ['result', 'operation'] ) annotations( read_only_hint: true, idempotent_hint: true ) def self.call(operation:, a:, b:, server_context:) result = case operation when 'add' then a + b when 'subtract' then a - b when 'multiply' then a * b when 'divide' return error_response('Division by zero') if b.zero? a / b.to_f else return error_response("Unknown operation: #{operation}") end structured_data = { result: result, operation: operation } MCP::Tool::Response.new( [{ type: 'text', text: "Result: #{result}" }], structured_content: structured_data ) end def self.error_response(message) MCP::Tool::Response.new( [{ type: 'text', text: message }], is_error: true ) end end end end
ruby# frozen_string_literal: true module MyMcpServer module Prompts class CodeReviewPrompt < MCP::Prompt prompt_name 'code_review' description 'Generate a code review prompt' arguments [ MCP::Prompt::Argument.new( name: 'language', description: 'Programming language', required: true ), MCP::Prompt::Argument.new( name: 'focus', description: 'Review focus area (e.g., performance, security)', required: false ) ] meta( version: '1.0', category: 'development' ) def self.template(args, server_context:) language = args['language'] || 'Ruby' focus = args['focus'] || 'general quality' MCP::Prompt::Result.new( description: "Code review for #{language} with focus on #{focus}", messages: [ MCP::Prompt::Message.new( role: 'user', content: MCP::Content::Text.new( "Please review this #{language} code with focus on #{focus}." ) ), MCP::Prompt::Message.new( role: 'assistant', content: MCP::Content::Text.new( "I'll review the code focusing on #{focus}. Please share the code." ) ), MCP::Prompt::Message.new( role: 'user', content: MCP::Content::Text.new( '[paste code here]' ) ) ] ) end end end end
ruby# frozen_string_literal: true module MyMcpServer module Resources class ExampleResource RESOURCE_URI = 'resource://data/example' def self.resource MCP::Resource.new( uri: RESOURCE_URI, name: 'example-data', description: 'Example resource data', mime_type: 'application/json' ) end def self.read(uri) return [] unless uri == RESOURCE_URI data = { message: 'Example resource data', timestamp: Time.now.iso8601, version: MyMcpServer::VERSION } [{ uri: uri, mimeType: 'application/json', text: data.to_json }] end end end end
ruby#!/usr/bin/env ruby # frozen_string_literal: true require_relative '../lib/my_mcp_server' begin server = MyMcpServer::Server.new server.start_stdio rescue Interrupt warn "\nShutting down server..." exit 0 rescue StandardError => e warn "Error: #{e.message}" warn e.backtrace.join("\n") exit 1 end
Make the file executable:
bashchmod +x bin/mcp-server
ruby# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path('../lib', __dir__) require 'my_mcp_server' require 'minitest/autorun'
ruby# frozen_string_literal: true require 'test_helper' module MyMcpServer module Tools class GreetToolTest < Minitest::Test def test_greet_with_name response = GreetTool.call( name: 'Ruby', server_context: {} ) refute response.is_error assert_equal 1, response.content.length assert_match(/Ruby/, response.content.first[:text]) assert response.structured_content assert_equal 'Hello, Ruby! Welcome to MCP.', response.structured_content[:message] end def test_output_schema_validation response = GreetTool.call( name: 'Test', server_context: {} ) assert response.structured_content.key?(:message) assert response.structured_content.key?(:timestamp) end end end end
ruby# frozen_string_literal: true require 'test_helper' module MyMcpServer module Tools class CalculateToolTest < Minitest::Test def test_addition response = CalculateTool.call( operation: 'add', a: 5, b: 3, server_context: {} ) refute response.is_error assert_equal 8, response.structured_content[:result] end def test_subtraction response = CalculateTool.call( operation: 'subtract', a: 10, b: 4, server_context: {} ) refute response.is_error assert_equal 6, response.structured_content[:result] end def test_multiplication response = CalculateTool.call( operation: 'multiply', a: 6, b: 7, server_context: {} ) refute response.is_error assert_equal 42, response.structured_content[:result] end def test_division response = CalculateTool.call( operation: 'divide', a: 15, b: 3, server_context: {} ) refute response.is_error assert_equal 5.0, response.structured_content[:result] end def test_division_by_zero response = CalculateTool.call( operation: 'divide', a: 10, b: 0, server_context: {} ) assert response.is_error assert_match(/Division by zero/, response.content.first[:text]) end def test_unknown_operation response = CalculateTool.call( operation: 'modulo', a: 10, b: 3, server_context: {} ) assert response.is_error assert_match(/Unknown operation/, response.content.first[:text]) end end end end
`markdown# My MCP Server A Model Context Protocol server built with Ruby and the official MCP Ruby SDK. ## Features - ✅ Tools: greet, calculate - ✅ Prompts: code_review - ✅ Resources: example-data - ✅ Input/output schemas - ✅ Tool annotations - ✅ Structured content - ✅ Full test coverage ## Requirements - Ruby 3.0 or later ## Installation
bundle install
## Usage
### Stdio Transport
Run the server:
bundle exec bin/mcp-server
Then send JSON-RPC requests:
{"jsonrpc":"2.0","id":"1","method":"ping"} {"jsonrpc":"2.0","id":"2","method":"tools/list"} {"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"greet","arguments":{"name":"Ruby"}}}
### Rails Integration
Add to your Rails controller:
class McpController < ApplicationController def index server = MyMcpServer::Server.new( server_context: { user_id: current_user.id } ) render json: server.handle_json(request.body.read) end end
## Testing
Run tests:
bundle exec rake test
Run linter:
bundle exec rake rubocop
Run all checks:
bundle exec rake
## Integration with Claude Desktop
Add to `claude_desktop_config.json`:
{ "mcpServers": { "my-mcp-server": { "command": "bundle", "args": "exec", "bin/mcp-server"], "cwd": "/path/to/my-mcp-server" } } }
## Project Structure
my-mcp-server/ ├── Gemfile # Dependencies ├── Rakefile # Build tasks ├── lib/ # Source code │ ├── my_mcp_server.rb # Main entry point │ └── my_mcp_server/ # Module namespace │ ├── server.rb # Server setup │ ├── tools/ # Tool implementations │ ├── prompts/ # Prompt templates │ └── resources/ # Resource handlers ├── bin/ # Executables │ └── mcp-server # Stdio server ├── test/ # Test suite │ ├── test_helper.rb # Test configuration │ └── tools/ # Tool tests └── README.md # This file
## License
MIT| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 17,450 | 37,528 | +115% | 1 | 1 | 0% | 4,294 | 5,067 | +18% | 0 | 0 | — |
case-02 | fail→fail | 23,776 | 38,394 | +61% | 1 | 1 | 0% | 6,198 | 4,455 | -28% | 0 | 0 | — |
case-03 | fail→fail | 25,450 | 34,355 | +35% | 1 | 1 | 0% | 6,196 | 4,455 | -28% | 0 | 0 | — |
case-04 | fail→pass | 8,040 | 3,877 | -52% | 1 | 1 | 0% | 1,640 | 5,024 | +206% | 0 | 0 | — |
case-05 | fail→pass | 6,965 | 4,284 | -38% | 1 | 1 | 0% | 1,476 | 5,005 | +239% | 0 | 0 | — |
case-06 | fail→pass | 7,995 | 2,448 | -69% | 1 | 1 | 0% | 1,836 | 4,647 | +153% | 0 | 0 | — |
case-07 | fail→pass | 14,794 | 15,042 | +2% | 1 | 1 | 0% | 3,311 | 8,443 | +155% | 0 | 0 | — |
case-08 | fail→pass | 12,974 | 5,879 | -55% | 1 | 1 | 0% | 2,821 | 5,446 | +93% | 0 | 0 | — |
case-24 | pass→pass | 16,746 | 12,847 | -23% | 1 | 1 | 0% | 4,136 | 7,453 | +80% | 0 | 0 | — |
case-09 | fail→pass | 12,506 | 10,018 | -20% | 1 | 1 | 0% | 2,765 | 6,359 | +130% | 0 | 0 | — |
case-10 | fail→pass | 13,544 | 8,471 | -37% | 1 | 1 | 0% | 2,796 | 6,214 | +122% | 0 | 0 | — |
case-11 | fail→pass | 12,501 | 8,323 | -33% | 1 | 1 | 0% | 2,868 | 6,333 | +121% | 0 | 0 | — |
case-12 | fail→pass | 10,282 | 7,353 | -28% | 1 | 1 | 0% | 2,226 | 5,865 | +163% | 0 | 0 | — |
case-13 | fail→pass | 13,579 | 12,757 | -6% | 1 | 1 | 0% | 2,999 | 7,061 | +135% | 0 | 0 | — |
case-14 | fail→pass | 9,848 | 7,911 | -20% | 1 | 1 | 0% | 2,063 | 6,060 | +194% | 0 | 0 | — |
case-15 | fail→pass | 10,499 | 7,435 | -29% | 1 | 1 | 0% | 2,484 | 5,849 | +135% | 0 | 0 | — |
case-16 | fail→pass | 10,414 | 8,298 | -20% | 1 | 1 | 0% | 2,153 | 6,008 | +179% | 0 | 0 | — |
case-17 | fail→pass | 10,798 | 10,467 | -3% | 1 | 1 | 0% | 2,464 | 6,499 | +164% | 0 | 0 | — |
case-18 | fail→pass | 9,193 | 8,215 | -11% | 1 | 1 | 0% | 2,345 | 6,255 | +167% | 0 | 0 | — |
case-19 | fail→pass | 10,135 | 7,244 | -29% | 1 | 1 | 0% | 2,416 | 5,714 | +137% | 0 | 0 | — |
case-20 | fail→pass | 9,410 | 3,732 | -60% | 1 | 1 | 0% | 2,143 | 4,841 | +126% | 0 | 0 | — |
case-21 | fail→pass | 8,163 | 5,619 | -31% | 1 | 1 | 0% | 1,945 | 5,413 | +178% | 0 | 0 | — |
case-22 | fail→pass | 13,303 | 11,028 | -17% | 1 | 1 | 0% | 2,954 | 6,773 | +129% | 0 | 0 | — |
case-23 | pass→pass | 19,736 | 15,902 | -19% | 1 | 1 | 0% | 4,384 | 7,831 | +79% | 0 | 0 | — |
case-25 | pass→pass | 11,048 | 12,183 | +10% | 1 | 1 | 0% | 3,048 | 7,595 | +149% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 22 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +76 percentage points is the difference between those two pass rates over the 22 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 7/24/2026 | +64% |
Other measured skills in the registry, with their headline benchmark lift.