By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Three teams call the same internal pricing service. One wrote a Python client, one wrote a TypeScript client and one copied the first. Each has its own retry rule, and only one of them sends the token the service now requires.
The fourth team solved it in an afternoon. They wrapped the pricing service in a Model Context Protocol (MCP) server, and every client connected to that server instead of rebuilding the API.
MCP is an open protocol for connecting a model client to tools and data. The server publishes capabilities, and the client — Claude Code or your own Agent SDK application — connects, lists them and calls them. The contract is the protocol, so a new client is configuration instead of code.
One server, because three clients share one capability and one credential. Write a custom tool instead when the capability is private to one application: a second process buys you nothing there.
Before you build, choose the cheapest layer that closes the gap. Each layer adds a different kind of cost.
| Layer | What it adds | What it costs | Choose it when |
|---|---|---|---|
| Built-in tool | A capability the client or provider already wires up | Nothing to build; you accept its schema | It already does exactly what you need |
| Skill | A saved procedure, loaded when the task matches | Authoring and review; no new runtime | The tools exist, but the model does the work in the wrong order |
| Custom tool | One function your application owns | Schema, auth, retries and logging are yours | One application needs one capability |
| MCP server | A capability served over a protocol | A process, a deployment and a version pin | Several clients need it, or another team owns it |
A Skill does not add a capability. It packages a procedure — the steps your team follows, plus any scripts the model may run — and loads when the task matches. Use one when the model can already reach the systems but follows your process badly.
Three capabilities cover most servers. Tools are actions the model can call, with a name, a description and an input schema, like the client tools from step 30. Resources are readable data at a fixed address, such as a file or a record. Prompts are templates a person invokes on purpose.
| Capability | Who invokes it | Example | Design question |
|---|---|---|---|
| Tool | The model | create_ticket | Does the description route and bound the call? |
| Resource | The client, for context | orders://A17 | Is it small, current and safe to read? |
| Prompt | The user | a refund-review template | Is it a shortcut, not a hidden loop? |
Tools do; resources are. A tool changes or computes something, and the model decides to call it. A resource is data the client pulls into context when it is relevant, with no action attached. If a capability only needs to be read, publish a resource and keep the write path small.
Every tool needs its own description, because the model chooses among server tools with the same rules as before. In most SDKs the docstring becomes that description, so write it as a routing rule, not a note to yourself.
# orders_mcp/server.py -- pip install "mcp[cli]"
import json
from mcp.server.fastmcp import FastMCP
ORDERS = {
"A17": {
"order_id": "A17",
"status": "shipped",
"items": ["desk lamp"],
"delivery_date": "2026-11-14",
}
}
mcp = FastMCP("orders")
@mcp.tool()
def lookup_order(order_id: str) -> dict:
'''Read one order by its id.
Use this when the customer has an order id. Do not search by customer
name; call get_customer first. Returns status, items and delivery date,
or a not_found code.
'''
order = ORDERS.get(order_id)
if order is None:
return {"code": "not_found", "order_id": order_id}
return order
@mcp.resource("orders://{order_id}")
def order_record(order_id: str) -> str:
'''Read-only record the client can load into context on demand.'''
return json.dumps(ORDERS.get(order_id, {"code": "not_found"}))
if __name__ == "__main__":
mcp.run() # stdio by default
# Network serving: mcp.run(transport="streamable-http")The run() call is the whole deployment shape for a local server. The client starts this process, so messages travel over standard input and output, and nothing listens on a port.
In Claude Code, a project declares its servers in .mcp.json at the repository root. A local server needs a command, its args and optional env. A remote server needs a type and a url.
{
"mcpServers": {
"orders": {
"command": "python",
"args": ["-m", "orders_mcp.server"],
"env": {
"ORDERS_DB_URL": "${ORDERS_DB_URL}",
"ORDERS_TOKEN": "${ORDERS_TOKEN}"
}
},
"tickets": {
"type": "http",
"url": "https://mcp.internal.example.com/mcp",
"headers": {
"Authorization": "Bearer ${TICKETS_TOKEN}"
}
}
}
}The transport is how the client reaches the server. With stdio, the client starts the server as a child process and exchanges JSON remote procedure call (JSON-RPC) messages over standard input and output. With a socket or HTTP transport, the client connects to a server that is already listening.
Choose stdio when the server ships with the repository and uses the developer's credentials. Choose a network transport when several clients share one server and you want one place to audit access.
Pin the SDK and the server version, and build the same image for your laptop and your runner.
Read configuration from the environment and fail at startup when a required variable is missing.
Log one line per tool call: tool name, a hash of the arguments, duration and outcome code.
Set a per-call timeout and a per-turn retry cap, and return isError instead of raising.
Authenticate every caller, and let the server act with that caller's identity, never a shared superuser.
Keep the previous version deployable, so a bad release is a version pin change rather than an incident.
A remote server is code you run for other people. Treat its results as untrusted: tool output reaches the model and can carry instructions.
.mcp.json with a ${VAR} reference for every credential and a pinned version.Key takeaways
MCP is an open protocol: a server publishes tools and resources, and any client can connect to it.
Choose the cheapest layer that closes the gap: built-in tool, then Skill, then custom tool, then MCP server.
Tools do and resources are; a resource is data the client reads, not an action the model takes.
Declare servers in .mcp.json with command, args and env, and reference secrets with ${VAR}.
stdio runs a local child process; HTTP reaches a shared server. Know which one you are operating.
Deploy the server like a service: pinned version, startup checks, per-call logs, timeouts and rollback.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.