Back to Learning Area

Using Interfaces: APIs & MCP

When software talks to models, someone needs the vocabulary — APIs and MCP do that.

  • Architectures
  • 10 min
  • Intermediate

Plain Language

This preview is in Plain Language. The whole portal is also available in Plain Language. You can change the language at the top. Or use the button below. Our Plain Language texts are AI-assisted and editorially reviewed. They follow the core principles of easy-to-read language, but they are not certified Easy Read: a review panel of people with learning difficulties does not test them.

Preview: Interfaces and AI tools

What is an API?

An API is an interface. Interface means: a connection point between programs. You send a request to the program. The program sends an answer back. This is how AI programs speak with other programs.

MCP connects all tools

Many AI programs need many connections. MCP makes this easier. MCP means: a standard for AI connections. It is like a USB-C cable for AI. All programs use the same cable.

What is an AI agent?

An agent is an AI program. It does tasks by itself. It plans a step. Then it performs it. Then it checks the result. This is how it works step by step.

You have seen what a language model can do when you type into a chat window. But software does not type — it sends structured requests through an API.

This article takes you from your first API call to the protocol that could standardize how all AI tools connect: MCP. Along the way, you will learn what these calls cost, why 50 custom integrations are a problem, and how four building blocks turn a single model into an acting agent.

From Chat Window to Code

The moment you move from a chat UI to code, the model becomes a service you call — like any other web API.

Definition

LLM API

Analogy

Think of a restaurant counter. You fill out an order form (the JSON request) specifying what you want: model, messages, temperature. You hand it to the counter staff along with your membership card (API key). The kitchen (the model) processes your order and sends back a tray (JSON response). You pay for the length of your order form and for what comes back on the tray, not per visit.

Important: you do not choose the ingredients — you have no access to the model's internal workings.

A minimal Python call looks like this (keep the real key in an environment variable, never directly in the code):

from openai import OpenAI
client = OpenAI()  # reads OPENAI_API_KEY from the environment
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What is DNA?"}]
)
print(response.choices[0].message.content)

Billing is split between input and output tokens.

Example with GPT-4o pricing (an older model that OpenAI removes from the API on January 14, 2027): 30 input tokens × USD 2.50 per million = USD 0.000075. 100 output tokens × USD 10.00 per million = USD 0.001. Total: about USD 0.001 — roughly one tenth of a cent.

At 1,000 calls per day: about USD 1.08. At 100,000 calls per day: about USD 107.50.

Per Call

~0.1  cents

Cost of a single GPT-4o API call

At 100k Calls/Day

~107.5  USD

Daily cost at high volume

Fewer Integrations

70 %

Savings through MCP with 5 apps and 10 tools (N+M instead of N×M)

Caution

Common Misconception: APIs Are Expensive

Individual short calls often cost only fractions of a cent. The cost risk lies in volume and long context windows — not in single requests. Think of API costs like a water bill: the per-liter price is tiny, but leaving the tap open drains the budget.

Interactive: What Happens During an API Call?

Click Play and watch step by step what happens behind the scenes when your code calls an API — from the browser through DNS and TLS to the JSON response.

The Journey of an HTTP Request

This animation shows the six stations every API call passes through — from the click in the browser to the JSON response.

BrowserEnter URLCLIENTDNS→ IP AddressRESOLUTIONTCP/TLSHandshakeCONNECTIONGET /apiHeader + BodyREQUEST⚙SERVER200 OK{ "temp": 22 }RESPONSEJSON Data
Start animation

Click "Play" to see the process step by step.

Why Does This Matter?

Every API call — whether to OpenAI, Claude, or your own REST API — goes through these steps (DNS lookup and handshake usually only on the first call; after that the connection is reused). Understanding what happens helps you diagnose errors (timeouts, 404, CORS) much faster.

One Plug for Everything — MCP

You have just seen how one app talks to one model. Now imagine five apps, each needing ten different tools. Without a standard, that is 50 integrations. This is the N-times-M problem.

Definition

Model Context Protocol (MCP)

Analogy

