From the course: Model Context Protocol (MCP) for Beginners by Microsoft

MCP core concepts

(bright music) - Hey there. In this chapter, we're diving into the core of model context protocol. If you've ever wondered how AI tools talk to external APIs or databases, then you're in the right place. MCP is what makes that possible and powerful. MCP stands for Model context protocol. It's a standardized way for language models to interact with tools, data sources, and external applications. Think of it like a translator between your AI model and the rest of your digital ecosystem. What makes MCP so special is architecture. It's modular, flexible, and designed to work with any programming language, be it Python, java, JavaScript, .NET, you name it. Here's how it works. MCPS is a client server architecture with three main roles. The host like VS Code or Cloud Desktop is where the user interacts. The client lives inside the host and talks to the server, and then the server provides tools, data, or prompts that the model can use. If you've ever used an AI agent that could look up a document, call the weather API, or generate code templates, it probably used something like MCP under the hood. So let's break it down. Hosts are where user prompts originate. They manage the UI permissions and connect to servers. Clients handle the back and forth. They send prompts to servers and return model responses, and then servers expose resources, tools, and prompts. They're the workhorses doing the actual lifting. Servers can provide three kinds of features. First, there's resources like local files, database entries, or external APIs. There's also prompts, which are templates that guide AI behavior. And then there's tools which are executable functions that models can call like GI products or fetch weather. This is where MCP really shines. Tools are like plugins for your AI. You can define them, control their access, and use them to make your agent both smarter and more helpful. So here's a simple Python example. We define a tool called Get Weather that takes a location and returns a mock forecast in the real world. This might call a weather API and return structure JSON back to the model. Now let's talk about how all these parts communicate. When a user makes a request, the host initiates the connection, the client and server negotiate capabilities. What tools or data are available? The model might request a tool or a resource. The server executes it and sends back the result, and finally, the client integrates everything into the model's response, and the user sees the result. All of this happens using a structured message format called JSON-RPC. It ensures clear, predictable communication between components, whether you're using web sockets, standard input output, or server send events. MCP builds on JSON-RPC with added features like capability negotiation, tool invocation, and result handling, request cancellation and progress tracking, authentication and rate limiting. And most importantly, user consent and control. Security is baked in every tool call. Every data access has to be approved. That means users stay in control of what's shared, what's executed, and what gets exposed to the model. Want to build your own MTP server? Our curriculum provides examples in .NET, Java, Python, and JavaScript. No matter your stack, you can define tools, serve contacts, and participate in the MCP ecosystem. So to recap, MCP is your bridge between AI and the rest of your digital world. It's modular, secure, and built for real world integration. Whether you're debugging in VS Code or building custom agents, MCP helps your models act on the world, not just talk about it. Here's a challenge. Design a tool you'd want to build with MCP. What would it be called? What inputs would it need? What output would it return and how would a model use it? That's it for this chapter. In the next one, we'll discuss security. We'll cover permissions, tool safety, and how to keep your data protected. See you in the next one.

Contents