MCPRuby logo

MCPRuby

by sergiobayona

MCPRuby provides server-side tools for implementing the Model Context Protocol (MCP) in Ruby applications. It allows you to easily create MCP servers that expose your application's capabilities to compatible LLM clients.

View on GitHub

Last updated: N/A

What is MCPRuby?

MCPRuby is a Ruby gem that simplifies the creation of MCP (Model Context Protocol) servers. These servers expose application capabilities like functions, data sources, and prompt templates to Large Language Models (LLMs).

How to use MCPRuby?

  1. Install the gem. 2. Create a server instance using MCPRuby.new_server. 3. Register tools, resources, and prompts using register_tool, register_resource, and register_prompt respectively, providing handler blocks for each. 4. Run the server using server.run with either the :stdio or :sse transport.

Key features of MCPRuby

  • MCP Specification Adherence

  • Tools: Define and register custom functions.

  • Resources: Expose data sources.

  • Prompts: Provide structured prompt templates.

  • Multiple Transports: Stdio and SSE.

Use cases of MCPRuby

  • Exposing application functions to LLMs.

  • Providing LLMs with access to specific data sources.

  • Guiding LLMs with predefined prompt templates.

  • Integrating Ruby applications with LLM-powered workflows.

  • Creating custom LLM integrations.

FAQ from MCPRuby

What is MCP?

MCP (Model Context Protocol) is a specification for how Large Language Models (LLMs) can discover and interact with external tools, resources, and prompts provided by separate applications (MCP Servers).

What transports are supported?

MCPRuby supports Stdio (standard input/output) and SSE (Server-Sent Events) transports.

How do I register a tool?

Use the register_tool method, providing a name, description, input schema, and a block that defines the tool's functionality.

How do I provide data to the LLM?

Register a resource using the register_resource method, providing a URI, name, description, MIME type, and a block that returns the data.

How do I define a prompt template?

Register a prompt using the register_prompt method, providing a name, description, arguments, and a block that returns an array of message hashes conforming to the MCP PromptMessage structure.