Cover image

Un marco rubí liviano para construir servidores MCP con un DSL similar a Sinatra

3 years

Works with Finder

2

Github Watches

9

Github Forks

129

Github Stars

MCP-RB

A lightweight Ruby framework for implementing MCP (Model Context Protocol) servers with a Sinatra-like DSL.

Installation

Add this line to your application's Gemfile:

gem 'mcp-rb'

Usage

Here's a simple example of how to create an MCP server:

require 'mcp'

name "hello-world"

version "1.0.0"

# Define a resource
resource "hello://world" do
  name "Hello World"
  description "A simple hello world message"
  call { "Hello, World!" }
end

# Define a resource template
resource_template "hello://{user_name}" do
  name "Hello User"
  description "A simple hello user message"
  call { |args| "Hello, #{args[:user_name]}!" }
end

# Define a tool
tool "greet" do
  description "Greet someone by name"
  argument :name, String, required: true, description: "Name to greet"
  call do |args|
    "Hello, #{args[:name]}!"
  end
end

# Define a tool with nested arguments
tool "greet_full_name" do
  description "Greet someone by their full name"
  argument :person, required: true, description: "Person to greet" do
    argument :first_name, String, required: false, description: "First name"
    argument :last_name, String, required: false, description: "Last name"
  end
  call do |args|
    "Hello, First: #{args[:person][:first_name]} Last: #{args[:person][:last_name]}!"
  end
end

# Define a tool with an Array argument
tool "group_greeting" do
  description "Greet multiple people at once"
  argument :people, Array, required: true, items: String, description: "People to greet"
  call do |args|
    args[:people].map { |person| "Hello, #{person}!" }.join(", ")
  end
end

Supported specifications

Reference: MCP 2024-11-05

  • Base Protocol
    • ping
    • stdio transport
  • Server features
    • Resources
      • resources/read
      • resources/list
      • resources/templates/list
    • Tools
      • tools/list
      • tools/call

Any capabilities are not supported yet.

Testing

rake test
rake test:unit # run only the unit tests, skipping tests that test a running server

Test with MCP Inspector

bunx @modelcontextprotocol/inspector $(pwd)/examples/hello_world.rb

Formatting

bundle exec standardrb --fix

You can also use rake tasks:

rake lint      # Run standardrb to check code style
rake lint:fix  # Auto-fix standardrb issues

Release

To release a new version:

  1. Update version in lib/mcp/version.rb
  2. Update CHANGELOG.md
  3. Create a git tag
git add .
git commit -m "Release vx.y.z"
git tag vx.y.z
git push --tags
  1. Build and push to RubyGems
gem build mcp-rb.gemspec
gem push mcp-rb-*.gem

Changelog

See CHANGELOG.md

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • GeyserMC
  • Una biblioteca para la comunicación con un cliente/servidor de Minecraft.

    Reviews

    3 (1)
    Avatar
    user_D6HUDWhf
    2025-04-17

    As a dedicated user of mcp applications, I am thoroughly impressed with mcp-rb by funwarioisii. This versatile tool simplifies complex tasks and boosts productivity. It's evident that a lot of thought and expertise went into its creation. Highly recommended for anyone looking to streamline their workflow! For more information, visit https://github.com/funwarioisii/mcp-rb.