AI coding

What Is the Model Context Protocol and When to Use It

Antonio Evans7 min read

A robot plugs a bundle of colorful cables into one universal socket panel, connecting itself to a calendar, a database drum and a folder floating nearby.
Key points

Key points

  1. 1The Model Context Protocol (MCP) is an open standard that lets any AI application connect to tools and data through a server built once, instead of a custom integration for every pair of application and service.
  2. 2An MCP host, such as an editor or chat app, runs one client per server, and servers expose three kinds of things: tools to call, resources to read and prompts to reuse.
  3. 3Use MCP when a tool must be shared across several applications, models or teams, or needs central authentication and audit; use plain function calling when a tool belongs to one application.
  4. 4Every MCP server you connect can inject instructions into your agent, so allowlist servers, give them the least privilege they need, and require human approval for sensitive actions.

What MCP is

The Model Context Protocol is "an open-source standard for connecting AI applications to external systems," according to its official documentation (modelcontextprotocol.io). Through MCP, an AI application can reach data sources such as local files and databases, tools such as search engines, and workflows such as specialized prompts. The documentation offers an analogy: "Think of MCP like a USB-C port for AI applications." One standard plug, many devices.

Anthropic open-sourced MCP in November 2024, describing it as "a new standard for connecting AI assistants to the systems where data lives, including content repositories, business tools, and development environments" (Anthropic). The launch included the specification and SDKs, local server support in Anthropic's desktop app, and a repository of open-source servers for systems such as Google Drive, Slack, GitHub, Git and Postgres.

The protocol is not tied to one vendor. The official documentation lists support across AI assistants and development tools, including Claude, ChatGPT, Visual Studio Code and Cursor, so a server built once can be used from many clients (modelcontextprotocol.io).

For a coding agent, MCP is how it reaches beyond the repository: reading an issue tracker, querying a database, driving a browser for testing, or looking up errors in a monitoring service.

The problem it solves

Before MCP, every AI application that wanted to use an outside service needed its own integration with that service. Google Cloud's explainer calls this the "N x M" problem: the number of custom connections grows with the number of AI applications multiplied by the number of tools and data sources (Google Cloud). Databricks describes it the same way, noting that without a standard, "each AI application must integrate directly with every external service" (Databricks).

Anthropic's announcement framed the cost in plain terms: even capable models are "trapped behind information silos and legacy systems," and "every new data source requires its own custom implementation" (Anthropic).

MCP turns that multiplication into addition. Each service gets one MCP server. Each AI application gets one MCP client implementation. Any client can then talk to any server.

Without a shared protocolWith MCP
Each app writes its own GitHub, Slack and database integrationOne GitHub server, one Slack server, one database server
Adding a new app means rewriting every integrationA new app connects to the existing servers
Tool definitions differ by model providerTools work with any MCP client, whatever model it uses
Access control lives in each appAccess control can live at the server

Google Cloud also notes that MCP "builds on existing concepts like tool use and function calling but standardizes them." It does not replace the model's ability to call tools. It standardizes how those tools are described, discovered and reached.

How MCP works: hosts, clients and servers

The architecture documentation defines three participants (MCP architecture):

  • MCP host: the AI application that coordinates everything, such as an editor or desktop assistant.
  • MCP client: a component inside the host that maintains a connection to one server.
  • MCP server: a program that provides context and capabilities to clients.

The host creates one client for each server it connects to. The documentation's example is Visual Studio Code: when it connects to a monitoring service's MCP server, it creates a client for that connection, and when it also connects to a local filesystem server, it creates a second client.

Servers can run in two places, matching the two transports the protocol defines:

TransportWhere the server runsTypical use
Standard input/output (stdio)A local process on the same machineFilesystem access, local git, a local database
Streamable HTTPA remote serviceA hosted product's API, shared company tools

The documentation notes that stdio gives "optimal performance with no network overhead," while Streamable HTTP supports standard HTTP authentication methods, with OAuth recommended for obtaining tokens. Messages on both use the same JSON-RPC 2.0 format.

What a server offers is described by three core primitives:

  • Tools: "Executable functions that AI applications can invoke to perform actions," such as file operations, API calls or database queries.
  • Resources: "Data sources that provide contextual information," such as file contents or database records.
  • Prompts: "Reusable templates that help structure interactions with language models."

Each primitive has list methods, so a client can ask a server what it offers at runtime and get an up-to-date answer. That discovery step is what makes MCP different from hard-coding tool definitions into an application, and, as the security section shows, it is also where much of the risk comes from.

When to use MCP and when not to

MCP adds a process or a network hop, a server to run, and a connection to manage. That overhead pays off in some situations and not in others. Prefect's guide to choosing between MCP and function calling puts the dividing line clearly: MCP wins "when tools need to be shared, discovered, or governed independently of any single application" (Prefect).

Its decision table, slightly condensed:

QuestionFunction callingMCP
How many clients use this tool?OneSeveral
How many model providers might you use?OneMore than one
Does the tool need central auth and audit?Not reallyYes
Is the tool specific to one app's workflow?YesNo
Will several teams use or maintain it?NoYes
Prototyping or shipping?PrototypingShipping

Prefect lists specific cases where plain function calling is better: single-application tools, tools generated at runtime from the conversation, latency-sensitive paths where an extra hop matters, and prototypes where you are still finding out whether a tool is useful. MCP is better for multi-client access, portability across models, team-shared tools, and production governance, where a gateway in front of the servers can handle "authentication, rate limiting, audit logging, and access control."

