Model Context Protocol (MCP)
The way we enable LLMs to use external tools
What is the Model Context Protocol (MCP)?
The Model Context Protocol (MCP) is a structured way for LLMs to communicate with external tools. Every tool, such as Google Sheets, Airtable or LinkedIn, can have its own way of integrating with it. Most often this is through an API, and APIs differ from each other in how they are used. Thanks to MCP, this complication doesn't exist for the LLM, because every request is always made in the same way.
How MCP is built
It consists of 3 things:
- Host - the place from which we interact with the model. It can be an LLM or an AI that assists the IDE
- Client - the intermediary between the host and the server. It prepares data in JSON format and establishes a connection with the server
- MCP server - an external app that receives our command and prepares the response data or performs an action.
MCP server features
It gives us 3 main features:
- Tools - calling programs, scripts or actions in other apps, most often using an API
- Resources - providing information from local files or databases
- Prompts - reusable templates that keep the model's responses consistent or simplify repetitive actions.
What does an MCP function look like?
We can see what a built function looks like using the example of the Shadcn MCP and its list_item_in_registries function.
From the model's side, a function mainly consists of 2 things:
- a short description of what it does, so the model knows when to use it
- the variables that need to be provided to handle the request properly - each variable also has its own description saying what exactly should go there.
If you want to build your own MCP server, you can take a look at this repo, which contains SDKs directly from Anthropic (the creators)