Skip to content

How MCP connects AI to tools

You are in a planning meeting. Someone on the testing team says they want to set up Playwright MCP. A manager frowns. "Why do we need Playwright MCP? We already have Playwright." Nobody in the room is quite sure.

It is a fair question. Playwright already works. So what does MCP add?

By the end of this lesson you can answer in two sentences. Playwright already opens pages, clicks buttons, and runs our tests. Playwright MCP gives a compatible AI app a standard way to ask Playwright to do that browser work and use the result to decide what to do next.

That standard way is the Model Context Protocol, or MCP. This lesson covers the problem it solves, the three roles in every MCP connection, the three kinds of things a server can offer, and what to ask before you connect one.

The previous lesson walked through function calling in three stages. First, the model picks a function and fills in its arguments. Second, ordinary code runs the function. Third, the model turns the result into a natural-language answer.

That lesson left a question open. Where does the function live, and who wires it up? Without a standard, the answer was simple and costly: each app often did its own wiring.

The Stanford lecturer names the cost directly. Each model could expect tools described in its own custom way, so the same tool might be built again for every model. That repeated work is exactly what you want to avoid.

Imagine a team with a calendar tool. To reach five AI apps, they might write five different connectors. Now multiply that by every tool and every app. That is the problem MCP addresses.

The lecturer describes MCP as a standard that came from the Anthropic team, meant to end that repeated work. It is a protocol, which means an agreed set of rules for how two pieces of software talk to each other.

The official MCP documentation describes it as an open-source standard that links AI apps with the systems outside them. It offers a comparison: "Think of MCP like a USB-C port for AI applications." The point of the comparison is the shared shape. A device maker builds one USB-C port, and any cable that follows the standard fits. A tool maker can build one MCP server that several compatible AI apps can use. Each app handles how it presents the available tools to its model.

The documentation says many apps support MCP, including AI assistants and developer tools from several companies. That is what makes it a standard rather than a feature of one product.

MCP is about the connection, not the model. The documentation says that it covers the exchange of context, and does not dictate how an AI app uses its model. MCP does not make a model smarter. It makes tools easier to reach.

Every MCP connection has three roles, and each one is a plain job.

The host is the AI application you actually use. It might be a chat assistant, a code editor with AI features, or a company chatbot. The host is where the conversation with the model happens.

The server is a program that offers capabilities to AI apps. The lecturer describes it as the program that serves the tools. It is often built by whoever knows the underlying system, such as the company that makes it.

The client lives inside the host. It holds the connection to one server. The host creates one client for each server it connects to, so three servers means three clients. A server can run on your own machine, or somewhere on the internet.

Here is how the three roles fit together, following the documentation. The client asks the server which tools it has. The host hands that list to the model. The model decides to use one, exactly like Stage 1 in the previous lesson. The client sends that call to the server. The server runs it and sends back the result. The result goes into the conversation, and the model writes its answer.

Notice what moved. In the previous lesson, Stage 2 was code that the app's own developer wrote. With MCP, Stage 2 can happen inside a server that someone else built, reached through a standard plug. The model's job does not change. The wiring does.

MCP does not turn an app into an agent on its own. One call through an MCP server is still a single function call. What changes the picture is the model calling tools again and again, which is the next lesson.

What a server offers: tools, resources, prompts

Section titled “What a server offers: tools, resources, prompts”

A server can offer three kinds of things. The lecturer and the documentation name the same three.

Tools are actions: functions an AI app can call, such as searching for flights or sending a message. The model decides when to use a tool, based on what the user asked.

Resources are data that helps complete the task, such as file contents or database records. They are read-only. The app decides how to use them. It might pass everything to the model, or pick out only the relevant parts.

Prompts are reusable templates, such as a ready-made request to plan a vacation. Typically, you choose one in the app, and the app uses it to prepare a request for the model.

That gives you a clean way to tell the three apart. Ask who is in control. The model chooses tools. The app manages resources. The user picks prompts.

The lecturer's example: a poetry book for the teddy bear

Section titled “The lecturer's example: a poetry book for the teddy bear”

The lecture keeps a running character, a teddy bear who loves to read poetry. Suppose an AI app wants to recommend the bear a poetry book.

The host is the AI chat app. The server, the lecturer suggests, would probably be built by a book provider, because they are the experts at serving that kind of content. Its tools might find books or recommend them. Its prompts might be templates that show how to look up a particular title, or how to recommend one to suit a reader's taste. Its resources might be the bear's personal collection, or popular books that people buy.

The model never needs to know how the book provider's catalog works inside. As in the previous lesson, it sees the description, not the implementation.

Worked illustration: why Playwright MCP exists

Section titled “Worked illustration: why Playwright MCP exists”

Back to the meeting.

Playwright is browser automation software. Its own site puts it this way: "Playwright enables reliable web automation for testing, scripting, and AI agents." Programmers drive it with code, in languages such as TypeScript and Python.

The model can request a browser action. In the example below, Playwright opens the page and performs the click.

Playwright MCP is an MCP server built on Playwright. Its official description says it provides browser automation through Playwright, and lets models work with web pages using what it calls structured accessibility snapshots, rather than screenshots. In plain words, by default the model gets a structured text description of the page rather than a picture of it. Screenshots are available too, but the snapshot is the usual way of working.

