Skip to content

lucavgobbi/RubAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RubAgent

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.

Purpose

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.

Features

  • 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

Getting Started

  1. Install Ollama by following the instructions at Ollama's official site.
  2. Download the model you want to use, for example:
ollama pull gpt-oss:20b

Note: the model must support tool calling.

  1. Ensure Ollama is running locally:
ollama serve

Note: code assumes ollama is running on http://localhost:11434/

  1. Install dependencies:
    bundle install
  2. Update the configuration section in main.rb with your preferences.
  3. (Optional) Configure MCP servers by editing mcp_servers.json (see MCP Configuration section below).
  4. Run the main script:
    ruby main.rb

MCP Configuration

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.

Configuration File

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": {}
    }
  ]
}

Available MCP Servers

  • Filesystem Server: Provides file system access tools
  • Git Server: Provides Git repository management tools
  • Custom Servers: You can add any MCP-compatible server

Prerequisites

  • 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

Notes

  • 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

Disclaimer

This is a learning project. The code is experimental and may not follow best practices for production applications.

License

MIT License

Note: This readme was generated with the help of an AI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages