A8gent
MCP vs Plain Function Calling cover
MCP Architecture · Lesson 1 of 17

MCP vs Plain Function Calling

What the Model Context Protocol adds over plain function calling, what the extra layer costs in context and latency, and how to decide which one a job needs.

Two ways to give an agent tools

Before writing any code, get clear on what the Model Context Protocol actually changes. If you have built with function calling, you already know one way to give a model tools: you define a set of functions inside your app, pass their schemas to the model with each request, and run whatever it calls. Here is what that looks like against the Anthropic API. The tool lives inside this one script and nowhere else:

import anthropic

client = anthropic.Anthropic()

tools = [{
    "name": "get_order_status",
    "description": "Look up the current status of an order by its numeric order ID.",
    "input_schema": {
        "type": "object",
        "properties": {
            "order_id": {"type": "string", "description": "Numeric order ID, e.g. 88231"}
        },
        "required": ["order_id"],
    },
}]

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    tools=tools,
    messages=[{"role": "user", "content": "Where is order 88231?"}],
)

for block in response.content:
    if block.type == "tool_use" and block.name == "get_order_status":
        result = lookup_order(block.input["order_id"])  # your code runs it

That works, but the tool is trapped. If tomorrow the same lookup should also be available in Claude Desktop, Claude Code, and Cursor, you rewrite the integration three more times, once per client, each with its own config format.

What MCP changes

MCP takes the tool out of your app and puts it behind a small server that speaks a shared JSON-RPC protocol. Any compatible client connects, calls tools/list to discover what the server offers, and calls tools/call to use it. The same tool, written once as an MCP server in Python with FastMCP, looks like this:

from fastmcp import FastMCP

mcp = FastMCP("orders")

@mcp.tool
def get_order_status(order_id: str) -> str:
    """Look up the current status of an order by its numeric order ID."""
    order = lookup_order(order_id)
    return f"Order {order_id}: {order.status}, ETA {order.eta}"

if __name__ == "__main__":
    mcp.run()  # stdio transport by default

Now any client can use it. Wiring it into Claude Desktop is a few lines of JSON config, and the exact same entry works in Claude Code and Cursor with only the file location changing:

{
  "mcpServers": {
    "orders": {
      "command": "python",
      "args": ["/absolute/path/to/orders_server.py"],
      "env": { "ORDERS_API_KEY": "sk-..." }
    }
  }
}

The trade-off, side by side

Concern Plain function calling MCP server
Where tools live Inside one app's code Behind a reusable server process
Reuse across clients None, re-integrate per app Any MCP client connects with config only
Discovery Schemas passed manually per request Clients call tools/list at runtime
Permission boundary Scattered through app code Enforced in one server you control
Operational cost None beyond the app A server, a transport, schemas to maintain
Best for One app, one model, fixed tools Shared tools, sellable integrations

What MCP adds

  • Reuse across clients. The same server works in Claude Desktop, Cursor, and your own agent without rewriting the integration for each one.
  • A clean boundary. Your server sits in front of your APIs and databases, so you decide exactly which actions an agent can reach and under what rules. This boundary is what companies actually pay for.
  • Discovery. Clients ask the server what tools, resources, and prompts it offers, so you can add or change tools without editing every client. The protocol messages are plain JSON-RPC 2.0, so you can read them in a debugger.

What it costs you

MCP is another moving part. You run a server, choose and handle a transport (stdio for local servers launched as a subprocess, Streamable HTTP for remote servers), and maintain the schemas your tools advertise. For a single app calling a single model with a fixed set of functions, that overhead buys you little, and plain function calling is the simpler, cheaper choice. Notice also what MCP does not do: it does not replace your APIs. The FastMCP handler above still calls lookup_order underneath. MCP adds descriptions, discovery, and permission rules on top of the same API calls you would have made anyway.

How to decide

  1. Will more than one client or agent use these tools? If yes, MCP earns its place immediately.
  2. Do you want a permissioned boundary in front of company systems that survives client changes? MCP gives you a single place to enforce it.
  3. Is this a one-off integration inside one product? Function calling is usually enough, and you can lift it into a server later, since the handler code barely changes.

A migration path you can reuse

The fact that the handler survives the move is worth internalizing, because it shapes how you write function-calling code today. Keep the business logic (lookup_order above) in its own function, keep the schema definition close to it, and keep credentials in the environment rather than inline. When the second client shows up, migrating is an afternoon: wrap the same function in a decorator or a registerTool call, delete the manual schema-passing, and hand the client a config block. Teams that tangle tool logic into their chat loop pay for that tangle twice, once when debugging and again when migrating. This is also the honest answer when a client asks whether starting with function calling paints them into a corner: it does not, provided the tools are written as clean, separately testable functions from day one.

