Write get_invoice as a plain function, then put it behind an MCP server, and the model’s half of the conversation doesn’t change. The model sees a name, a description and a JSON Schema for the arguments, and it answers with a name and some JSON. That’s all function calling has been since OpenAI shipped it in mid-2023, and Claude tool use and Gemini function calling work the same way.
So when the plan is to move to MCP so the agent gets better at using tools, my first question is what anyone expects to change. The Model Context Protocol leaves the model’s side of the exchange alone. What it standardizes is the stretch between your application and the code that does the work.
What happens on the wire, both ways
With a plain tool call, your application holds a list of tool definitions and a matching set of functions. It sends the definitions with the prompt. The model replies with a call, your loop looks up the function, runs it, and sends the result back. Everything lives in one process.
With MCP, the function moves into a separate tool server. A protocol client inside your application connects to it, asks for the tool list, and turns that list into the same definitions you would have written by hand. The model replies with the same call. The client forwards it to the server, the server runs the function, and the result comes back along the same path.
The second version adds one hop and a discovery step. In return, the person who wrote the tool and the person who wrote the application no longer have to be the same person or ship on the same day.
The same get_invoice tool, twice
Here it is in process, using the Claude tool definition format. The OpenAI and Gemini versions differ in field names and little else.
import json
import httpx
BILLING = "https://billing.internal.example/api"
GET_INVOICE = {
"name": "get_invoice",
"description": "Fetch one invoice by its number, for example INV-2025-00417. "
"Returns status, amount due, currency and due date.",
"input_schema": {
"type": "object",
"properties": {
"invoice_number": {"type": "string", "pattern": "^INV-[0-9]{4}-[0-9]{5}$"},
},
"required": ["invoice_number"],
"additionalProperties": False,
},
}
def get_invoice(invoice_number: str, user_token: str) -> dict:
r = httpx.get(f"{BILLING}/invoices/{invoice_number}",
headers={"Authorization": f"Bearer {user_token}"}, timeout=5.0)
if r.status_code == 404:
return {"error": f"No invoice {invoice_number}. Confirm the number with the user."}
r.raise_for_status()
inv = r.json()
return {k: inv[k] for k in ("number", "status", "amount_due", "currency", "due_date")}
TOOLS = [GET_INVOICE] # sent to the model with every request
HANDLERS = {"get_invoice": get_invoice}
def run_tool(block, user_token: str) -> dict:
# block is a tool_use content block from the model's response
result = HANDLERS[block.name](**block.input, user_token=user_token)
return {"type": "tool_result", "tool_use_id": block.id, "content": json.dumps(result)}
And as an MCP server, with the official Python SDK:
import json
import os
import re
import httpx
from mcp.server.fastmcp import FastMCP
BILLING = "https://billing.internal.example/api"
INVOICE_NUMBER = re.compile(r"INV-[0-9]{4}-[0-9]{5}")
mcp = FastMCP("ottery-invoices")
@mcp.tool()
def get_invoice(invoice_number: str) -> str:
"""Fetch one invoice by its number, for example INV-2025-00417.
Returns status, amount due, currency and due date."""
# The generated schema is just {"type": "string"}, so check the format here.
if not INVOICE_NUMBER.fullmatch(invoice_number):
return json.dumps({"error": "invoice_number must look like INV-2025-00417."})
r = httpx.get(f"{BILLING}/invoices/{invoice_number}",
headers={"Authorization": f"Bearer {os.environ['BILLING_TOKEN']}"},
timeout=5.0)
if r.status_code == 404:
return json.dumps({"error": f"No invoice {invoice_number}. Confirm the number with the user."})
r.raise_for_status()
inv = r.json()
return json.dumps({k: inv[k] for k in ("number", "status", "amount_due", "currency", "due_date")})
if __name__ == "__main__":
mcp.run(transport="stdio")
The server version saves you some typing: the SDK builds the schema from the type hints and the docstring, and the client fetches it instead of you registering it. The pattern I wrote by hand in the first version is gone from that schema, which is why the function checks the format itself.
Look at the Authorization header, though. In process, the function gets the token of the user who is chatting, because the application already has it. The server reads a credential from its own environment. It has no idea who is on the other end unless you build a way to tell it, and until you do, every caller gets whatever that one credential can see. That gap is the real cost of the move, and it doesn’t show up in a line count.
The March revision of the specification added an OAuth-based flow for remote servers, where callers have to prove who they are over HTTP. It’s a month old, and I’d expect SDKs and clients to take a while to agree on it. I wouldn’t plan a finance tool around it yet.
Five questions that decide it
| Question | Stay in process | Put it behind a tool server |
|---|---|---|
| Who owns the tools? | The team that owns the application | Another team, or a vendor |
| How many clients call them? | One | Two or more, at least one you don’t build |
| Does a client need to discover tools at runtime? | No, the list ships with the app | Yes, the client can’t be redeployed for each new tool |
| Where is the auth boundary? | Inside the app, with the user’s own token | At the server, which has to authenticate callers itself |
| What’s the latency budget? | Tight, many calls per turn | Loose enough for an extra hop per call |
If every answer lands in the left column, a tool server gives you a second deployable, a second set of logs and a new place to get authorization wrong. You’d be paying for interoperability with clients that don’t exist.
If even one client is outside your control, the right column pays for itself quickly. A desktop assistant you didn’t write can’t import your Python module. It can connect to a server.
Ottery Rail moves two tools out of six
To make this concrete, I’ll invent a company. Ottery Rail’s finance team runs one internal chat application with six tools: get_invoice, get_vendor, list_open_purchase_orders, get_budget_line, draft_journal_entry and flag_for_review. All six are in-process functions. The median tool round trip is 40 ms, and a change to any tool goes out in the same deploy as the application.
Then procurement buys a vendor’s desktop assistant that speaks MCP, and the people using it want to look up invoices and vendors without switching windows.
The tempting move is to put all six tools behind a server “for consistency” and point the chat application at it too. I’d argue against that. Four of the six tools have exactly one caller. Two of them write data, and in process they run with the user’s own permissions for free. Moving them means rebuilding that check at the server for no new capability.
So Ottery moves two. get_invoice and get_vendor go behind a small tool server with a read-only billing credential scoped to what the vendor assistant is allowed to see. The other four stay where they are, at 40 ms and one deploy.
That leaves one choice: the chat application can call the two moved tools through the server, or keep its own in-process copies. I’d go through the server, so there is one implementation of each tool, and accept the extra hop on two read-only lookups. Nothing stops a client from handling both kinds of tool. The application loop can merge its local function definitions with the list it fetched from the server, and the model sees a single flat list.
What Ottery ends up with is a mixed setup, and I think that’s where most teams should land this year. Start with a function. Promote it to a server on the day a second client shows up that you can’t redeploy, and write down whose identity the server acts under before you write any code for it.