RubyMCP - Build a MCP Server with Ruby
A low-level Model-Context-Protocol implementation for Ruby. Supports prompts and completions.
server = RubyMCP::Server.new
server.add_prompt(
name: "ruby_example",
description: "Example usage of a method",
arguments: [
{
name: "snippet",
description: "small ruby snippet",
required: true,
completions: ->(*) { [ 'String#split', 'Array#join', 'tally', 'unpack' ] }
}
],
result: ->(snippet:) {
{
description: "Explain '#{snippet}'",
messages: [
{
role: "user",
content: {
type: "text",
text: " You're a coding assistant in the editor zed.\n You give one practical example for the given ruby method.\n Only answer with a single code snippet and one line of explanation.\n For example:\n INPUT: '''String#split'''\n OUTPUT: 'abc'.split('') # ['a', 'b', 'c']\\n Splits the string\"\n TXT\n }\n },\n {\n role: \"user\",\n content: {\n type: \"text\",\n text: \"INPUT: '''\#{snippet}'''\"\n }\n }\n ]\n }\n },\n)\n\ntransport = RubyMCP::Transport::Stdio.new\nserver.connect(transport)\n"
Logging
RubyMCP supports mcp logging. Each logging level has a corresponding method prefixed with send_ and suffixed with _log_message.
Debug Level:
server.({ text: "Debug information" })Info Level:
server.({ text: "Informational message" })
A MCP client can configure change the log severity or it can be set during server creation. The default is "info".
server = Server.new(logging_verbosity: "debug")