The same server in TypeScript

Python is not the only option, and which SDK you pick matters commercially: if the buyer's team is a Node shop, handing them a Python server means handing them a runtime they do not want to operate. The official TypeScript SDK expresses the same three ideas - a server, a registered tool, a transport:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({ name: "orders", version: "1.0.0" });

server.registerTool(
  "get_order_status",
  {
    title: "Get order status",
    description: "Look up the current status of an order by its numeric order ID.",
    inputSchema: { order_id: z.string().describe("Numeric order ID, e.g. 88231") },
  },
  async ({ order_id }) => {
    const order = await lookupOrder(order_id);
    return { content: [{ type: "text", text: "Order " + order_id + ": " + order.status }] };
  },
);

await server.connect(new StdioServerTransport());

Read the two implementations side by side and the pattern is clear. A name, a human-readable description, a typed input schema, an async handler that calls the same API you already have. Everything else in the file is boilerplate the SDK owns. That is the honest size of MCP as a technology: the protocol is large, the surface you write against is small.

What the extra layer actually costs at runtime

The comparison table above lists the operational costs, but there are two runtime costs worth naming precisely, because clients ask about both and vague answers lose deals.

The first is context. Every tool your server advertises has its name, description, and input schema loaded into the model's context before the model does any work, on every request in that session. A server with forty verbosely described tools spends a meaningful slice of the window before the user has typed anything, and it degrades tool selection too, because the model is choosing from forty near-identical options. This is not an MCP-specific problem - plain function calling has exactly the same cost - but MCP makes it easy to bolt on more servers, and each one adds its whole catalogue. If you want to measure it rather than guess, count the tokens of your own tools/list response; the SDKs will happily print it.

The second is a round trip. With plain function calling, the handler runs inside your process. With MCP over stdio, the call crosses a process boundary; over Streamable HTTP, it crosses the network. In both cases the underlying API call almost always dominates, so the added latency is usually small relative to the work being done - but it is not zero, and for a tool called in a tight loop it is worth measuring on your own stack rather than accepting anyone's published number.

Transports, and which one you actually need

Transport choice follows from where the server runs, and it is the question that trips up most first builds.

  • stdio. The client launches your server as a child process and talks to it over standard input and output. There is no port, no auth layer, no deployment. The server inherits the trust of whoever is sitting at the machine. This is the right default for anything that touches local files, local databases, or a developer's own credentials.
  • Streamable HTTP. Your server is a service at a URL, and multiple users connect to it. Now you own everything a public service owns: authentication, tenant isolation, rate limits, logging, uptime. That is a lot more work, and it is also the only shape you can sell as a hosted product rather than a repo.

A useful rule: start on stdio even if you intend to host it later. The handler code is identical, and you will find your schema and permission bugs far faster without a deployment loop in the way. Promote to HTTP only when a second person needs to reach it from a machine that is not theirs.

Three situations, decided out loud

The decision list above is easier to trust once you have watched it run against real jobs. These are the three shapes that come up most often.

An internal support copilot in one Next.js app. One client, one model, six tools, no plan to expose them elsewhere. Function calling. Adding MCP here buys a process to supervise and a schema layer to maintain in exchange for reuse nobody has asked for. Write the six handlers as standalone exported functions and move on.

A finance team that wants Claude Desktop to read the warehouse. Several people, off-the-shelf clients you do not control, and a hard requirement that nobody can write to the warehouse from a chat window. MCP, immediately - not because of reuse but because of the boundary. The server can expose read-only query tools, refuse anything that is not a SELECT, cap the row count, and log every call with the user attached. There is no equivalent place to enforce that when the tools live inside somebody's app code.

A vertical SaaS wanting its customers' agents to reach its API. Many clients, none of them yours, all of them different. MCP again, and this time it is the product: you publish a server, customers add a config block, and your integration surface is one artefact instead of one per client framework. This is the shape most sellable MCP work takes, and it is why tool descriptions become a commercial concern rather than a stylistic one - covered later in the course.

Testing either approach the same way

Because the handler is just a function in both worlds, the test that matters does not involve a model at all:

def test_get_order_status_unknown_id():
    result = get_order_status.fn("00000")   # FastMCP keeps the plain function on .fn
    assert "not found" in result.lower()
    # and it must not raise - a raised exception reaches the agent as an
    # opaque protocol error instead of something it can recover from

Test the handler directly for correctness, then exercise the protocol layer separately with the MCP Inspector to confirm the schema and description are what you think they are. Mixing the two into one end-to-end "ask the model and see what happens" test is how teams end up debugging a prompt when the actual fault is a required field missing from a JSON Schema.

Setup: a complete server you can run in ten minutes

Everything above is fragments chosen to make a comparison. Here is the whole thing - project setup, a runnable file, the run command, and the client config - using the official Python SDK. Package and API names below follow the current MCP quickstart as of August 2026; the SDK's own MCPServer class is what the official docs use today, and third-party wrappers such as FastMCP expose the same three ideas under different names, so check which one your project depends on before copying either.

# Prerequisites: Python 3.10+ and uv (https://docs.astral.sh/uv/)
uv init orders-mcp
cd orders-mcp
uv venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
uv add "mcp[cli]"
touch orders.py

Now the complete file. Nothing is elided - this runs as written, with a fake datastore standing in for whatever API you actually have:

# orders.py
from mcp.server import MCPServer

mcp = MCPServer("orders")

# Stand-in for your real system. In production this is an HTTP call,
# a database query, or your existing client library - the shape of the
# rest of the file does not change.
_ORDERS = {
    "88231": {"status": "in transit", "eta": "2026-08-14"},
    "88232": {"status": "delivered", "eta": "2026-08-02"},
}


@mcp.tool()
async def get_order_status(order_id: str) -> str:
    """Look up the current status of an order by its numeric order ID.

    Args:
        order_id: Numeric order ID as a string, e.g. "88231"
    """
    order = _ORDERS.get(order_id)
    if order is None:
        # Return a sentence the agent can act on. Do NOT raise here -
        # see the debugging section below for what raising looks like
        # from the client's side.
        return f"No order found with ID {order_id}. Check the ID and try again."
    return f"Order {order_id}: {order['status']}, ETA {order['eta']}"


if __name__ == "__main__":
    mcp.run(transport="stdio")

Run it with uv run orders.py. It will appear to hang - that is correct. A stdio server sits waiting for JSON-RPC messages on standard input; there is no banner and no port. Press Ctrl+C and move on to connecting a client, which is the only way to see it do anything.

// ~/Library/Application Support/Claude/claude_desktop_config.json   (macOS)
// %AppData%\Claude\claude_desktop_config.json                      (Windows)
{
  "mcpServers": {
    "orders": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/orders-mcp",
        "run",
        "orders.py"
      ]
    }
  }
}

Three things about that block cause most first-time failures. The path must be absolute - get it with pwd. command may need the full path to the uv binary, which which uv will give you, because the desktop app does not inherit your shell's PATH. And you must fully quit the client and reopen it: closing the window is not a restart, on either platform, and configuration changes will not be picked up.

Debugging: four failures, and how each one announces itself

The single most useful fact for anyone building their first server: stdio servers must never print to standard output. Standard output is the protocol channel. A stray print() injects text into the JSON-RPC stream and the connection dies with a parse error that names your debug message. Log to stderr instead - with the Python SDK, ordinary logging configured to a stderr handler is fine, and the client captures it for you.

When something is wrong, read the logs before touching the code. On macOS the client writes MCP logs to ~/Library/Logs/Claude: mcp.log holds connection-level events, and one mcp-server-NAME.log per server holds that server's stderr. Follow them live:

tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
What you see What is actually wrong Fix
No MCP indicator in the client at allThe config file is malformed JSON, so nothing loadedValidate the file. A trailing comma is the usual culprit; the client fails silently rather than warning
Server listed but shows as failed, log says command not foundThe app does not inherit your shell PATHPut the absolute path from which uv in command
Connection drops immediately, log shows a JSON parse error containing your own debug textSomething printed to stdoutRemove every print(); route all logging to stderr
Tool appears, model never chooses itThe description does not say when to use the tool, only what it isRewrite the docstring to name the trigger condition: "Use this when the user asks where an order is"
Tool is called, then the agent gives up or apologises vaguelyYour handler raised, so the agent got an opaque protocol error rather than a recoverable messageCatch inside the handler and return a sentence describing the problem and what to try instead
Edits to the code have no effectThe old process is still running; the window was closed, not quitFully quit (Cmd+Q on macOS, tray icon then Quit on Windows) and reopen

The fifth row is the one worth dwelling on, because it is the difference between a demo and something usable. Compare the two handlers:

# Bad: the exception crosses the protocol boundary. The agent sees a
# transport-level failure with no idea what to do next, and typically
# either retries identically or abandons the task.
@mcp.tool()
async def get_order_status(order_id: str) -> str:
    """Look up an order's status."""
    return _ORDERS[order_id]["status"]      # KeyError on any unknown ID

# Good: the failure is data the agent can reason about, so it can ask
# the user for a corrected ID instead of failing the whole task.
@mcp.tool()
async def get_order_status(order_id: str) -> str:
    """Look up an order's status. Use when the user asks where an order is."""
    order = _ORDERS.get(order_id)
    if order is None:
        return f"No order found with ID {order_id}. Ask the user to confirm it."
    return f"Order {order_id}: {order['status']}, ETA {order['eta']}"

The rule generalises: an expected failure - not found, not permitted, rate limited, needs a field you did not get - is a normal return value written as a sentence. Only genuinely unexpected faults should be allowed to raise.

When MCP is the wrong answer

Four cases where the decision list would say yes and you should still not build a server.

  • Your API is already agent-friendly and the consumer is a developer. If the "client" is someone writing code against you, they can call your REST API directly. MCP earns its keep when the consumer is an agent inside an application you do not control.
  • The action is a single webhook. "When X happens, do Y" needs no model in the loop at all. A server here adds a process to supervise in exchange for nothing.
  • You cannot answer who the caller is. A hosted server without a per-user identity has no way to enforce permissions, which was the entire reason for the boundary. If identity is unsolved, solve it before you expose anything that writes - and until then, stdio with the user's own credentials is the honest shape.
  • The tools would need to change every week. Tool names and schemas are a contract with every client that connected. A surface still being designed should stay inside one application until it settles.

Testing the protocol layer without a model in the loop

The handler test above covers correctness. The other half - is the tool advertised the way I think it is - needs the MCP Inspector, which is the official development tool for exactly this, and it is worth building the habit before your first real server rather than after your first confusing bug.

The Inspector connects to your server the way any client would, lists what it finds, and lets you invoke tools by hand with arguments you choose. Three checks, every time you add or change a tool:

  1. Read your own tools/list output. Not the code - the output. This is where you discover that a parameter you thought was required is optional, that a description got truncated, or that a tool you deleted is still being advertised because the process did not restart.
  2. Call the tool with deliberately bad arguments. An empty string, a missing required field, an ID that does not exist. You are checking that each one comes back as a readable message rather than a stack trace, because a stack trace crossing the protocol boundary is the failure mode from the debugging table above.
  3. Count the characters of the full listing. Every tool's name, description and schema sits in the model's context on every request in the session. A listing that has quietly grown to several thousand characters is a real cost you are paying on every turn, and it degrades tool selection at the same time.

The reason to do this before wiring the server into a chat client is the isolation. When you ask a model a question and get a strange answer, the fault could be the prompt, the tool description, the schema, the handler, or the model's judgment. The Inspector removes four of those five from the picture in about a minute, which is why "test the protocol layer separately" is not fussiness - it is the difference between a bug you locate and a bug you argue about.

Common mistakes

  • Building an MCP server for a task a single API call or webhook would have handled, adding a server to maintain for no gain.
  • Assuming MCP replaces your APIs. It sits in front of them, usually calling the same APIs underneath while adding descriptions and permission rules on top.
  • Choosing MCP because it feels modern, then discovering you now maintain a protocol server for one client that will never change.

What you should be able to do now

  • Explain in one sentence what MCP adds over function calling: reuse across clients plus a controlled boundary.
  • Read a plain function-calling integration and identify what would move into an MCP server and what would stay.
  • Write the JSON config entry that connects a local stdio server to Claude Desktop.
  • Decide for a given job whether MCP removes a real constraint, and name that constraint out loud.

Where this goes next

This lesson and the next one are the free part of the course, and they are deliberately the conceptual half: what MCP is, what it costs, and how the five roles fit together. They are enough to decide whether to build a server at all, which is the decision most people get wrong.

The paid lessons are the build. You write a first server in the TypeScript SDK and again in Python with FastMCP, drive both under the MCP Inspector until the schemas are right, then work through the parts that separate a demo from something a company will connect to production: designing narrow tools instead of god-tools, writing tool descriptions the model actually selects correctly, returning errors an agent can recover from, read-only resources, auth and tenant isolation for a hosted server, and the packaging and pricing of a server you intend to sell. Every one of those lessons ships runnable code and the repo.

