RubAgent is the simplest coding agent that can be created. It is a minimal Ruby project for learning and experimentation with Large Language Models (LLMs) using the RubyLLM gem and Ollama. This repository is not intended for production use, but rather as a playground to explore how to connect Ruby applications to AI APIs and handle responses.
This project serves as a hands-on introduction to integrating Ruby with LLM services. It demonstrates basic usage patterns, error handling, and configuration, making it a useful reference for anyone interested in experimenting with AI in Ruby.
- Connects to LLM APIs via RubyLLM and Ollama
- Basic error handling for API responses
- Simple, readable code structure
- Can read, write, and execute files within a specified directory
- NEW: Configurable MCP (Model Context Protocol) server support
- Auto-starting MCP servers with JSON configuration
- Integration of MCP tools alongside existing local tools
- Install Ollama by following the instructions at Ollama's official site.
- Download the model you want to use, for example:
ollama pull gpt-oss:20bNote: the model must support tool calling.
- Ensure Ollama is running locally:
ollama serveNote: code assumes ollama is running on
http://localhost:11434/
- Install dependencies:
bundle install
- Update the configuration section in
main.rbwith your preferences. - (Optional) Configure MCP servers by editing
mcp_servers.json(see MCP Configuration section below). - Run the main script:
ruby main.rb
RubAgent now supports configurable MCP (Model Context Protocol) servers that can provide additional tools to the agent. MCP servers are configured using a JSON file following Claude's configuration conventions.
Create or edit mcp_servers.json in the project root:
{
"mcp_servers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/directory"],
"env": {}
},
{
"name": "git",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git", "--repository", "/path/to/your/repo"],
"env": {}
}
]
}- Filesystem Server: Provides file system access tools
- Git Server: Provides Git repository management tools
- Custom Servers: You can add any MCP-compatible server
- Node.js must be installed for MCP servers that use
npx - MCP servers will be automatically started when the agent runs
- Servers are checked for existing processes to avoid duplicates
- MCP tools are integrated alongside existing local tools
- If MCP server connection fails, the agent continues with local tools only
- Server processes are managed automatically
This is a learning project. The code is experimental and may not follow best practices for production applications.
MIT License
Note: This readme was generated with the help of an AI.