AI & Machine Learning

MCP Servers Explained: Why Connecting AI Agents Is Not Just an API

Sarah Chen By Sarah Chen • • 10 min read

MCP Servers Explained: Why Connecting AI Agents Is Not Just an API

Two years ago, connecting an AI assistant to a company system meant a custom integration for every pairing of assistant and tool. Today a single open standard, the Model Context Protocol (MCP), lets assistants such as Claude, Cursor and many others plug into ticket trackers, code repositories, cloud accounts and business apps in minutes. That speed has a catch.

Many teams treat an MCP server as “just another API”, a new doorway to the same data. It is not. The client on the other side of an MCP server is an AI model, which reads instructions written in plain language, decides on its own what to do, and can be misled by text it encounters along the way.

This article explains what MCP is, what a well-built MCP server does differently from a normal API, why connecting many of them creates new costs and risks, and how Cloudflare’s MCP Server Portals and “Code Mode” approach that problem.

What the Model Context Protocol Actually Is

MCP is an open protocol that Anthropic introduced in November 2024 to standardize how AI applications connect to outside tools and data. Think of it as USB for AI assistants: one plug shape, so any assistant that speaks MCP can use any service that offers an MCP server.

An MCP server can offer three kinds of things:

  • Tools: actions the AI may decide to take, such as “create a ticket” or “list my invoices”
  • Resources: documents or data the assistant can read
  • Prompts: reusable templates a user can pick from

When an assistant connects, the server sends a list of its tools, each with a name, a short written description and a definition of the inputs it expects. That list is placed in the AI model’s working memory, its context window. From that moment, the model decides which tool to use and when, based mostly on those written descriptions. The full specification is public at modelcontextprotocol.io.

Why an MCP Server Is More Than an API

A traditional API is used by software that a developer wrote, tested and deployed. The developer reads the documentation once, handles the errors and moves on. An MCP server is used by an AI model in real time, every time, with no developer in the loop. That changes the job in five practical ways.

A good real-world example is the MCP server built for RedirMe, a link shortening and email forwarding service. It lets paying customers manage their short links from their AI assistant with six tools: list links, look up a link, create a link, edit a link, delete a link, and check the account’s plan and remaining limits. On paper that is a tiny API. In practice, most of the work went into the points below.

1. The Description Is the Documentation

An AI model never sees a documentation website. It only sees the short text attached to each tool. So that text has to explain not just what a tool does, but when to use it. RedirMe’s account tool, for example, tells the model to call it “before creating links in bulk to find out how many remain”. That one sentence changes how the assistant plans a task.

2. Error Messages Become Instructions

When a normal API refuses a request, it returns a numeric code and a human figures out what went wrong. An AI model reads the error message and acts on it immediately. RedirMe’s server therefore writes every error as guidance. If an assistant tries to delete a link that was created in the web dashboard, the answer explains that it cannot be deleted from here and that the user should delete it in the dashboard instead. The assistant passes that on, rather than retrying in a loop.

3. Every Answer Costs Space

Everything a tool returns lands in the model’s context window, which is limited and, through token pricing, costs money. An API can happily return a thousand records; an MCP tool that does the same pushes the actual conversation out of the model’s memory. Well-designed servers return small pages of compact results instead.

4. The Client Can Be Talked Into Things

This is the most important difference for business leaders. AI assistants are vulnerable to prompt injection: hidden instructions in a web page, email or document that the model reads and then follows. OWASP lists prompt injection as the number one risk for applications built on large language models.

For a link shortener, the obvious abuse is a legitimate customer account suddenly creating large numbers of phishing links on an attacker’s behalf. RedirMe’s MCP server counters that with several layers:

  • The same safety checks as the website. Links created by an assistant go through exactly the same screening as links created by a person, so the AI route is never the easier route.
  • Layered rate limits, with much stricter limits on creating and editing links than on reading them. Creation is what gets abused, and an edit changes where a link that people already use sends them.
  • A record of origin. Every link remembers whether it was made in the dashboard, through the API or through an AI assistant. Assistants can only delete links that assistants created, and deletions can be undone. An agent can clean up its own mistakes, but it can never wipe an account.
  • An audit trail for edits. Editing is allowed on any of the customer’s links, because that is what people ask their assistant to do. So every edit is logged with the assistant connection that made it and what it changed, and a new destination is screened just like a new link.

5. Sign-In Is a Protocol, Not a Password

The MCP standard expects remote servers to support OAuth 2.1, the same “Sign in with…” flow people know from consumer apps. The assistant registers itself, the user sees a consent screen listing what the assistant may do, and access can be revoked at any time. RedirMe also keeps AI credentials completely separate from its regular API keys, so a key handed to an assistant can do exactly what the assistant tools allow and nothing else.

None of these measures is exotic. Together, though, they show that an MCP server is a separate product with its own audience, its own threat model and its own sign-in flow. Building it like a thin wrapper around an existing API leaves those protections out.

The Hidden Cost of Connecting Many MCP Servers

One well-built server is manageable. The trouble starts when a team connects an assistant to a code repository, a ticket tracker, a documentation system, a cloud provider and a handful of business apps at once. Every connected server adds its full list of tool descriptions to the model’s context, before the user has typed a word.

Cloudflare has published concrete numbers. In its April 2026 reference architecture for enterprise MCP, the company describes an internal setup of four MCP servers with 52 tools that consumed about 9,400 tokens of context just for the tool definitions. In an earlier post about its own MCP server, Cloudflare estimated that exposing each of the more than 2,500 operations of its API as a separate tool would require 1.17 million tokens, more than most AI models can hold at all.

Token cost is only part of the problem:

  • Accuracy drops. The more similar tools a model has to choose from, the more often it picks the wrong one or fills in the wrong details.
  • Multi-step work is slow. A task that needs three tools takes three round trips through the model, with every intermediate result copied into its memory.
  • Governance sprawls. Every server has its own sign-in, its own keys and its own logs. Security teams also worry about unvetted servers that staff install themselves, which Cloudflare calls “shadow MCP”.

Some AI clients now load tool descriptions only when they are needed, which helps with the first problem. Cloudflare’s answer goes further, at the network level.

How MCP Server Portals Bring Order

An MCP Server Portal is a single address that sits in front of many MCP servers, both servers hosted on Cloudflare and third-party servers elsewhere. Think of it as a reception desk for AI tools: employees connect their assistant once and see every server they are allowed to use.

Behind that desk, administrators control access with Cloudflare Access policies. They decide who can connect to a portal, which servers appear in it, and which individual tools of each server are switched on. A finance team could get a portal with read-only tools, while engineers get one with read and write access. Every tool request is logged in one place, and when the portal traffic runs through Cloudflare Gateway, data loss prevention rules can block sensitive information from reaching certain servers.

That solves the sprawl. On its own, though, a portal would still pass all 52 tool descriptions to the model. That is where Code Mode comes in.

Code Mode: Two Tools Instead of Hundreds

Code Mode starts from an observation Cloudflare made in a September 2025 post: AI models are better at writing short programs that call an API than at calling many separate tools directly. Cloudflare’s explanation is that models have seen enormous amounts of real program code during training, and very few tool calls.

So instead of listing every tool, a Code Mode server offers just two:

  • Search, where the model writes a small query to find only the operations it needs, so the full catalog never enters its memory
  • Execute, where the model writes a short program that performs the work, chaining several steps and returning only the final result

That code runs in an isolated sandbox with no file system and no access to the internet by default, and the credentials stay on the server side, out of reach of the generated code.

The savings are large. For Cloudflare’s own API, the 1.17 million tokens drop to roughly 1,000, a reduction of 99.9%, and that number stays the same as the API grows. Cloudflare has since brought the same approach to portals: with Code Mode enabled, all tools of all connected servers collapse into two portal tools. For the internal portal with 52 tools, the context cost fell from about 9,400 tokens to roughly 600, a 94% reduction, and it does not grow as servers are added.

What This Means for Your Business

Code Mode does not make careful MCP server design unnecessary. If anything, it raises the stakes:

  • Clear descriptions matter more. In Code Mode the model finds tools by searching their names and descriptions. A vague description means a tool that is never found.
  • Clear errors matter more. Generated code acts on whatever a tool returns, within a single step.
  • Server-side safeguards matter most. A model can call a tool many times inside one program, without a person approving each call. Rate limits, origin tracking, audit logs and limited delete rights inside the server are the protections that still apply.

For organizations planning to connect AI assistants to internal systems, a few practical steps follow:

  1. Treat each MCP server as a product, with its own threat model, not as a side door to an existing API.
  2. Give AI access its own credentials and scopes, separate from regular API keys, so they can be limited and revoked on their own.
  3. Record which actions came from an assistant, so mistakes and abuse can be traced and reversed.
  4. Centralize access through a portal or gateway before the number of connected servers grows, rather than after.
  5. Watch the context budget. Ask vendors how many tools their server exposes and whether it supports Code Mode or on-demand loading.

Conclusion

MCP has made it remarkably easy to connect AI assistants to the tools a business already uses. That ease hides a shift: the system on the other end is no longer code a developer tested, but a model that read a description a moment ago, may have read something hostile a moment before that, and will act on whatever it gets back.

Well-built MCP servers, such as the one behind RedirMe, are designed for that reader, with clear descriptions, helpful errors, small answers and firm limits. Portals and Code Mode then keep the cost and governance of many servers under control.

As AI agents take on more real work in 2027, the question for every organization is no longer whether to connect them, but how carefully. Are your AI connections built for a reader that can be persuaded?

Share this article

About the Author

Sarah Chen

Sarah Chen

Senior Technology Analyst

Senior technology analyst with over 10 years of experience covering enterprise software and AI. Sarah specializes in translating complex technological developments into actionable business insights. Her work has helped countless organizations navigate digital transformation.