If you would rather not build it yourself, the same work is something we do as a project - see AI automation services, or start with the free automation audit to find out whether an MCP boundary is even the right first move for your systems. If you are still weighing tooling, the MCP glossary entry and the wider platform comparisons cover the surrounding stack.

The email box below sends the free lessons and the code samples from them, so you have the config blocks and the FastMCP skeleton to hand when you sit down to build. No purchase needed for that part.

Key takeaways

What to remember from this lesson

  • MCP does not replace your APIs. It puts a reusable, permissioned server in front of the same calls you were already making, adding discovery and descriptions on top.
  • The honest one-line answer: MCP buys reuse across clients plus a single boundary you control. If neither is a real constraint, function calling is the cheaper choice.
  • Two runtime costs to name precisely: every advertised tool's schema sits in context on every request, and each call crosses a process or network boundary.
  • Start on stdio even when you plan to host later - the handler code is identical and you will find schema bugs far faster without a deployment loop.
  • Keep business logic in standalone testable functions with credentials in the environment, and migrating to MCP later is an afternoon rather than a rewrite.

Try it yourself

Hand-write a tool definition and validate its schema

Whether you use MCP or plain function calling, the model sees the same thing: a name, a description, and a JSON Schema. Write the definition for a dental practice's appointment lookup. The check validates it the way a strict client would, so every rule it enforces is one a real client enforces too.

Check yourself

Is this a job for MCP, or for a function call?

  1. You have one internal Python script that calls one model, and one API it needs to reach. Nothing else will ever use it. What does putting MCP in front of that API buy you?

  2. Your server advertises 40 tools. A client asks a question that needs exactly one of them. What does the model pay?

  3. You plan to host the server eventually. Should you start on stdio or go straight to HTTP?

Answer every question to mark.

Exercise

Decide the MCP question for a real system, out loud

25 min
  1. 1Pick a real system you or a client operates and list the 3-6 actions an agent would need against it. Write each as a function name plus its inputs.
  2. 2Answer the three decision questions in writing: will more than one client use these tools; do you need a permission boundary that survives client changes; is this a one-off inside one product.
  3. 3Write your verdict as one sentence in this form: 'MCP / function calling, because the constraint it removes is ___.' If you cannot name a constraint, the answer is function calling.
  4. 4If your verdict is MCP, choose stdio or Streamable HTTP and justify it by where the server runs and who reaches it - not by which sounds more production-ready.
  5. 5Take the FastMCP orders example from the lesson and rewrite it against one of your own actions, keeping the business logic in a separate function the decorator calls.
  6. 6Write the Claude Desktop config block that would launch your server, with an absolute path and the credential in `env` rather than inline in the code.

You are done when You have a one-sentence verdict that names a specific constraint MCP does or does not remove, a transport choice justified by where the server runs, and a config block whose command, absolute path, and env credential you could paste into a client without editing the handler.

Companion files

Both implementations of the same tool

The plain function-calling client and the FastMCP server side by side, plus the Claude Desktop config entry and a requirements file - so you can run the comparison in this lesson rather than read it.

The free-preview pack includes 6 files of runnable code and config for MCP vs Plain Function Calling, plus the other free lessons of this course. No email needed.

Free preview pack - 10 KB zip

Check yourself

Answer before you reveal

A team says 'we started with function calling and now we are locked in'. Are they?Show answer

No, provided the tool logic lives in clean, separately testable functions with credentials in the environment. Migrating is wrapping the same function in a decorator or registerTool call, deleting the manual schema passing, and handing over a config block.

A finance team wants Claude Desktop to read the data warehouse, with no writes possible from a chat window. Which approach, and what is the deciding reason?Show answer

MCP - and the reason is the boundary, not reuse. The server can expose read-only query tools, refuse anything that is not a SELECT, cap row counts, and log every call with the user attached. There is nowhere to enforce that when the tools live inside app code.

Your test asks the model a question and checks the answer. Why is that the wrong test for a tool handler?Show answer

It mixes two layers. Test the handler directly as a plain function for correctness, and exercise the protocol layer separately in the MCP Inspector to confirm the schema and description. Otherwise you end up debugging a prompt when the real fault is a required field missing from a JSON Schema.

Free lesson notes

Get the notes pack for Build and Sell MCP Servers Course, plus every new module free by email.

No card, no spam, unsubscribe any time.