AI agents can reason, generate responses, and decide which tools they need. But their capabilities are limited when they cannot access external information or interact with real-world systems.
Consider an AI coding assistant that needs to inspect a GitHub repository, read project documentation, check a database, or create an issue.
Without integrations, every application would need custom code to connect to each external service. Developers would have to maintain separate integrations, authentication flows, and tool definitions.
The Model Context Protocol (MCP) addresses this integration problem.
MCP is an open protocol that standardizes how AI applications connect to external data sources and tools. Instead of building a different integration for every AI application, developers can expose capabilities through an MCP server and allow compatible AI applications to connect to it.
This makes integrations more reusable, modular, and easier to manage.
1. What Is Model Context Protocol (MCP)?
Model Context Protocol is an open standard originally introduced by Anthropic to connect AI applications with external systems.
It defines a common communication interface between an AI application and services that provide data or functionality.
Think of MCP as a universal connector for AI applications.
For example, suppose you build an AI assistant that needs to access GitHub.
Without MCP, you might implement GitHub-specific integration code inside your application. If you later want to support another AI application, you may need to build the integration again.
With MCP, you can build a GitHub MCP server that exposes repository information and operations through a standardized protocol.
Any compatible MCP client can connect to that server and use its supported capabilities, subject to its permissions.
MCP does not replace the GitHub API. Instead, the MCP server uses the API internally and exposes selected functionality through a standard interface.
This distinction is important: MCP standardizes how AI applications communicate with integrations, not how the underlying services operate.
2. Understanding MCP Architecture
MCP follows a client-host-server architecture with three main components.
MCP Host
The host is the AI application that manages the overall interaction. Examples include AI assistants and coding environments.
It manages model interactions, user context, permissions, and connections to MCP servers.
MCP Client
The client is a component inside the host that maintains communication with an MCP server.
An MCP host can create multiple clients to connect to different servers. Each client maintains its own connection to its corresponding server.
MCP Server
The server exposes capabilities such as tools, resources, and prompts.
It can run locally on the developer's machine or remotely as a service.
Example architecture
Imagine an AI development assistant connected to three MCP servers:
- GitHub MCP Server: Accesses repositories, pull requests, and issues.
- Database MCP Server: Provides database information and query capabilities.
- Filesystem MCP Server: Exposes selected files and directories.
The architecture looks like this:
AI Application
(MCP Host)
|
+---------+---------+
| | |
v v v
Client 1 Client 2 Client 3
| | |
v v v
GitHub Database Filesystem
Server Server Server
| | |
v v v
GitHub DB Local Files
API
The host coordinates the clients, while each server focuses on providing a particular set of capabilities.
This separation allows developers to build integrations independently without tightly coupling them to a specific AI application.
3. The Three Core MCP Primitives
An MCP server can expose three important primitives: tools, resources, and prompts.
They serve different purposes, and understanding the distinction is essential when designing an MCP integration.
A. Tools: Let AI Applications Perform Actions
Tools allow AI applications to invoke executable functions exposed by an MCP server.
For example, a GitHub MCP server might expose:
list_repositoriesget_pull_requestcreate_issuesearch_code
When a user asks:
"Create a GitHub issue for the authentication bug."
The AI application can discover available tools, select the appropriate one, provide the required arguments, and request execution through the MCP client.
A tool definition includes information such as its name, description, and input schema.
For example:
{
"name": "create_issue",
"description": "Create an issue in a GitHub repository",
"inputSchema": {
"type": "object",
"properties": {
"repository": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"repository",
"title",
"description"
]
}
}
The input schema tells the client what arguments the tool expects.
The interaction follows this general sequence:
- The client requests the available tools using
tools/list. - The host makes suitable tool definitions available to the model.
- The model selects a tool and prepares its arguments.
- The client sends a
tools/callrequest. - The MCP server executes the operation and returns the result.
- The host provides the result to the model.
An important distinction: MCP defines the tool interface, but the host controls how the model is allowed to discover and invoke tools.
Tools can perform operations with side effects, so applications should implement appropriate permission checks and user confirmations.
B. Resources: Provide Context and Data
Resources expose information that an AI application can retrieve and use as context.
Unlike tools, their primary purpose is providing data rather than executing an action.
For example, a database MCP server could expose:
- Database schema.
- Table definitions.
- Documentation.
- Read-only records.
- Configuration information.
Suppose a developer asks:
"What tables are available in the customer database?"
The assistant may retrieve a database schema resource and use its contents to answer.
Resources are typically identified using URIs.
An example might be:
database://production/schema
The client can discover available resources through resources/list and retrieve their contents through resources/read.
Resources can also support templates, allowing a client to retrieve information using parameterized resource URIs.
For example, a service could expose:
github://repositories/{owner}/{repo}/metadata
This allows an application to retrieve repository metadata for different repositories.
The key idea is that resources provide information the AI application can use, without necessarily performing an operation that changes external state.
C. Prompts: Reusable Interaction Templates
Prompts provide reusable message templates that help structure interactions with an AI model.
Instead of constructing similar instructions repeatedly, an MCP server can expose predefined prompts for common tasks.
For example, a GitHub MCP server might provide:
review_pull_requestexplain_commitsummarize_repository
A prompt could accept parameters such as a repository name or pull request number.
The client discovers available prompts through prompts/list and retrieves a particular prompt using prompts/get.
A prompt might contain instructions such as:
"Review the supplied pull request for correctness, security vulnerabilities, and performance problems. Return findings with file references and severity levels."
The host can present this template to the user or incorporate it into an interaction with the model.
Prompts do not independently execute external actions. They provide reusable instructions and context for an AI interaction.
Tools vs Resources vs Prompts
| Primitive | Primary purpose | Example |
|---|---|---|
| Tools | Perform actions | Create a GitHub issue |
| Resources | Provide information | Read repository metadata |
| Prompts | Structure interactions | Review a pull request |
A simple way to remember the difference:
- Tools do something.
- Resources provide something.
- Prompts guide how something is done.
4. How MCP Communicates: JSON-RPC and Transports
MCP uses JSON-RPC 2.0 as its underlying message format.
JSON-RPC defines how requests, responses, and notifications are represented.
For example, when a client requests available tools, it sends a structured request containing a method name and parameters.
A simplified illustration:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
The server responds with the available tools and their metadata.
When a client needs to execute a tool, it uses tools/call with the tool name and its arguments.
The protocol also defines capability discovery, version compatibility, notifications, progress reporting, and error handling.
MCP transports
MCP separates the data protocol from the transport used to exchange messages.
Two primary transports are supported by the current specification.
1. STDIO transport
STDIO uses standard input and standard output to communicate between local processes.
For example, an AI coding application can launch a filesystem MCP server as a child process and exchange messages through its input and output streams.
This is useful for local integrations because it does not require a network connection.
2. Streamable HTTP transport
Streamable HTTP allows clients to communicate with remote MCP servers over HTTP.
It uses HTTP POST for client-to-server messages and can use Server-Sent Events (SSE) for streaming responses.
This is useful when an MCP server runs on a remote infrastructure and needs to support multiple clients.
The current specification uses Streamable HTTP rather than the older HTTP+SSE transport as the recommended remote approach.
5. Building an MCP Server: A Practical Example
Consider a simple application that provides weather information.
You could build a weather MCP server that exposes a tool named get_weather.
The server receives a location, calls an external weather API, and returns the result to the MCP client.
Its basic responsibilities are:
- Define the MCP server and its capabilities.
- Register the
get_weathertool. - Define the tool's input schema.
- Implement the function that calls the weather API.
- Connect the server through a supported transport.
- Allow compatible MCP clients to discover and invoke the tool.
The architecture looks like this:
User Question
|
v
AI Application
|
v
LLM selects get_weather
|
v
MCP Client
|
| tools/call
v
Weather MCP Server
|
v
External Weather API
|
v
Weather Result
|
v
MCP Client
|
v
LLM generates response
|
v
User receives answer
Notice that the model does not need to understand the weather provider's internal API implementation.
It only needs an appropriate tool description and input schema. The MCP server handles the integration details.
For actual development, use an official MCP SDK rather than manually implementing protocol message handling. The SDK manages protocol details and provides abstractions for registering tools, resources, prompts, and transports.
6. MCP and AI Agents: Why It Matters
MCP becomes particularly useful when building agentic AI applications.
An AI agent often needs to interact with several external systems during a single task.
Consider an AI software engineering agent.
A developer asks:
"Investigate the latest production error, find the related code, and create a GitHub issue describing the problem."
The agent may need to:
- Query an observability platform for recent errors.
- Search a GitHub repository for related code.
- Read project documentation.
- Analyze the error and identify a likely cause.
- Create a GitHub issue.
Each external service can expose its capabilities through an MCP server.
The agent's host can connect to those servers through separate MCP clients and make relevant capabilities available during the workflow.
This is where MCP helps reduce integration complexity.
Instead of implementing a different communication protocol for every service, developers can build compatible servers and clients using a shared specification.
However, MCP does not make an application an autonomous agent. It provides the integration layer. The AI model, application logic, and orchestration system still determine how tasks are planned and executed.
7. Security Considerations When Building with MCP
Connecting an AI application to external systems introduces security risks.
A tool that can read files or query a database might expose sensitive information. A tool that can delete records or modify infrastructure can cause serious damage.
Developers should consider the following safeguards:
Least-privilege access: Give each MCP server access only to the systems and operations it needs.
Input validation: Validate tool arguments on the server rather than trusting values generated by the model.
Human approval: Require confirmation for sensitive operations such as deleting data, publishing content, or changing production infrastructure.
Authentication and authorization: Secure remote MCP servers using appropriate authentication and enforce authorization for every request.
Token audience validation: Remote servers must verify that access tokens were issued specifically for them. Do not blindly forward tokens intended for another service.
Prompt injection protection: Treat retrieved documents, repository content, and external responses as untrusted input. Retrieved instructions should never automatically override application policies.
Logging and monitoring: Record tool executions, failures, and important security events without unnecessarily storing sensitive content.
MCP provides a standard communication mechanism, but it does not automatically make every connected integration secure. Security must be designed into the host, client, server, and underlying services.
Conclusion
Model Context Protocol provides a standardized way for AI applications to connect with external tools and data sources.
Its three core primitives serve different purposes: tools perform actions, resources provide context, and prompts supply reusable interaction templates.
By combining these capabilities with a client-host-server architecture and standardized communication, MCP makes integrations more reusable across compatible AI applications.
For developers building AI agents, understanding MCP is increasingly important because the usefulness of an agent depends not only on how well it reasons, but also on how safely and reliably it can interact with the systems around it.



