Teams often ask whether they still need the Model Context Protocol if they already have REST APIs and native function calling. Short answer: MCP is not a replacement for your product API, and raw function calling is not a replacement for a shared tool protocol. They sit on different layers—and patterns like Cloudflare Code Mode change how models consume tools without deleting MCP.
Three layers people confuse
- Product APIs (REST/RPC/GraphQL): what your service already exposes to software.
- Model function calling: a model vendor’s JSON/tool-call format for invoking functions the host registers for one session.
- MCP: an open protocol for discovering tools, attaching docs, and connecting agents to servers with out-of-band auth—so clients and servers do not hardcode each other.
Raw API function calling means you hand-write tool schemas in your agent host and map each call to fetch/SDK code. That works for a fixed internal toolbox. It scales poorly when every IDE, chatbot, and automation runtime must re-integrate the same SaaS by hand.
Scorecard
| Dimension | Raw API function calling | MCP |
|---|---|---|
| Discovery | Developer codes each tool into the host | Client can connect to unknown servers that speak MCP |
| Docs for the model | You maintain descriptions | Server can ship tool docs in-protocol |
| Auth uniformity | Ad hoc per API | Designed for out-of-band auth patterns (keys/OAuth) across servers |
| Portability across agents | Low—schemas are host-specific | Higher—same server can serve Cursor, Claude, custom hosts |
| Best fit | Small closed toolsets you fully control | Ecosystem tools, partner integrations, shared internal platforms |
| Failure mode | Schema drift per host | Untrusted servers / sprawl without allowlists |
Where raw function calling still wins
If you have five internal tools, stable schemas, and one harness, native function calling is simpler. No MCP process to run, fewer moving parts, easier to reason about in a single repo. Many production agents correctly start here. You own validation, retries, and logging without negotiating a second protocol.
Raw function calling also keeps the blast radius obvious: every tool is a function you registered. That clarity helps security reviews when the tool count is small.
Where MCP wins
When multiple agent products must use the same capabilities, or when you want a uniform way to add GitHub/docs/cloud tools without rewriting host code each time, MCP’s connectivity model pays off. That is why coding agents standardized on MCP servers for third-party tools.
MCP shines for platform teams that publish capabilities once and let many agent hosts subscribe under an allowlist. The protocol’s value is uniformity of discovery and auth—not magic performance.
How Code Mode changes the debate
Code Mode does not pick MCP vs API—it changes execution style. Models write sandboxed code against typed APIs derived from MCP or OpenAPI, instead of loading every operation as a native tool. Cloudflare’s public guidance is explicit: Code Mode is a better way to use MCP, not a replacement for it. See the Code Mode explainer for client- vs server-side patterns.
In practice you might keep MCP for connectivity, expose a tiny search/execute surface (server-side Code Mode), or convert MCP tools into TypeScript bindings inside your agent sandbox (client-side Code Mode). The underlying system of record remains your API.
Security notes (both paths)
- Least-privilege credentials whether tools are MCP or hand-wired
- Allowlists for which servers/functions exist in production
- Approvals on write/send/deploy
- Prompt-injection defenses on tool results
- Audit logs with tool name, latency, and arg fingerprints—not raw secrets
Protocol choice does not remove prompt injection risk. Tool results are untrusted input in both designs. Pair this article with prompt injection defenses and MCP allowlist policy.
Pick guide
- One app, few tools → raw function calling is fine
- Many agents / many vendors → MCP servers + allowlist governance
- Huge API surface / multi-step composition → Code Mode (often still over MCP or OpenAPI)
- Never expose production-destructive tools without gates—protocol choice will not save you
Eval method
Build twenty tasks: ten that need one call, ten that need chained calls. Score success, tokens, and human fixes for (a) hand-wired tools, (b) MCP direct tools, (c) Code Mode if available. Publish the scorecard internally before standardizing.
Keep the suite stable for at least a month so you can attribute regressions to harness changes rather than flaky tasks. Gate merges on safety cases even if quality scores are noisy.
Implementation sketch (host-side)
For raw function calling, register tools in your model SDK, validate args with JSON Schema, execute SDK calls, return structured results, and cap iterations. For MCP, run or connect to a server, negotiate tools/list, map call requests to handlers, and keep auth tokens in the host—not in model context. In both cases, log tool name, latency, and arg fingerprints (not secrets).
A minimal acceptance test: the agent completes a read-only task without requesting undeclared tools, and a write task stops at an approval gate. Automate those checks in CI alongside agent evals.
Ops and pricing shape
Raw function calling costs are mostly model tokens plus your API usage. MCP adds server hosting (local stdio is cheap; remote hosted servers add egress and vendor fees). Code Mode can cut schema tokens dramatically on large APIs—Cloudflare published on the order of ~1,000-token tool footprints for a very large API surface via search/execute—but you still pay for execution and underlying API calls. Verify current pricing on vendor docs; do not treat blog measurements as your invoice.
Lock-in and migration
Hand-wired tools lock you to your harness code. MCP reduces client lock-in to a protocol but can create server sprawl. Prefer allowlisted registries and version pins either way.
Migrate shared multi-client capabilities to MCP first. Leave niche internal tools as native functions until the maintenance cost of duplicated schemas exceeds the cost of running servers. Document the decision in your harness README so new teams do not reinvent parallel tool stacks.
Worked example: incident triage agent
Suppose on-call wants an agent that reads status pages, queries logs, and opens a ticket. With raw function calling you ship three host functions and wire secrets in one service. With MCP you might attach a docs server, a logs server, and a tracker server—portable to IDE agents, but you must allowlist and scope each. With Code Mode you might keep those connectors yet let the model write a short script that filters log lines before they re-enter context, cutting token burn on noisy incidents.
FAQ
Is MCP slower than calling my API?
MCP adds a process/protocol hop. For most SaaS tools the network/API latency dominates. Optimize allowlists and result size before blaming MCP.
Can I wrap my existing OpenAPI as MCP?
Yes—many gateways generate MCP tools from OpenAPI. Code Mode can also derive typed methods from OpenAPI without advertising one tool per endpoint.
Should I migrate everything to MCP tomorrow?
No. Migrate shared, multi-client capabilities first. Keep tight internal tools as native functions until sprawl hurts.
Does Code Mode replace this comparison?
No. Code Mode is an execution pattern that can sit on MCP, OpenAPI-derived connectors, or both. You still choose how capabilities are published and authorized.
Bottom line
Use APIs as the system of record. Use function calling for small private toolboxes. Use MCP when you need portable tool connectivity across agent hosts. Use Code Mode when tool cardinality or multi-step composition blows the context window. Measure with a fixed eval set before declaring a winner for your team.
AI Generated Apps AI Code Learning Technology