Skip to content

tangentus/mcp-ruby-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Ruby SDK

Gem Version MIT licensed

Ruby implementation of the Model Context Protocol (MCP).

Installation

Add this line to your application's Gemfile:

gem 'mcp'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install mcp

Quick Start

Here's a simple example of creating an MCP server with a calculator tool:

require 'mcp'

# Create an MCP server
server = MCP::Server.new(
  name: "Demo",
  version: "1.0.0"
)

# Add an addition tool
server.add_tool("add") do |params|
  result = params["a"] + params["b"]
  {
    content: [{ type: "text", text: result.to_s }]
  }
end

# Add a dynamic greeting resource
server.add_resource("greeting") do |uri, params|
  {
    contents: [{
      uri: uri,
      text: "Hello, #{params['name']}!"
    }]
  }
end

# Start the server using stdio transport
transport = MCP::Transport::Stdio.new
server.connect(transport)

Features

  • Full implementation of the MCP specification
  • Support for Resources, Tools, and Prompts
  • Multiple transport options (stdio, HTTP/SSE)
  • Easy-to-use high-level interfaces
  • Async/await support
  • Comprehensive type system

Documentation

For detailed documentation, please visit:

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/modelcontextprotocol/ruby-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby SDK for the MCP Protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages