Skip to content
Back to search

ruby-sdk

The official Ruby SDK for the Model Context Protocol servers and clients.

Safety scan

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

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/modelcontextprotocol/ruby-sdk with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/modelcontextprotocol/ruby-sdk'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/modelcontextprotocol--ruby-sdk/badge.svg)](/listings/modelcontextprotocol--ruby-sdk)

HTML

<a href="/listings/modelcontextprotocol--ruby-sdk"><img src="/api/listings/modelcontextprotocol--ruby-sdk/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"

And then execute:

$ bundle install

Or install it yourself as:

$ gem install mcp

You may need to add additional dependencies depending on which features you wish to access.

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 · 144 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 Ruby SDK [![Gem Version](https://img.shields.io/gem/v/mcp)](https://rubygems.org/gems/mcp) [![Apache 2.0 licensed](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/LICENSE) [![CI](https://github.com/modelcontextprotocol/ruby-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/modelcontextprotocol/ruby-sdk/actions/workflows/ci.yml)
  2. The official Ruby SDK for Model Context Protocol servers and clients.
  3. Detailed guides are available at https://ruby.sdk.modelcontextprotocol.io.
  4. ## Features
  5. - Build [MCP servers](https://ruby.sdk.modelcontextprotocol.io/server/) that expose tools, prompts, and resources to any MCP host, with OAuth 2.1 resource-server protection
  6. - Build [MCP clients](https://ruby.sdk.modelcontextprotocol.io/client/) that connect to any MCP server, with automatic lifecycle negotiation and OAuth 2.1 authorization
  7. - Speak every standard transport: stdio and Streamable HTTP (including SSE), with a Rails integration
  8. - Cover the full protocol surface: server-to-client requests, multi round-trip requests, notifications, progress, logging, cancellation, completions, and pagination
  9. ## Installation
  10. Add this line to your application's Gemfile:
  11. ```ruby
  12. gem "mcp"
  13. ```
  14. And then execute:
  15. ```console
  16. $ bundle install
  17. ```
  18. Or install it yourself as:
  19. ```console
  20. $ gem install mcp
  21. ```
  22. You may need to add additional dependencies depending on which features you wish to access.
  23. ## Quick Start
  24. The following minimal programs show both sides of the protocol: a server that exposes a single tool,
  25. and a client that spawns such a server and drives it over stdio.
  26. ### MCP Server
  27. A minimal server defines a tool and serves it over the stdio transport:
  28. ```ruby
  29. require "mcp"
  30. # Create a simple tool
  31. class ExampleTool < MCP::Tool
  32. description "A simple example tool that echoes back its arguments"
  33. input_schema(
  34. properties: {
  35. message: { type: "string" },
  36. },
  37. required: ["message"]
  38. )
  39. class << self
  40. def call(message:, server_context:)
  41. MCP::Tool::Response.new([{
  42. type: "text",
  43. text: "Hello from example tool! Message: #{message}",
  44. }])
  45. end
  46. end
  47. end
  48. # Set up the server
  49. server = MCP::Server.new(
  50. name: "example_server",
  51. tools: [ExampleTool],
  52. )
  53. # Create and start the transport
  54. transport = MCP::Server::Transports::StdioTransport.new(server)
  55. transport.open
  56. ```
  57. Save the script as `server.rb`, run it, and send JSON-RPC requests via stdin:
  58. ```console
  59. $ ruby server.rb
  60. {"jsonrpc":"2.0","id":"1","method":"ping"}
  61. {"jsonrpc":"2.0","id":"2","method":"tools/list"}
  62. {"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"example_tool","arguments":{"message":"Hello"}}}
  63. ```
  64. The same server can also run over Streamable HTTP, including mounted inside a Rails application;
  65. see [Server Transports](https://ruby.sdk.modelcontextprotocol.io/server/transports/).
  66. ### MCP Client
  67. A minimal client spawns a stdio server as a subprocess, connects, and lists and calls its tools:
  68. ```ruby
  69. require "mcp"
  70. stdio_transport = MCP::Client::Stdio.new(
  71. command: "bundle",
  72. args: ["exec", "ruby", "path/to/server.rb"],
  73. env: { "API_KEY" => "my_secret_key" },
  74. read_timeout: 30
  75. )
  76. client = MCP::Client.new(transport: stdio_transport)
  77. # Negotiate the protocol lifecycle before sending any requests.
  78. client.connect
  79. # List available tools.
  80. tools = client.tools
  81. tools.each do |tool|
  82. puts "Tool: #{tool.name} - #{tool.description}"
  83. end
  84. # Call a specific tool.
  85. response = client.call_tool(
  86. tool: tools.first,
  87. arguments: { message: "Hello, world!" }
  88. )
  89. # Close the transport when done.
  90. stdio_transport.close
  91. ```
  92. Stdio servers inherit only a small base environment by default, including `GEM_HOME` and `GEM_PATH`.
  93. Pass extra variables through `env:`, or set `inherit_env: true` to restore full inheritance.
  94. The same client can connect to Streamable HTTP servers with `MCP::Client::HTTP`;
  95. see [Client Transports](https://ruby.sdk.modelcontextprotocol.io/client/transports/).
  96. ## Examples
  97. Runnable examples are available in [`examples`](https://github.com/modelcontextprotocol/ruby-sdk/tree/main/examples),
  98. including a complete Rails application in [`examples/rails`](https://github.com/modelcontextprotocol/ruby-sdk/tree/main/examples/rails).
  99. ## Documentation
  100. - [SDK guides](https://ruby.sdk.modelcontextprotocol.io)
  101. - [SDK API documentation](https://rubydoc.info/gems/mcp)
  102. - [Model Context Protocol documentation](https://modelcontextprotocol.io)
  103. ## License
  104. This project is licensed under the Apache License 2.0 for new contributions, with existing code under MIT. See the [LICENSE](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/LICENSE) file for details.

Ratings and comments

Sign in to rate this skill.

Sign in

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