Walk through one step.

The host connects to the Playwright MCP server. The client asks for the list of tools. Among them are tools to go to a web address, to take a snapshot of the page, and to click on part of the page.

A user asks the AI to open the Playwright website and follow its Get started link. The model picks the tool for going to a web address and fills in the address. The client sends the call to the server. You never need to write a call like this yourself; it is just what one looks like.

{
"name": "browser_navigate",
"arguments": { "url": "https://playwright.dev" }
}

Playwright opens the page in a real browser. The result that comes back can already include a snapshot of the page. The snapshot is text. It describes what is on the page, and gives each element a reference the model can point to. One line of it might look like this. The exact reference will differ from one run to the next.

- link "Get started" [ref=e7]

The model reads the snapshot and finds that line. It asks for a click, using the reference the snapshot gave for that link. The client sends that request to the server, and Playwright clicks the link.

Be precise about who does what. MCP is the connection: the agreed way to list tools, send calls, and return results. Playwright does the browser work. The model chooses the next step and reads the outcome. None of the three can do the others' jobs.

So the answer to the manager has two parts. Playwright already existed for people who write code. Playwright MCP puts the standard plug on it, so an AI app can use it too. And the Playwright project publishes that server itself. That is the book provider idea from the lecture: the people who make a tool are the ones who serve it.

Nothing about the team's existing Playwright scripts changes. They keep running the checks they were written for. Playwright MCP adds something different. A person can ask an AI app, in plain words, to work through a page, and the model takes it one step at a time, reading each snapshot before it picks the next action.

At the time of writing, the Playwright MCP documentation also points coding agents to a separate command-line route, which it says uses less of the model's limited context. It keeps MCP for longer, more exploratory browser sessions. MCP is a standard way to connect a tool. It is not the only way.

  • Connecting a server changes what the AI can reach and do. An AI app works with what is in the conversation, plus any tools its own developers built in. Connect a server, and the app can read new data and take new actions. The documentation's examples include calendars, note-taking workspaces, databases, and design files.
  • One server can work across many apps. Because MCP is an open standard, a tool maker can build one server that several compatible hosts can use. When a company announces an MCP server, it is saying its system now has the standard plug.
  • Asking what a server offers tells you a lot. Tools, resources, prompts. That one question tells you what the AI will be able to do, what it will be able to see, and what ready-made templates you get.

An MCP server is software. When you connect one, you are trusting it.

The MCP specification is direct about this. It says: "Tools represent arbitrary code execution and must be treated with appropriate caution." It also says the host app must get your explicit permission before it runs any tool, and that you should understand what a tool does before you allow it. In practice, apps can also let you approve some actions ahead of time, which is why it pays to check your settings. And it warns that a tool's own description of what it does should not be trusted, unless the server it comes from is trusted.

That last point connects to the previous lesson. The model decides what to call based on tool descriptions. Those descriptions are text that a server supplies. Tool results can also contain text that influences the model's next decision. Both go into the model's context. A server you do not trust is a source of text you do not control, flowing into the model's decisions.

The specification also notes that MCP itself cannot enforce these principles. The apps that use MCP are expected to build the consent screens and permission settings. And the MCP security guidance notes that a server installed on your own machine may have direct access to your system.

The Playwright MCP documentation makes the same point in one line: "Playwright MCP is not a security boundary." Even its options for limiting which sites the browser may visit are not, by its own account, a security boundary.

So before you connect a server, ask four questions.

  1. Who built it, and do I trust them?
  2. What can it reach: files, accounts, a browser, the internet?
  3. Which of its tools can change things, rather than only read?
  4. Will my AI app ask me before each action, or act on its own?

The next lesson, on agent loops, shows why these questions get sharper. There, the model calls tools again and again, each step shaped by the last result. The next lesson also covers prompt injection, an attack that hides instructions inside text the model reads.

Thinking MCP is a tool. It is not. MCP is the connection standard. Playwright, a database, a calendar: those are the systems. A server wraps a system and offers its actions as tools.

Thinking the model talks to the server directly. It does not. The model can read the page snapshot and request a click. The client inside the host holds the connection and sends that request to the server, and Playwright clicks the element. Then the client brings back the result.

Thinking MCP belongs to one product. The lecturer notes that it came from the Anthropic team. The documentation describes it as an open-source standard, supported by apps from several companies. What you learn about it carries across apps.

Thinking more servers is always better. Each server is more software with access to something. Connect what you need, from builders you trust.

  • MCP, the Model Context Protocol, is a standard plug between AI apps and outside tools and data. It replaces wiring each tool into each app separately.
  • Three roles. The host is the AI app. The server offers capabilities. The client, inside the host, holds one connection to one server.
  • Three offerings. Tools are actions the model chooses. Resources are data the app manages. Prompts are templates the user picks.
  • Playwright MCP is Playwright with the standard plug. Playwright does the browser work. MCP carries the requests and results. The model decides the next step.
  • A server is software you trust. Ask who built it, what it can reach, and whether your app asks you before it acts.

MCP does not make the model smarter. It makes tools reachable.
The model asks, the client carries, the server acts.
Plug in only what you trust.