Model Context Protocol (MCP) is an open-source framework that gives AI models context and integrates them with external tools and data sources via a client-server architecture.
A Guide to MCP: Providing Context for AI Models
article
To understand Model Context Protocol (MCP), one needs an understanding of how Large Language Models are used by AI applications. AI models need to connect to different data sources, tools, and devices and request actions. On its own, an AI application can’t handle the integrations with these data sources, tools, and devices. MCP is an open-source protocol for providing context to a model and helping in its integrations with its ancillary tools. Essentially, MCP is based on a client-server architecture.
Integrations
The integrations that a model depends on don’t have to be created specially. These could be prebuilt integrations that a model can plug into. Additionally, MCP provides a standardized protocol to build customized integrations. The context one associates with a model is transferable between different applications and the model itself.
MCP Servers Serve Context to AI Applications
MCP Servers are central to MCP architecture as AI applications depend on them for context. A single AI application could be receiving context from several MCP Servers. MCP Servers can offer tools, resources, and prompts to AI applications. A tool is an executable function that an AI application can use to perform an action, such as open a file, make an API call, or run a database query. An MCP Server can offer an AI application, resources in the form of data sources for context. These data sources are plain old files or database data, or REST API responses. An MCP Server can offer prompts to an AI application. These prompt templates can help an AI application interact with an LLM. As an example, an AI application may want to know how to use few-shot examples to improve a model's performance at a specific task.
An AI Application Plays the MCP Host
An AI application plays the role of an MCP Host. It receives context from MCP Servers; it is the target of the MCP Servers’ activity. Further, it coordinates and manages one or more MCP clients. It is the MCP Host that instantiates MCP Clients that can subsequently interact with MCP Servers. As an example, suppose Visual Studio Code is the AI application that needs to connect to the local filesystem server. It does so by creating a new MCP Client that establishes a one-to-one connection with an MCP server, which represents the local filesystem server.
MCP provides standard protocol operations that an AI application can use to discover and use tools, resources, and prompts. As an example, an AI application (MCP Host) can discover available tools via the protocol operation tools/list. After it finds a suitable tool, it can execute a specific tool with the protocol operation tools/call.
An MCP Client Is the Intermediary
An AI application, or the MCP Host, doesn’t interact with MCP Servers directly. Instead, it interacts via MCP Clients. There is a one-to-one connection between an MCP Client and a MCP Server. Because there could be multiple MCP Servers serving context to an AI application, there are the same number of MCP Clients in the middle. For example, there could be a dedicated MCP Client-MCP Server pair for the filesystem, another pair for the database, and yet another for a REST API.
MCP Clients Can Offer to MCP Servers as Well
MCP Clients are not just dormant intermediaries obtaining context from the MCP Servers and passing it on to the AI applications. MCP Clients have access to an AI application’s capabilities. As an example, MCP Clients can help MCP Servers when a server needs large language completion from an AI application. By taking an MCP Client’s help, an MCP Server can avoid using a language model SDK directly, only for its specific use. This MCP Client to MCP Server feedback can help build better interactions. An MCP Server can always request additional information from a user in the form of an elicitation.
There is so much that goes on within an AI application, and it constantly needs to request external tools and data sources to perform actions on its behalf. MCP provides the protocol for serving context to a model when needed.
Lets Hang!