USB-C for AI. Before USB-C, every device had its own cable — phone charger, camera cable, external drive connector. With 5 devices and 10 accessories, you needed up to 50 different cables. USB-C reduced this to one standard plug: each device and each accessory just needs one USB-C port. MCP does the same for AI integrations.
Without MCP

5 apps × 10 tools = 50 custom integrations to build and maintain.

With MCP

5 MCP clients + 10 MCP servers = 15 implementations. That is a 70% reduction.

Key difference: USB-C is a mature, universal standard. MCP is young (2024); ChatGPT, Gemini and Microsoft Copilot now support it, but it is not yet universally adopted.

Architecturally, MCP forms a triangle: the MCP server exposes tools, the client manages the connection, and the LLM decides when to use which tool. Concrete example: Claude Desktop connects to filesystem, SQLite, and GitHub through three MCP servers — one protocol, three capabilities.

Caution

Important: MCP Is Not a Universal Replacement

MCP does not replace all APIs. Direct integrations remain necessary for specialized SaaS services where no MCP server exists yet. MCP standardizes how AI discovers and invokes tools — not how the tool works internally.

Anatomy of an Agent

An API call is a question with one answer. An agent is a loop — it plans, acts, observes, and decides whether to continue. This loop needs four building blocks.

Brain (LLM) Plans and interprets — decides which tool to use and when
Hands (Tools) Execute actions — each tool has a specific function
Memory (Context) Stores history, documents, and intermediate results across steps
Conductor (Orchestration) Controls flow, handles errors, and determines stopping conditions

Think of a head chef managing dinner service.

The chef's brain is the LLM — reading orders, deciding what to cook, and prioritizing. The chef's hands are the tools — knife, stove, oven, each with a specific function. The order tickets above the pass are the context — they track what has been ordered, what is in progress, what is done. The kitchen workflow is the orchestration: starters first, then mains, then desserts, check timing.

Like a real chef, an agent can also make mistakes — picking the wrong tool or misreading an order.

  1. 1. Receive Task
  2. 2. PlanLLM chooses tool
  3. 3. Executetool runs
  4. 4. Observeresult returns
  5. 5. Decidecontinue or stop

Example: A Travel-Booking Agent

Step 1: The user says: Book me a flight to Berlin next Tuesday. Step 2: The LLM reads the calendar (context) — Tuesday is March 24. Step 3: The LLM calls the flight-search tool — three options found. Step 4: The LLM compares prices and times, selects the cheapest morning flight. Step 5: The LLM asks the user for confirmation (safety gate). Step 6: User confirms. Step 7: The LLM calls the booking tool. Step 8: Orchestration checks the result — booking confirmed — loop ends.

Caution

Common Misconception: Agents Are Freely Improvising AI

Today's agents are only as capable as their tools, permissions, and safety boundaries. They do not improvise — they follow a plan-act-observe loop within defined guardrails. An agent without tools is a chatbot. An agent without guardrails is a liability.

LangChain: Broad integration ecosystem — many connectors, many possibilities.

LlamaIndex: RAG-focused — document processing and knowledge retrieval as core strengths.

CrewAI: Multi-agent collaboration — agents with defined roles working together.

Claude Agent SDK: Claude Code's agent loop and tools as a library, with built-in MCP support.

This overview is a signpost, not a benchmark. Each framework has its own emphasis.

Note

Key Takeaways

  1. An API call is an HTTP POST with JSON — the same mental model you already know from web development, applied to language models.
  2. MCP turns many-to-many integration chaos (N times M) into a manageable many-plus-many structure (N plus M) by standardizing how tools expose their capabilities.
  3. An agent is not magic — it is a loop of four components (LLM, Tools, Context, Orchestration) repeating until a stopping condition is met.

Check

Knowledge Check: APIs & MCP

Not completed

What is the primary role of an API key when calling an LLM API?

Select one answer

Answer Key: 1) B · 2) C · 3) C · 4) B · 5) D · 6) A

Check

Self-Check: APIs & MCP

Can you explain this in your own words? Tick what you've got.

0 of 3 done