For large language models (LLMs) to unlock their full potential and be truly valuable, they must be able to interact seamlessly with external data sources, services, and tools. Traditionally, this interaction has been facilitated by application programming interfaces (APIs). However, late in 2024, Anthropic introduced the model context protocol (MCP), an open standard protocol that has already significantly advanced how applications provide essential context to LLMs.
This post will delve into the definitions, shared characteristics, and crucial distinctions between MCP and APIs, particularly focusing on their roles in AI agent integration.
Understanding APIs
An API serves as a defined set of rules or protocols dictating how one system can access the functionality or data of another. Essentially, APIs act as a bridge, allowing separate software components to communicate. Developers leverage APIs to integrate capabilities from external systems without the need to build every feature from scratch. For instance, an e-commerce platform might utilise a payment API to process credit card transactions.
How APIs function: APIs establish an abstraction layer. The client, which is the requesting application, does not need to comprehend the intricate internal workings of the service it wishes to invoke (the server). The server processes the request, and the client's sole requirement is to understand how to format its requests and interpret the subsequent responses.
The RESTful API style is one of the most widespread, often considered the default for web-based interactions. RESTful APIs communicate over HTTP, with clients employing standard HTTP methods:
- GET: retrieves data (e.g.,
/books/123
to fetch details for book ID 123). - POST: creates new data (e.g.,
/loans
to record a new book loan). - PUT: updates existing data.
- DELETE: removes data.
Typically, each RESTful API endpoint returns data, frequently in JSON format, representing the outcome of the request. Many commercial LLMs are offered via REST, where a JSON prompt is sent and a JSON completion is received. Furthermore, AI agents can utilise REST APIs for various tasks, such as performing web searches or interacting with a company's internal RESTful services.
Introducing MCP
MCP is a newer, open standard protocol specifically engineered to standardise connections between AI applications (especially AI agents), LLMs, and external data sources. A helpful analogy for MCP is that it functions much like a USB-C port for your AI applications. Just as a single USB-C port allows diverse peripherals from different manufacturers (e.g., monitors, external disk drives, power supplies) to connect seamlessly to a laptop using a common standard, MCP standardises how AI applications interact with various external capabilities.
MCP architecture and capabilities: An MCP setup involves an MCP host running multiple MCP clients. Each client connects to an external MCP server by initiating a JSON RPC 2.0 session using the MCP protocol. This establishes a clear client-server relationship.
MCP servers are designed to expose capabilities. These capabilities can include access to a database, a code repository, or an email server. Extending the USB-C analogy, the laptop represents the MCP host, the USB-C connection signifies the MCP protocol, and the drive, monitor, or power supply are akin to MCP servers.
MCP addresses two primary needs for LLM applications, particularly AI agents:
- Providing context: This involves retrieving contextual data such as documents, entries from knowledge bases, and database records.
- Enabling tools: This allows AI agents to execute actions or tools, such as performing a web search, calling an external service, or conducting calculations.
MCP primitives: MCP servers advertise a set of "primitives" to define their capabilities:
- Tools: These are discrete actions or functions that an AI can invoke. For example, a weather service might expose a
get_weather
tool, or a calendar service might expose acreate_event
tool. The server advertises each tool's name, description, and its input/output schema within its capabilities listing so that an LLM is able to interpret how to utilize this server. When an LLM uses an MCP client to invoke a tool, the MCP server executes the underlying function. - Resources: These are read-only data items or documents that the server can provide and which the client can retrieve on demand. Examples include text files, database schemas, or file contents.
- Prompt Templates: These are predefined templates that offer suggested prompts.
Crucially, an AI agent can query an MCP server at runtime to discover what primitives are available and then invoke those capabilities in a uniform manner. Because every MCP server publishes a machine-readable catalogue (e.g., tools/list
, resources/list
, prompts/list
), agents can discover and utilise new functionality without requiring code redeployment. This represents a significant advantage.
Shared ground: similarities between MCP and APIs
Despite their differing designs, MCP and APIs share fundamental characteristics:
- Client-Server Model: Both protocols are built upon a client-server architecture. With a REST API, a client sends an HTTP request to a server, which then returns a response. Similarly, in MCP, an MCP client sends a request (e.g.,
tools/call
) to an MCP server and receives a response. - Abstraction Layer: Both provide an abstraction layer, concealing the low-level implementation details of one system from another. The client merely needs to adhere to the defined interface.
- Simplified Integration: Both MCP and APIs simplify integration, enabling developers to connect systems more easily and avoid "reinventing wheels".
Key distinctions: purpose-built vs. general-purpose
The most significant divergences between MCP and APIs lie in their purpose and flexibility:
Purpose:
- MCP is purpose-built: It was explicitly designed for integrating LLM applications with external data and tools. It standardises patterns for providing context data and invoking tools in ways that are inherently aligned with AI agent operations.
- APIs are general-purpose: They were not initially conceived with AI or LLMs specifically in mind.
Dynamic Discovery: This is one of MCP's most compelling advantages.
- MCP supports dynamic discovery: An MCP client can simply ask an MCP server, "What capabilities do you offer?" and receive a description of all available functions and data. The LLM application can then adapt to whatever is available. This means AI agents can retrieve the latest capabilities list each time they connect and automatically incorporate new features.
- Traditional REST APIs typically lack an equivalent runtime discovery mechanism. If an API changes or new endpoints are added, the client usually requires a manual update by a developer.
Standardisation of Interface:
- MCP standardises the interface: Regardless of the service or data it connects to, every MCP server "speaks the same protocol" and adheres to the same patterns. This embodies a "build once, integrate many" approach.
- API interfaces are unique: The specific endpoints, parameter formats, and authentication schemes differ considerably between various API services. An AI agent needing to interact with five different REST APIs might require five distinct adapters.
The interplay of MCP and APIs in AI agent development
It is vital to understand that MCP and APIs are not competing technologies; instead, they function as complementary layers within an AI stack. In numerous scenarios, the implementation of an MCP server actually leverages traditional APIs to perform its operations. An MCP server can effectively act as a wrapper around an existing API, translating between the standardised MCP format and the underlying service's native interface.
For instance, the GitHub MCP server exposes high-level tools like repository/list
as MCP primitives. However, internally, it translates each tool call into the corresponding GitHub's REST API request. This means MCP can capitalise on existing API infrastructure while simultaneously providing a more AI-friendly interface on top.
Today, MCP services are available for a growing list of external data sources and services, including file systems, Google Maps, Docker, and Spotify. Thanks to MCP, these services can now be integrated into AI agents in a standardised and more intelligent manner.