The Ruby MCP Server for Claude Integration is an experimental Ruby implementation of the Model Context Protocol (MCP). It serves as a starter server framework for integrating Large Language Models (LLMs) like Claude with external tools. This project provides a foundational structure for building and managing tools that can be called by LLMs, with a current implementation that includes a random number generator tool.
get-random-number
Tool: Generates a random integer between 1 and a specified maximum value (defaults to 100).MCP::Server
: Handles MCP protocol messages, including initialization, tool registration, message handling, and error management.MCP::Transport::Stdio
: Manages communication via standard I/O, including message reception and response transmission.MCP::Tool
: Defines and executes tools, managing tool names, descriptions, and input schemas.RandomNumberServer
: Initializes the server, sets up tools, and manages server execution.initialize
request with the protocol version.initialized
notification.initialize
: Initializes the server and negotiates the protocol version.tools/list
: Lists available tools and their schemas.tools/call
: Executes a tool with provided arguments.Clone the repository:
git clone <repository-url>
cd mcp-ruby-skeleton
Make the server script executable:
chmod +x bin/run_server.rb
Run the server directly:
./bin/run_server.rb
Add the following to your Claude Desktop configuration:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"random-number": {
"command": "ruby",
"args": [\
"/Users/bash/src/mcp-ruby-skeleton/bin/run_server.rb"\
]
}
}
}
Replace the path with the absolute path to your run_server.rb
file. Restart Claude Desktop and try a prompt like "Generate a random number between 1 and 50."
Claude app logs related to MCP servers are available at:
~/Library/Logs/Claude/mcp*.log
%APPDATA%\Claude\logs\mcp*.log
To view the logs in real-time:
# On macOS
tail -f ~/Library/Logs/Claude/mcp*.log
# On Windows
type "%APPDATA%\Claude\logs\mcp*.log"
Modify the RandomNumberServer
class to add new tools:
def setup_tools
# Existing random number tool
random_number_tool = MCP::Tool.new(
"get-random-number",
"Generate a random number between 1 and the specified maximum value",
{
type: "object",
properties: {
max: {
type: "integer",
description: "Maximum value for the random number (defaults to 100 if not specified)"
}
}
}
) do |args|
max = (args["max"] || 100).to_i
max = 100 if max <= 0
rand(1..max)
end
@server.register_tool(random_number_tool)
# Add your new tool here
new_tool = MCP::Tool.new(
"tool-name",
"Tool description",
{
type: "object",
properties: {
# Tool parameters
}
}
) do |args|
# Tool implementation
end
@server.register_tool(new_tool)
end
Implement unit tests, integration tests, and end-to-end tests to verify:
Improve server robustness by:
This project is an experimental Ruby implementation of the Model Context Protocol (MCP), designed as a starter framework for integrating LLMs like Claude with external tools.
No releases published
No packages published