Most teams end up using both. Prefect's example is an incident-response agent. Searching alerts and querying the runbook database are shared capabilities that many agents and people need, so they belong on MCP servers. Formatting the agent's own Slack summary is specific to that agent, so it stays as a function call. Putting it on a server "would add infrastructure overhead for no benefit."

For coding agents, a practical rule follows from this. If a capability is already offered as a well-maintained MCP server by the service you use, connect to it. If you need a small helper for one project, a script the agent can run, described in a skill or a project context file, is often simpler than a server. Build your own MCP server when several tools or teams need the same internal capability, such as querying a company database with access control.

The security risks you take on

Connecting an MCP server gives text written by someone else a direct path into your agent's context. That is the core risk, and several security teams have documented how it plays out.

Tool poisoning. Invariant Labs described tool poisoning attacks, in which "malicious instructions are embedded within MCP tool descriptions that are invisible to users but visible to AI models" (Invariant Labs). Their experiments showed that a malicious server could instruct the model to read sensitive local files and pass their contents along as a tool argument, while the user interface showed only a harmless-looking call. They also found that a malicious server can "override instructions provided by other, trusted servers."

Rug pulls. Datadog's security team describes a server that was approved when it was safe and later updated with new tool definitions the user never saw, a pattern it calls a rug pull (Datadog). Elastic Security Labs defines the same attack as a tool's description or behavior being "silently altered after user approval" (Elastic Security Labs).

Injection through tool output. The OWASP community page on MCP tool poisoning points out that tool responses are often added to the model's context without validation, that internal and external tools often share the same privilege level, and that restrictions written into a system prompt "are enforced only by the LLM's instruction-following, not by backend access controls" (OWASP).

Credentials in configuration. MCP servers hold the keys to the systems they connect to. Datadog notes that improperly stored server configuration files, which typically contain those credentials, can give attackers access to connected systems.

Consent fatigue. Requiring approval for sensitive actions is the right control, but Datadog warns it "can fail if a malicious MCP server inserts a harmful action in between an influx of legitimate ones," and that many users switch on automatic approval to stop the prompts.

None of this makes MCP unusable. It makes each server a dependency with the same trust questions as any package you install, plus one more: it can talk to your model directly.

A checklist for adopting MCP safely

The recommendations from OWASP and Elastic overlap closely (OWASP, Elastic Security Labs). Combined into one list:

Before connecting a server
[ ] It comes from a trusted source, and someone has read its tool descriptions
[ ] It is on the team's allowlist of approved servers
[ ] Its credentials are scoped to what the task needs, nothing more

While running it
[ ] Local servers run in a sandbox, such as a container, away from your own credentials
[ ] Privileged tools (files, databases, internal APIs) are isolated from external servers
[ ] Access limits are enforced in the tool or server, not only in the system prompt
[ ] Destructive or data-sending actions require human approval outside the model
[ ] "Always allow" and auto-run are off for tools that touch sensitive data

Over time
[ ] Every tool call is logged and the logs are reviewed
[ ] Server versions are pinned, and description changes are reviewed before update
[ ] Unused servers are disconnected

Two of these deserve emphasis. First, enforce limits server-side. OWASP's advice is direct: "Do not rely on system prompt instructions to restrict tool access." Second, keep approvals meaningful. If an approval prompt appears so often that people click through it, reduce what needs approval by narrowing permissions, so that the prompts that remain are worth reading.

Treated this way, MCP gives an agent useful reach into the systems a team already uses, with one well-understood interface for each, and with the same supply-chain discipline you would apply to any other dependency.

FAQ

FAQ

Is MCP only for Anthropic's products?

No. MCP is an open standard, and the official documentation lists support in several assistants and development tools from different companies. A server built to the specification works with any compliant client, whatever model the client uses.

Do I need MCP to give an agent tools?

No. Most model APIs support function calling directly, and that is often simpler for tools used by one application. MCP becomes worth it when the same tool needs to work across several applications, models or teams, or needs central authentication and logging.

What is the difference between an MCP tool and an MCP resource?

A tool is an action the model can call, such as running a query or creating an issue. A resource is data the application can read into context, such as a file or a database record. Prompts, the third primitive, are reusable templates a server offers.

Should I run MCP servers locally or remotely?

Local servers over standard input/output suit tools that need your machine, such as the filesystem or local git. Remote servers over HTTP suit shared services and hosted products, with OAuth for authentication. Either way, give each server only the access it needs.

How do I know an MCP server is safe?

Read its tool descriptions and code, check who maintains it, and pin the version you reviewed. Run it with limited credentials, in a sandbox if it is local, and log its tool calls. Treat any update to its tool descriptions as a change that needs review.

Sources

Sources

  1. https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro
  2. https://www.anthropic.com/news/model-context-protocol
  3. https://cloud.google.com/discover/what-is-model-context-protocol
  4. https://www.databricks.com/blog/what-is-model-context-protocol
  5. https://modelcontextprotocol.io/docs/2026-07-28/learn/architecture
  6. https://www.prefect.io/resources/mcp-vs-function-calling
  7. https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks
  8. https://www.datadoghq.com/blog/monitor-mcp-servers/
  9. https://www.elastic.co/security-labs/threat-command/mcp-tools-attack-defense-recommendations
  10. https://community.owasp.org/attacks/MCP_Tool_Poisoning
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles