# Teaching an LLM New Tricks #### [Gannon McGibbon](https://gannon.io/) Note: - For WRUG August 2025 --- ## 👋 Hi, I'm Gannon  - Works at Shopify - Committer on Ruby on Rails - Organizes Winnipeg.rb Note: - Intro --- ## LLM?  Note: - How many of you know what an LLM is? - How many of you have used one? - How many of you have use them daily? --- ## What is an LLM? A Large Language Model (LLM) is a type of AI that uses deep learning to understand and generate human language. Note: - Large Language Models are a kind of Artifical Intelligence - that understands and generates human language --- ## What is an LLM? - ChatGPT - Claude - Gemini Note: - Some examples of LLMs are - ChatGPT from OpenAI - Claude from Anthropic - Gemini from Google --- ## AI is Everywhere # 🌎 Note: - LLMs are everywhere these days - It has seeped into my day-to-day work - I have mixed feelings --- ## AI is Everywhere  Note: - I used it to help write this presentation - And to ocasionally provide visuals - Some better than others --- ## AI is Everywhere  Note: - I see the value of it - It can do amazing things - But I worry about how it is being used --- ## The future I wanted - Automation of repetitive tasks - Code autocompletion - A competent pair programmer Note: - I thought AI could solve job pain points - Automate repetitive tasks - Code autocompletion - A knowledgable pair programmer --- ## The future I got - Vibe coding - Intern level code competence - AI-generated hallucinations Note: - But what we have today is different - Vibe coding - Intern level autocomplete and code reviews - AI-generated hallucinations --- ## What people say  Note: - I've heard a lot of people say negative things about AI - It makes our brains slower - It makes development slower - It is bad for the environment --- ## What people say  Note: - This all sounds pretty bad - But is it true? --- ## What studies say  Note: - A study from MIT found - ChatGPT can impact critical thinking - At least in the context of essay writing --- ## What studies say  Note: - Another study from MIT found - The AI tools developers use today - Make us slower, not faster --- ## What studies say  Note: - An article from Bloomberg found - AI data centers are causing problems - In the US power grid ---  Note: - I might be being too negative - I'm sure we used to feel this way about calculators - Or spell check - Or even bitcoin ---  Note: - Maybe I'm just out of touch - It is easy to focus on the negatives - But there are positives too --- ## AI Assistants  Note: - Big tech companies all offer AI assistants - If you can get past spying - They're useful for timers, weather, etc. --- ## AI Assistants  Note: - Apple has Siri - But there are other offerings too - As you probably know --- ## Reading and Writing  Note: - Modern LLMs are pretty good at reading/writing - Many people use it to summarize text or write for them - Though you can often tell if text is AI generated --- ## Reading and Writing  Note: - Here I'm asking it to summarize the Ruby Wikipedia page - It seems to do a good job --- ## Search  Note: - LLMs are also pretty good at search - They can use Retreival Augmented Generation - To learn about specific data sources --- ## Search  Note: - I don't have a lot of experience with chatbots - But Intercom's chatbot is pretty good - I asked it how to make API calls with Ruby --- ## Search  Note: - It pointed me to the Rails gem - Not the Ruby gem - But it was still helpful --- ## Coding  Note: - I bashed AI generated code earlier but - Editors like Cursor are interesting - You can tell an LLM to do your job for you - But it probably won't do it well. Yet. --- ## Coding  Note: - Other editors are catching up - VS Code has Copilot - JetBrains has Junie --- ## The LLM Client  Note: - We usually use some kind of client - To interact with an LLM - This can be a webpage, mobile app, your editor, etc. --- ## The LLM Client  Note: - One that we're all familiar with - Is the ChatGPT website - It provides a front end with a chat interface --- ## The LLM Client  Note: - VS Code also has an LLM client built in - I'll use this later in the demo - Let's look at how it works under the hood --- ## The LLM Client ```mermaid graph LR Developer -- Chats --> Client Client -- Queries --> LLM LLM -- Responds --> Client ``` Note: - Explain diagram --- ## The LLM Client  Note: - Often you can choose the LLM to query - LLMs are often referred to as Agents - But they are just a target LLM version - Like Calude 3.5 or GPT 4 --- ## The LLM Client  Note: - It can also manage conversations - Which allows you talk to multiple models - And keep the context in threads --- ## New Skills  Note: - We know roughly how clients talk to LLMs - How do we teach them new skills? --- ## New Skills  Note: - Alexa can play music from Spotify - Siri can send messages on your behalf - Can I teach ChatGPT to talk to a Rails Application? --- ## Model Context Protocol (MCP)  Note: - Yes, you can - And that's what I'd like to talk about today - Model Context Protocol (MCP) provides a standard way - For clients to extend the capabilities of LLMs --- ## Model Context Protocol (MCP) ```mermaid graph LR Client <-- Registers --> MCPServer Client -- Queries --> MCPServer MCPServer -- Responds --> Client ``` Note: - It works like this - Explain diagram --- ## Model Context Protocol (MCP) ```mermaid sequenceDiagram Client ->> Server: Initialize Request activate Server Server -->> Client: Initialize Response Server -->> Client: Initialized Notification deactivate Server ``` Note: - When registering a new MCP Server - The client starts a handshake - Explain diagram --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2025-06-18", "capabilities": { "sampling": {}, }, "clientInfo": { "name": "client", "title": "Client", "version": "0.0.1" } } } ``` Note: - Requests, responses, and notifications - Are all sent as JSON RPC - This is what the initialize request looks like - Explain JSON --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "result": { "protocolVersion": "2025-06-18", "capabilities": { "tools": { "listChanged": true } }, "serverInfo": { "name": "server", "title": "Server", "version": "0.0.1" } } } ``` Note: - The initialize response looks similar - Explain JSON --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "method": "notifications/initialized" } ``` Note: - Notifications looks like this - And are sent through HTTP streaming - Which is basically a long-lived HTTP request --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "method": "notifications/initialized" } ``` Note: - When the initialized notification is received - The handshsake is done - The client and server can now communicate --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} } ``` Note: - The client then usually asks the server - For a list of tools it has - Based on stated capabilities - Tools are basically remote functions --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "test", "description": "Test", "inputSchema": { "type": "object", "properties": { "name": { "type": "string", "description": "Name"} }, "required": ["name"] } } ] } } ``` Note: - The server responds with a list of tools - Here we have a test tool - With a name parameter --- ## Model Context Protocol (MCP) ```mermaid graph LR Developer -- Chats --> Client Client <-- Registered --> MCPServer Client -- Queries with Tools --> LLM LLM -- Responds --> Client ``` Note: - At this point the client knows - What the server can do - Explain diagram --- ## Model Context Protocol (MCP) ```json { "model": "gpt-5", "input": "Use the test tool." "tools": [{ "type": "function", "name": "test", "description": "Test", "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "Name" }, }, "required": ["name"], "additionalProperties": false }, "strict": true }] } ``` Note: - And that would look like this - Explain JSON --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name":"test", "arguments": { "name":"Gannon" } } } ``` Note: - If the LLM wishes - The client can then call a tool - By sending a tools/call request - With the name of the tool and arguments --- ## Model Context Protocol (MCP) ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [{ "type": "text", "text": "Hello from MCP, Gannon" }], "isError": false } } ``` Note: - The server responds with a result with content - The content is the return from the tool --- ## Model Context Protocol (MCP) - Tools - Resources - Prompts Note: - Tools are just one server capability - There's also prompts and resources - Resources are files hosted on the server - Prompts are basically templated queries --- ## Model Context Protocol (MCP) - Roots - Sampling - Elicitation Note: - Clients also have capabilities too - I'm focusing more on MCP servers - So you can read more about that in the MCP spec --- ## Model Context Protocol (MCP) ```mermaid sequenceDiagram activate Server Client -->> Server: Disconnect deactivate Server ``` Note: - When the client no longer wishes to use the server - It can simply close the connection - No disconnect request is needed --- ## Model Context Protocol (MCP) - HTTP - STDIO Note: - HTTP is just a transport method - You can also use MCP servers through STDIO - Anything that you can send and receive JSON through --- ## Demo  Note: - Demo - Building a basic MCP server - VSCode and Ruby - Using Copilot --- ## API Clients  Note: - Not all of us are Rubyists - There's a standard set of SDKs - Ruby's SDK isn't quite production ready, but other clients likely are --- ## Be Careful  Note: - LLMs are really cool - But they are a developing technology - Error prone - You shouldn't trust them to do the right thing --- ## Be Careful  Note: - They're getting better - They show a lot of promise - They might just take our jobs - But not anytime soon IMO --- ## Be Careful  Note: - I've heard a sentiment that I agree with - LLMs are like interns - They can do basic work --- ## Be Careful  Note: - You need to hold their hand a lot - They get a lot of things wrong - But they also might surpise you --- ## Thanks! --- ## Resources - https://modelcontextprotocol.io/ - https://platform.openai.com/docs/overview - https://github.com/modelcontextprotocol/ruby-sdk - https://github.com/yjacquin/fast-mcp