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: <<~TXT
You're a coding assistant in the editor zed.
You give one practical example for the given ruby method.
Only answer with a single code snippet and one line of explanation.
For example:
INPUT: '''String#split'''
OUTPUT: 'abc'.split('') # ['a', 'b', 'c']\n Splits the string"
TXT
}
},
{
role: "user",
content: {
type: "text",
text: "INPUT: '''#{snippet}'''"
}
}
]
}
},
)
transport = RubyMCP::Transport::Stdio.new
server.connect(transport)
RubyMCP supports mcp logging. Each logging level has a corresponding method prefixed with send_
and suffixed with _log_message
.
-
Debug Level:
server.send_debug_log_message({ text: "Debug information" })
-
Info Level:
server.send_info_log_message({ 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")