Rails World 2026: I Didn't Get MCP, So I Built My Way Through It (Enrique Mogollan) Video: https://www.youtube.com/watch?v=km2hEx-HEME Talk page: https://www.rubyevents.org/talks/i-didn-t-get-mcp-so-i-built-my-way-through-it Unedited machine transcript, generated with Whisper. It contains recognition errors (names, technical terms). Check the video before quoting. ---- - Hello. Who here has built an MCP server? All right, there are a few hands. Who here has built or saw how the run messages between a server and a client go? All right, there are a few people. But after today, everyone in this audience will have seen that. The message is going back and forth between the server and our client. And MCP a year ago was everywhere. It was in my editor, it was in the harness, it was in the chat. And I could give you the one line definition. is how an agent pulls data from an external source into the context window without you having to type it or stuff it into the prompt. But I really didn't get exactly how it worked. I wasn't sure how it was beneficial for me. So I started doing some things, experiments, ended up building an MCP inspector. And I'm going to tell you about it a little bit. Again, my name is Enrique. I'm a software engineer at Handshake. And Handshake, we help students and young people land their first job. And we're also helping the foundation and labs to train their models with the network of students and people that we have. I am also from Mexico. I'm originally from a town called San Miguel de Allende. It's in the heart of Mexico. Thank you. It's one of the places that was named by the travel magazine of one of the best places to live, best places to travel. And it's cobblestone street, colonial architecture. But something that the magazines don't mention a lot is that semi-desertic area that surrounds the town. And after the semi-desertic area, there's some mountains. youth in the weekends over there hiking and camping because i was a boy scout and one of the other things that i enjoyed doing over there was this thing called navigational challenges where they give you a map they put you in a point and then they tell you go there find your place and you have to follow the map no gps no phone and not because it was written it was because it didn't exist back then. And the navigational challenges during the day were easy, more or less easy. You just have to find a hill, a church, a radio tower, that weird tree that everyone uses as a marker. And then once you find a landmark, you start walking in that direction or you move your map to match it. of doing navigational challenges during the night. And that was a little bit harder. It was tricky. I get lost constantly. And the challenge was which cluster of dots in the sky map to the ones that are in my map. And we didn't get a compass during the night. We just had our constellation map and the landmark map. I know this is a little bit random, but that feeling of having to match something that are dots with symbols on a page is pretty much what MCP Inspector looks like. That's pretty much the same feeling that I got when I saw the first round message going through. All right, so a year ago, I built an MCP Inspector in Ruby. There is one in nodes that is maintained by Anthropic, but I wanted to build one in Ruby just to be able to see what was this MCP thing. And last year at Ruby, I gave a talk about this. And I'm not gonna give you the same talk, but I'm gonna tell you two important things. One is that there are two transfer methods. The first one is STDO or standard input output. And that works very well for local development or local MCP servers when you can just connect them directly your local servers. And the other one is streamable HTTP, which is a combination of both standard HTTP and stream from HTTP. In the past, this used to be HTTP as server-side event, but that has been deprecated in favor of streamable HTTP. The second thing that you need to know about the inspector or MCP is that all the messages are in JSON-RPC. So every conversation in a way has the same shape. And I'm going to show you a demo of the MCP inspector. First, we're going to look at how we set up the MCP server. Then we're going to list the tools. Remember, for MCP, there are tools, resources, and prompts. And finally, we're going to execute a call. setup here i'm showing you the list this is the file system mcp server so it has a bunch of things and i'm here i'm actually executing one of the requests and as you can see at the top there's pre-json at the bottom is the raw json and now everyone in the audience has seen raw json going back and forth between an mcp server and a client initialize, then you can list tools, resources, and prompts, and then you can execute or call each of these. But one thing I want to highlight is that the MCP server for file system has a bunch of things, a long list, and each of these items has a schema, and the schema is also JSON or how you can use the tool. actually execute the tool, there's a lot of headers that come back from the JSON, the JSON response. All right, so let's go back for a moment to Mexico and the navigational challenges, because I told you during the day, it was kind of easy, but during the night, it was more complicated because all the things that you have is just points in the sky. Actually, points in the sky is not a bad representation of what is happening with LLM models when they use transformers in the background. Because what they do is they take a token and make it a vector, a multidimensional vector that uses thousands of dimensions. But we, as humans, it's very difficult for us to imagine how this vector is represented dimensions so today we're going to flatten this vector and we're going to put it in two dimensions and because it's three dimensions we're just going to put it into a little tiny dot and today because it's a special day because it's rails work we're going to make it a star so basically it's a vector token is a vector or star in the sky and then when you group stars, when you put them together, it's token that have similarities between them. For example, ocean and tide are together, but ocean and tax return are completely separated. And this is the mechanism. This distance has some meaning, and this is the mechanism that is used to be able to determine the semantics and significance of things and this is how you can find an email by vaguely remembering something random from 10 years ago and then when you put it together there's although there's like infinite sky there's only a few portion of the sky that you can see our time so that's your context window and then when we try to align the stars to match a specific constellation that's our attention. And that is important for us because we want to find our path. And in order to be able to find our path, we have to find the way on Merak to be able to find the Polaris star, find north. So here's our map, stars, our tokens, the sky is the context window, and constellations lines our attention. And MCP, It's how you put more stars into the sky. All right, so let's go back to a problem in real life. Here, I am running the test, or I'm asking an agent to run the test for Ruby event. I just downloaded Ruby events, run bundle install, and told the agent, can you run the test? And as you can see, there's a lot of things that are happening, sometimes it shows me the error one time, or it can also show me the warnings of the things that are happening, the deprecations. So it's a lot of things that are happening in one request. So this happened to me when I was upgrading Rails at work. I was constantly running the test suite 50 times a day. And one of the things that happened to me was that every time I run the test, It took eight seconds for my server to start, just like Rails to boot to be able to run a spec. And then all the context that started coming back is like stars that were adding and adding into my context. And I call it light pollution that prevents me for me to see the stars in the sky. But that doesn't mean that the stars are not there. The stars are there. lost my ability to find them. So I started questioning myself, do we actually need all these contexts, all these data into the context? And I think the answer is no. We don't need all the data. We just need the portion that is important to us. So I started working on something that I call Quatepec. And Quatepec is an MCP server, and this is not a performance but it's an MCP server that is helping me do my work faster. And it's the same protocol that we watch in the inspectors, same tools, resources, but the difference is what we get back from the response. So how does it work? So it works by creating a sidecar process and it creates a warm Rails version of the My Rails process. talks to this Quatepex server and it tells it, oh, can you run the test? Oh, can you give me the routes for this? Oh, can you tell me about the model user? And instead of like taking eight seconds to boot Rails, it just takes milliseconds. And how does it look in the inspector? Here I have seven tools, only seven tools. The first one is Rails Spectrum. And I think this is the most important. And the parameters is just like which test you want to execute. And after we execute it, we get just a small little portion of JSON. So let me show you how it runs in an agent. Here I'm telling the agent to run the same similar test in the Ruby events app. and it's thinking, it calls quite the peg. And I'm gonna expand the call there. And as you can see, it's just a small JSON. And because it's very small, a very well formatted, Cloud determined that the best way for me to see the data was to build a table. I didn't ask it to build a table. It just did it because the JSON was formatted in a right way. All right. how does MCP server for Quatepec work? Here, I'm showing you the definition of the tool. It's called Rails spec run. And basically here, I'm calling a worker manager to run the spec. And inside run the spec, there is a call to dispatch, and dispatch calls lock synchronize. And this lock is to be able to use work threes, so we can use multiple times Quatepec. Because every time you create a new process in Quatepec with Quatepec for Rails, it will duplicate the database connection. So each process gets its own database connection. But one thing that I want you to notice is that here it says client spawn. And this is because I work on a Mac computer and my computer is the preferred method to start a new server or new process is with spawn. spawn is very slow it's as slow as using just being rails directly so instead of using spawn I'd switch it to use fork and at the top the orange line is being rails it's the same as a spawn but when I switch to fork is when I started to get performance gains now I was not satisfied to just like being faster I also wanted to be better and more token efficient. So, over different versions of the gem, I was able to reduce the token consumption by 90%. And this is basically just adjusting the JSON headers or not sending the full path of the error and just sending which test pass, which test fail. Just trying making engineering work. All right. advantage of sub-agents. And I was successful. My original idea was to include the skill to tell it to always use Quatepec with a sub-agent. And that works, but it has a caveat. And the caveat is that, yes, you save tokens on your main context window. But on the other hand, every time you spawn a sub-agent, you have to do some setup. And that setup is going to end up burning more tokens at the end. So if you don't have unlimited tokens, it's better if you don't use sub-agents. And for me, that was interesting. Something that I didn't expect it to find. All right, so one last graph of how it behaves. So models and routes, it's just basically instantaneous. You can talk to Quaterpac to get data from Rails. And then when you try to run the spec still faster, than just being Rails. And yes, the main tools that are available is the spec run that is mini test compatible, Rails model, and Rails route to your query. And you can also include your Rails engines if you have ones. But one thing that I wanted to make sure is that this has no eval, no console, no raw SQL. You cannot start a console from Coatepec. It's just for development. It's not for debugging. And one thing I want to mention is why the name of the gem is Coatepec. Well, in Mexico, there is the state of Veracruz. And in Veracruz, there is this place called Coatepec. It's up in the mountains. And it has one of my favorite coffees. So I was just drinking coffee when I thought about the gem. All right, so we're gonna go back to inspector, but it's not the Ruby inspector. This is the node inspector, the node MCP inspector. And I wanna show you something that is different, something that is interesting, because now they ship something called MCP apps. And one thing that I wanna highlight is that it has like a new thing called UI. So basically what MCP apps or like the future of MCP based on this official first extension is a tool that tells you that it's something, an interface available. And when the interface is available, it sends you back an HTML that you can put inside an iframe. And this iframe will contain the HTML, the styles, and it will contain JavaScript. And this iframe will have access to all the tools that are available in the MCP server. So, you know, another way to think about it is you get the entire constellation back. You don't get just one star. You get everything. It's basically that their MCP apps is giving you a map with augmented reality that you can just put in the put in the sky and it will tell you oh yeah this is this is the direction this is where you want to go so here I'm going to show you an example the good and cold valley card is an iframe and every time I modify the iframe is sending data to the MCP server and the MCP server is even sending back an animation and I'm just gonna play it one more time because I want to highlight that these cards of cold valley is the mcp app this is not coming from rails this is an mcp app although i'm running it in a rails application i'm just embedding something that's coming from mcp and how i'm doing that just basically setting up my iframe allowing scripts and then i have an mcp client and then after the mcp client is set up i i call the tool get coffee place card. And then inside this, there is a resource that comes from the text. So basically, I'm just calling an MCP server. And I know what you're thinking. We have APIs. Why do we need this? Or we can access database directly. Well, MCP is built for agents. So one of the advantages of using MCP apps, for example, is that you can start talking with an and it will do something similar. Allow the MCP server to have the same interface here. I can modify the rating. I can modify my favorite beverage. And when I put the five rating stars, I get the animation back. And it's all in the chat window. There's one more thing I would like to share about past. I was terrible at navigation challenges. I got lost. I ran out of water. And I also was a terrible leader in navigation challenges. I got my team lost. I led them through the hardest part multiple times. But eventually I got better. I even learned trigonometry to be able to read maps and be able to what was happening and how long do we have to walk and i think that the same skills that i used back then are the same skills that have led me to this stage today it is curiosity and my willingness to learn from my mistakes it is my curiosity because we saw that i was curious about the mcp inspector and it was my willingness to learn from my mistakes that led me to improve quite the peck. And it's again, my curiosity, what is telling me that I should look into this thing called MCP apps. But now, now you all have this knowledge. Now I am curious to see what you're gonna build with all these tools of all this knowledge that you have. as we saw today, the sky is no longer the limit. And thank you.