Sub topic 1
What MCP is and why your application might use it
Prerequisites
This chapter assumes you can read Python with async/await, know what JSON and JSON Schema are, and have called an LLM API from code. You should also know the idea of tool (function) calling: you describe functions to the model, the model asks to call one, and your code runs it and returns the result.
The problem MCP addresses
Without a shared protocol, every tool integration is custom work. If your application needs file access, a database lookup, and a ticket tracker, you write three adapters. Each one defines its own schema, error handling, and process management. If a second application wants the same tools, it repeats the work.
The Model Context Protocol (MCP) is an open protocol that standardizes how an application discovers and calls external capabilities. A tool author writes an MCP server once. Any application that speaks MCP can connect to it, ask what it offers, and call it.
The idea is similar to a standard port. Instead of wiring each application to each tool, both sides implement the same protocol.
What your application gains
- Reuse. You can use servers that others wrote instead of writing adapters.
- Discovery at run time. Your code asks a server for its tools instead of hard-coding them. A server that adds a tool needs no change in your application.
- Schemas included. Each tool arrives with a JSON Schema for its inputs, which maps closely onto the tool format of LLM APIs.
- Process separation. A server runs as its own process, so it can be written in another language and restricted separately.
What MCP does not do
MCP does not call the model, and it does not decide when a tool is used. Your application still owns the conversation with the LLM. It reads the model's tool-call requests and forwards them to the right server. MCP only standardizes the connection between your application and the tools.
When it is worth using
MCP pays off when you want several tools, tools you did not write, or tools shared across applications. For one small function used by one application, a plain Python function passed to the model is simpler. MCP adds a process, a connection, and a trust decision about third-party code.
| Situation | Likely choice |
|---|---|
| One private helper function | Plain tool definition |
| Reusing a community server | MCP |
| Same tools in several applications | MCP |
| Tools that must run in a separate, restricted process | MCP |
What you will build
In later chapters you will write a small server and a client that connects to it. The client lists the server's tools, converts them into the format your model API expects, and runs a loop. In that loop the model requests tools and your code routes each request to the server. By the end you will have handled errors, combined multiple servers, and applied basic security practices.
Exercise
Your application has one tool, a function that formats dates, and no other application will use it. Should you wrap it in an MCP server? Give one reason for your answer.
Show answer
Probably not. A plain tool definition passed to the model is simpler. An MCP server adds a separate process, a connection, and lifecycle handling, and you gain little because nothing else will reuse the tool. MCP becomes worthwhile when you want to reuse tools across applications or use servers written by others.