Ruby Melbourne talk: speed-run on AI and MCP with Ruby
Action Plan
1. Side Intro
Prompt Engineering
- temperature, top-P, top-K
Retrieval-Augmented Generation (RAG)
2. ModelContextProtocol (MCP)
- live 'vibe' code an app and integrate with LLM client
- have some fun
About me
class Friendlyantz
def initialize
@name = 'Anton'
@title = 'Extreme Programmer', 'Software Stuntman'
@hobbies = ['kitesurfing', 'skatebords', 'MTB']
end
def find_more = 'https://friendlyantz.me/'
class Intro::PromptEngineering
temperature
top-K
top-P
end
Temperate (0…1)
0
- predictable, ‘dry’, sober1
- most creative
Start with 0.2
Top K(1…)
max count of words with the highest probabilities. Start with 30
- I.e. `topK = 5`
["wine" (30%), "vino" (25%), "VB" (20%), "vermouth" (15%), "vine" (10%)]
Top P(0..1)
The model sorts all words by probability. It keeps adding words until their cumulative probability exceeds P. good start with 0.95
(i.e. 0.9) ->
["Wine" (20%), "Vino" (20%), "Vinho" (20%), "Wein" (20%), "GrapeJuice" (10%), ...]
Note: Extreme values cancel each other out
"Balanced / coherent results with a touch of creativity"
- temperature of .2,
- top-P of .95,
- top-K of 30
"Especially creative results"
- temperature of .9
- top-P of .99
- top-K of 40.
"Less creative results"
- temperature of .1
- top-P of .9
- top-K of 20.
Retrieval-augmented generation (RAG)
RAG / embeddings are not the final answer, other resources are available in real world
Model Context Protocol (MCP)
great explanation of MCP https://www.youtube.com/watch?v=FLpS7OfD5-s
https://github.com/yjacquin/fast-mcp
Time for…
Vibe coding!
create a simple shopping app that lists some funny vibing products in valid JSON , include 5 example products. make it simple, no need in web server, sinatra, etc, just simple calss. just vibes class. name file `vibes.rb`
add shopping cart functionality that can take quantity
require "json"
class Vibes
def initialize
@products = [
{id: 1, name: "Dancing Cactus", price: 19.99, description: "A cactus that dances to your favorite tunes."},
{id: 2, name: "Vibing Sloth Mug", price: 12.99, description: "A mug with a sloth that vibes with your coffee."},
{id: 3, name: "Mood Ring Lamp", price: 29.99, description: "A lamp that changes colors based on your mood."},
{id: 4, name: "Chill Llama Pillow", price: 24.99, description: "A pillow shaped like a llama for ultimate chill vibes."},
{id: 5, name: "Groovy Disco Ball", price: 34.99, description: "A mini disco ball to bring the groove to your room."}
]
@cart = []
end
def list_products
JSON.pretty_generate({products: @products})
end
def add_to_cart(product_id, quantity)
product = @products.find { |p| p[:id] == product_id }
if product
@cart << {product: product, quantity: quantity}
"Added #{quantity} of '#{product[:name]}' to the cart."
else
"Product not found."
end
end
def view_cart
JSON.pretty_generate(@cart.map do |item|
{
name: item[:product][:name],
quantity: item[:quantity],
total_price: (item[:product][:price] * item[:quantity]).round(2)
}
end)
end
end
VIBES = Vibes.new
require "fast_mcp"
server = FastMcp::Server.new(name: "my-ai-server", version: "1.0.0")
class VibeProducts < FastMcp::Tool
description "List some funny vibing products"
def call
VIBES.list_products
end
end
server.register_tool(VibeProducts)
class AddToCart < FastMcp::Tool
description "Add a product to the cart"
arguments do
required(:product_id).filled(:integer).description("The ID of the product to add")
required(:quantity).filled(:integer).description("The quantity of the product to add")
end
def call(product_id:, quantity:)
VIBES.add_to_cart(product_id.to_i, quantity.to_i)
end
end
server.register_tool(AddToCart)
class ViewCart < FastMcp::Tool
description "View the current shopping cart"
def call
VIBES.view_cart
end
end
server.register_tool(ViewCart)
server.start
Claude Desktop agent claude_desktop_config.json
{
"mcpServers": {
"vibe-mcp": {
"command": "/PATH/ruby/3.4.4/bin/ruby",
"args": [
"/PATH/mcp-vibe/vibes.rb"
]
},
"mp-challenge": {
"command": "/PATH/ruby/3.4.4/bin/ruby",
"args": [
"/PATH/promotions/app/app.rb"
]
}
}
}
chat history https://claude.ai/share/69c174c5-40b1-4f24-9769-583541d71c95 — REFERENCES:
Leave a comment