From the course: Unboxing AI: Build a Remote MCP Server from Zero to Deployed with OAuth

Real-world examples of MCP in Claude

- The easiest way to make sense of this is to see an example. Here is Claude. In Claude, I've installed two new MCP servers. One that's called weather that I built myself, that has three tools. get_current_weather, get_forecast, and get_hourly_analysis, and one that's called hue, which I found that someone else built that allows Claude to interact with hue. The lights in my room. Let me show you how this works. In Claude, I'll just say, "What's the weather like in Burnaby right now?" Now, when I send off this request, instead of Claude doing a web search for this information or just hallucinating some information about the weather or giving me general statistics about the weather, it'll say, "Hey, there's some MCP server available to me here, so I'm going to use it." See, here it says get_current_weather, request name Burnaby. This is Claude seeing that I made a request for weather, that it has tools available that say something about getting information about the weather. And then, it requests permission from me, the user, to use this tool. And I as a user can now look at what's happening here. So, it says Claude wants to use this tool. The function it wants is called get_current_weather, and the information that's being passed in is Burnaby, British Columbia, Canada. Now, I can review this information. That's all I can see. And then I'll just say Allow always or Allow once. So, Allow always means for the rest of this particular chat, it'll just allow this to run. If I say Allow once, it'll just allow it for this particular instance of the chat. And if I say Decline, it just won't be able to use the service and it'll fall back on something else. So, I'll say Allow once. The system now sends the necessary information to the MCP server. The MCP server in this case goes to Open-Meteo which is an open source weather API, and retrieves a bunch of information. And then, when that information is returned, the server summarizes the information for me. So, here you can see the response I got. There's a bunch of weather information packaged in it. And this weather information isn't everything that is returned from the API. It is what the MCP server defined as relevant to be turned to the API. So, when I built this MCP server, I thought carefully about which pieces of information would I find useful for the types of questions I would ask in Claude about the weather? And then, I only include those pieces of information in the response from the weather service. So, instead of building an API connection where I'm just sending a request to an API and all the weather data comes back, which is just a massive amount of data, I say, "Send a request, figure out where the location and time is, and then only get these pieces of information back." That's what I get in return. That's neat, right? Well, let's see something a little more in the real world practical. You'll notice behind me there's like a blue sheen, right? This blue light behind the screen here. That's a hue bulb. So, I can go in here because I have this hue tool. I'll say, "What lights are currently on?" It's a weird question to ask, right? But because I have hue installed and one of the tools inside describes that it's, that it can find lights. It says, "Hey, do you want to use get-lights?" I say Allow once. It'll now give me a list of all the available lights. So, see here. We have dining room, Morten's office, bedroom. And let's see, hue color spot 1. I think it's this one, desk color light. So, I'm going to type in here, "change desk color light to red." So, you see it's blue right now? Yeah. I will run this command. And if everything works right, it'll say, "Do you want to change the desk color light from, turn it on and set it to red?" Yes, I'll allow once. Tada! Do you see why this is important now? How I am now able to control the world using my AI chat bot? And start thinking what is possible when this is possible? And then realize that MCP is a protocol that can be connected to anything. Meaning you can do all sorts of weird things with it. So, here's how this works. My MCP client, in this case, Claude, connects to the MCP server. The MCP server contains within it tools and resources, and possibly prompts and elicitation and other things. And in this case, the tool that is in the MCP server is a location tool that figures out, when I say Burnaby, what does that actually mean? And then, it surfaces information about those locations that can then be passed to the weather server. Then if I say, "What's the weather like right now?" I use the get current_function that goes and gets current weather. If I say what, "What is the weather going to be like a week from now?" Then it'll use the get_forecast function, which receives date information. If I say, "What was the weather like on Friday last week?" It'll go back into history and send a different command. And if I say get_stats, it'll get more stats than normal because then we can draw graphs and stuff. And then, the MCP server connects to the external service through an API. This is what I mean when I say it's a middle worker. This has some significant implications because it means if any service has an ability to connect to it like an API or is running on your current system, then you can build an MCP server that allows a chat agent to talk to that system, which makes really interesting things possible.

Contents