GyaanStack. Blog

Articles / mcpagentspython

UTCP vs MCP: the same API exposed both ways, with measured latency and the real trade-offs

One REST API exposed through a UTCP manual and through an MCP server, with runnable Python, measured latency, a credential test, the MCP bridge, and where WebMCP and Agent Skills fit.

By Raghunath · · 17 min read

UTCP, the Universal Tool Calling Protocol, is the tool-calling proposal that argues you should not need an MCP server at all. Its site has a long UTCP vs MCP page with a latency table that says MCP adds 25 to 100 percent overhead per call. The page gives no method for those numbers, so this post builds the comparison and measures it.

One small REST API is exposed twice: once through a UTCP manual, once through an MCP server that wraps it. The same two tools, the same client machine, 500 timed calls per path. Versions used: utcp 1.2.0, utcp-http 1.1.15, utcp-mcp 1.2.0, mcp 2.3.0 (spec revision 2026-07-28), Python 3.15.2 on an Apple-silicon Mac. No model and no API key are involved.

If MCP itself is new to you, read MCP from zero first. The MCP reference guide covers the current spec.

The one-paragraph difference#

MCP puts a server between the agent and the tool. The agent speaks JSON-RPC to the server, and the server calls the real API. UTCP removes that server. The API publishes a JSON document called a manual that says "this tool is a GET to this URL with this header", and the agent's client library makes that HTTP call itself.

MCP     agent --JSON-RPC--> MCP server --HTTP--> REST API
UTCP    agent --------------HTTP---------------> REST API
              (after reading GET /utcp once)

Everything else in the comparison follows from where that middle box sits: latency, who holds the API key, what breaks when the API changes, and what you can audit.

The API both sides share#

An ordinary FastAPI app with two routes and an API-key header. The only UTCP-specific part is the /utcp route, which returns the manual.

# api.py: an ordinary REST API, plus one extra route that serves a UTCP manual
from fastapi import FastAPI, Header, HTTPException

app = FastAPI(title="Bookshop API", version="1.0.0")

BOOKS = {
    "b1": {"id": "b1", "title": "Designing Data-Intensive Applications", "price": 3200, "stock": 4},
    "b2": {"id": "b2", "title": "The Pragmatic Programmer", "price": 2100, "stock": 0},
    "b3": {"id": "b3", "title": "Fluent Python", "price": 2800, "stock": 9},
}


@app.get("/books/{book_id}")
def get_book(book_id: str, x_api_key: str = Header(default="")):
    if x_api_key != "demo-key":
        raise HTTPException(401, "missing or wrong X-Api-Key")
    if book_id not in BOOKS:
        raise HTTPException(404, f"no book with id {book_id}")
    return BOOKS[book_id]


@app.get("/search")
def search_books(q: str, x_api_key: str = Header(default="")):
    if x_api_key != "demo-key":
        raise HTTPException(401, "missing or wrong X-Api-Key")
    return [b for b in BOOKS.values() if q.lower() in b["title"].lower()]


AUTH = {"auth_type": "api_key", "api_key": "${BOOKSHOP_KEY}",
        "var_name": "X-Api-Key", "location": "header"}


@app.get("/utcp")
def utcp_manual():
    base = "http://127.0.0.1:8123"
    return {
        "manual_version": "1.0.0",
        "utcp_version": "1.2.0",
        "tools": [
            {
                "name": "get_book",
                "description": "Get one book by id, with price in rupees and stock count.",
                "inputs": {"type": "object",
                           "properties": {"book_id": {"type": "string"}},
                           "required": ["book_id"]},
                "tool_call_template": {"call_template_type": "http",
                                       "url": base + "/books/{book_id}",
                                       "http_method": "GET", "auth": AUTH},
            },
            {
                "name": "search_books",
                "description": "Search book titles by substring.",
                "inputs": {"type": "object",
                           "properties": {"q": {"type": "string"}},
                           "required": ["q"]},
                "tool_call_template": {"call_template_type": "http",
                                       "url": base + "/search",
                                       "http_method": "GET", "auth": AUTH},
            },
        ],
    }

Run it with uvicorn api:app --port 8123.

A tool in a manual has the parts an LLM needs (name, description, an inputs JSON Schema) plus a tool_call_template that the model never sees. The template is the calling instruction. {book_id} in the URL is filled from the tool arguments, and arguments that match nothing in the URL, body or headers become query parameters, which is how q reaches /search. ${BOOKSHOP_KEY} is a variable the client resolves from its own configuration, so the manual names the secret without containing it.

Side A: the UTCP client#

# utcp_demo.py: discover the manual, list tools, call them
import asyncio

from utcp.utcp_client import UtcpClient


async def main():
    client = await UtcpClient.create(config={
        "variables": {"bookshop_BOOKSHOP_KEY": "demo-key"},
        "manual_call_templates": [{
            "name": "bookshop",
            "call_template_type": "http",
            "url": "http://127.0.0.1:8123/utcp",
            "http_method": "GET",
        }],
    })
    for t in await client.search_tools("book", limit=10):
        print("tool:", t.name)
    print(await client.call_tool("bookshop.get_book", {"book_id": "b3"}))
    print(await client.call_tool("bookshop.search_books", {"q": "python"}))
    try:
        print(await client.call_tool("bookshop.get_book", {"book_id": "zz"}))
    except Exception as e:
        print("error:", type(e).__name__, e)


asyncio.run(main())

Install with pip install utcp utcp-http. Output, with the library's INFO log lines removed:

tool: bookshop.get_book
tool: bookshop.search_books
{'id': 'b3', 'title': 'Fluent Python', 'price': 2800, 'stock': 9}
[{'id': 'b3', 'title': 'Fluent Python', 'price': 2800, 'stock': 9}]
error: ClientResponseError 404, message='Not Found: no book with id zz', url='http://127.0.0.1:8123/books/zz'

Two details are easy to miss. Tool names are namespaced as manual.tool. Variables are namespaced too: the manual registered as bookshop can only read variables prefixed bookshop_, so the config key is bookshop_BOOKSHOP_KEY. A second manual cannot ask for the first one's key by name.

The 404 arrives as the HTTP client's own exception with the status code and the API's message intact. That part of the UTCP pitch holds: nothing rewrote the error on the way.

An OpenAPI spec works as a manual#

FastAPI already serves /openapi.json. Pointing the same client at that URL instead of /utcp registered three tools with no manual written by hand:

shop.get_book_books__book_id__get
shop.search_books_search_get
shop.utcp_manual_utcp_get

The call returned the right book. The rough edges are visible in the names, which come from FastAPI's operation ids, and in the auth handling. The API key in this app is a plain header parameter, not an OpenAPI security scheme, so the converter exposed x-api-key as a tool argument. A model would be asked to supply the key itself. Declare a real securitySchemes entry before using the converter on an API with credentials.

Side B: the MCP server#

The same two tools as an MCP server. It holds the API key and proxies each call.

# mcp_server.py: the same two tools as an MCP server that proxies to the REST API
import os
import sys

import httpx
from pydantic import BaseModel
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError

API = "http://127.0.0.1:8123"
server = MCPServer("bookshop")
http = httpx.AsyncClient(base_url=API, headers={"X-Api-Key": os.environ["BOOKSHOP_KEY"]})


class Book(BaseModel):
    id: str
    title: str
    price: int
    stock: int


async def _get(path: str, **params):
    r = await http.get(path, params=params)
    if r.status_code >= 400:
        raise ToolError(f"bookshop API returned {r.status_code}: {r.json().get('detail')}")
    return r.json()


@server.tool()
async def get_book(book_id: str) -> Book:
    """Get one book by id, with price in rupees and stock count."""
    return await _get(f"/books/{book_id}")


@server.tool()
async def search_books(q: str) -> list[Book]:
    """Search book titles by substring."""
    return await _get("/search", q=q)


if __name__ == "__main__":
    if sys.argv[1:] == ["http"]:
        server.run(transport="streamable-http", host="127.0.0.1", port=8124)
    else:
        server.run()
# mcp_demo.py: list and call the same tools through the MCP server
import asyncio

from mcp import Client


async def main():
    async with Client("http://127.0.0.1:8124/mcp") as client:
        tools = await client.list_tools()
        for t in tools.tools:
            print("tool:", t.name)
        r = await client.call_tool("get_book", {"book_id": "b3"})
        print(r.structured_content)
        r = await client.call_tool("search_books", {"q": "python"})
        print(r.structured_content)
        r = await client.call_tool("get_book", {"book_id": "zz"})
        print("is_error:", r.is_error, "|", r.content[0].text)


asyncio.run(main())

Start the server with BOOKSHOP_KEY=demo-key python mcp_server.py http, then run the client:

tool: get_book
tool: search_books
{'id': 'b3', 'title': 'Fluent Python', 'price': 2800, 'stock': 9}
{'result': [{'id': 'b3', 'title': 'Fluent Python', 'price': 2800, 'stock': 9}]}
is_error: True | Error executing tool get_book: bookshop API returned 404: no book with id zz

The server file is 45 lines against 29 for the manual route, so the "10 lines versus 50+" claim on the UTCP page did not show up at this size. The real cost is different: the MCP server is a second program to deploy, and its tool list is a second description of the API that can drift from the first. Here the idle server process used 83 MB of memory, inside the 50 to 200 MB range the UTCP page quotes.

The error case shows the translation the UTCP page complains about. The client sees is_error: True and a string. The 404 survives only because _get wrote it into the message. A wrapper that raised a bare exception would have hidden it.

Latency: what the extra hop costs#

Each path made 50 warm-up calls and then 500 timed sequential calls to get_book, all on loopback. The two "direct" rows call the REST API with a bare HTTP client and no protocol library, as a floor for each stack. UTCP is built on aiohttp and the MCP SDK on httpx, so each has its own floor.

Path p50 p95
Direct, aiohttp 0.41 ms 0.44 ms
UTCP call_tool 1.16 ms 1.22 ms
Direct, httpx 0.89 ms 0.94 ms
MCP over Streamable HTTP 2.22 ms 2.39 ms
MCP over stdio 2.17 ms 2.33 ms

Three repeated runs gave p50 ranges of 1.15 to 1.35 ms for UTCP, 2.2 to 2.8 ms for MCP over HTTP and 1.7 to 2.2 ms for MCP over stdio.

MCP was about twice as slow per call, and the absolute gap was about 1 ms. The UTCP page's table shows gaps of 10 to 50 ms. A gap that size needs the MCP server to sit a network round trip away from the API it wraps, which is a deployment choice. A stdio server on the same machine, or a remote server in the same region as its API, adds low single-digit milliseconds. An LLM turn that decides to call the tool takes hundreds of milliseconds or more, so the hop is rarely what a user feels.

Two more numbers from the same runs:

  • Setup. Loading the manual took about 26 ms. Connecting to the HTTP MCP server and listing tools took about 21 ms. Starting the stdio server as a subprocess took 400 to 600 ms.
  • UTCP's own overhead. call_tool is 0.75 ms slower than the bare aiohttp call. The HTTP plugin opens a new aiohttp.ClientSession for every call (http_communication_protocol.py, line 345 in 1.1.15), so each call pays for a new TCP connection. The UTCP page lists "connection pooling" as a benefit; this version does not pool. Against a remote HTTPS API that means a TLS handshake per tool call, which will cost more than the MCP hop measured here.

Where the API key lives#

This is the difference that should drive the decision more than latency.

With MCP, the server holds the key. In the code above it comes from the server's environment, and the agent process never sees it. The agent can only do what the server's tools allow. If get_book is the only tool, there is no way for a prompt-injected model to reach DELETE /books/b1.

With UTCP, the agent's client holds the key and sends it wherever the manual says. To see what that means, a second server on port 8126 served a manual whose get_book tool pointed at a different origin, port 8127, and asked for ${BOOKSHOP_KEY} in a header. The client was configured to trust that manual under the name bookshop:

registered: ['bookshop.get_book']
{'id': 'b3', 'title': 'looks normal'}
key received by the other origin: ['demo-key']

The key went to the origin the manual named. Nothing here is a bug. It is the design: a manual you trust with a credential decides where that credential is sent. The practical rules follow from that.

  • Treat a manual like code you are about to run. Fetch it only from the API owner's own domain over HTTPS, and pin or review it when it changes.
  • Give each manual its own narrowly scoped key. The namespacing above stops manual A from reading manual B's variable, but only if you did not hand both the same key.
  • Per-tool authorization has to exist in the API itself. There is no middle layer to add it.

The client does carry real protections. The same rogue manual also declared a cli tool that would run a shell command. The client refused to register it:

Tool 'cleanup' uses communication protocol 'cli' which is not in allowed protocols ['http'] for manual 'bookshop'. Tool will not be registered.

A manual fetched over HTTP can only define HTTP tools unless you list more in allowed_communication_protocols. The HTTP plugin also rejects plain http:// to anything except loopback, blocks tool URLs whose host is filled from a tool argument and resolves to loopback, and strips auth headers on cross-origin redirects. Its source says the invocation-time URL check was added after an SSRF report (issue #83), so use a current release.

Using both: the MCP bridge#

utcp-mcp lets a UTCP client call existing MCP servers through a call template of type mcp, so one client can mix native manuals and MCP servers:

"manual_call_templates": [
    {"name": "bookshop", "call_template_type": "http",
     "url": "http://127.0.0.1:8123/utcp", "http_method": "GET"},
    {"name": "legacy", "call_template_type": "mcp",
     "config": {"mcpServers": {"bookshop": {
         "transport": "http", "url": "http://127.0.0.1:8124/mcp"}}}},
]
tool: bookshop.get_book
tool: bookshop.search_books
tool: legacy.bookshop.get_book
tool: legacy.bookshop.search_books

It worked, with three findings worth knowing before you depend on it.

  1. utcp-mcp 1.2.0 requires mcp<2, so the bridge runs the 1.x client (1.30.0 here). It still talked to the 2.3.0 server, because that server answers older clients. Features that exist only in the 2026-07-28 revision are out of reach through the bridge.
  2. The plugin depends on langchain 0.3 and mcp-use. On Python 3.15 that import chain crashed, so the bridge test ran in a Python 3.13 environment. utcp and utcp-http alone ran fine on 3.15.
  3. The first version of the MCP server returned a plain dict from get_book, which gives the tool no output schema. The bridge then failed to register the whole server with 1 validation error for Tool: outputs. Typing the return value as the Book model fixed it.

A bridged call took 5.8 ms at p50, slower than either native path. The bridge is client-side only. Neither the UTCP site nor the README describes exposing UTCP tools as an MCP server.

What the UTCP page gets right and wrong#

Claim on utcp.io What the test showed
No wrapper server needed True. One route and a static JSON document.
MCP adds 25 to 100% latency, 10 to 50 ms About 2x per call, but about 1 ms absolute on one machine. Tens of milliseconds only if the MCP server is far from its API.
Native HTTP performance with connection pooling No pooling in utcp-http 1.1.15. A new session per call.
Native errors preserved True for HTTP status and message.
MCP server uses 50 to 200 MB 83 MB idle for this one.
MCP needs session handling Dated. The 2026-07-28 revision removed sessions and the initialize handshake.
~10 lines vs ~50+ lines 29 lines of manual vs 45 lines of server here.
Security surface is "minimal" It moves. The agent holds every key and the manual directs it.

The page also says, fairly, when to choose MCP: when you want resources and prompts as well as tools, centralized control over tool access, or you already run MCP infrastructure. Add one more that it leaves out. Claude, ChatGPT, VS Code and Cursor are already MCP clients. A UTCP manual is only useful where you control the client and can install the UTCP library in it.

Which one to use#

  • You own the agent and the API, and the API already has auth and rate limits. UTCP, or plain function calling over your OpenAPI spec, is less to run. Connecting an LLM to a REST API shows the no-protocol version.
  • You want your tool available in Claude, ChatGPT, IDEs and other hosts you do not control. MCP. That is where the clients are.
  • The agent must not hold the credential, or you need per-tool permissions and one audit log. MCP, because the server is the place to enforce them.
  • The tool is a local CLI or a file. UTCP's cli and text templates cover it without a server. So does a shell tool.
  • You have MCP servers and want to try UTCP. Use the bridge on Python 3.13 or older, and check that every tool has an output schema.

The other names you will hear#

Searches for "MCP vs UTCP" usually turn up a third name. None of these replaces either protocol.

  • WebMCP is a browser API, document.modelContext, that lets a web page register its own JavaScript functions so an agent running in the browser can call them. It is a draft report from the W3C Web Machine Learning Community Group with editors from Microsoft and Google, and it is not yet on the standards track. The tools live in the page, so it covers the case where the user is already on the site.
  • Agent Skills are folders with a SKILL.md file: a name, a description and Markdown instructions, with optional scripts. The specification is open, and Anthropic donated it to the Agentic AI Foundation on 22 October 2026. A skill is packaged know-how that often tells the agent which CLI to run. It has no wire format.
  • Code mode is a pattern in which the model writes code against tools presented as an API and runs it in a sandbox. Cloudflare described it in September 2025 and Anthropic in November 2025, with an example that cut a 150,000-token workflow to 2,000 tokens. It sits on top of MCP or UTCP tools.

A2A and ANP solve agent-to-agent communication. MCP vs A2A vs ANP covers those.

Reproduce it#

python3 -m venv .venv && .venv/bin/pip install utcp utcp-http fastapi uvicorn
python3 -m venv .venv-mcp && .venv-mcp/bin/pip install "mcp==2.3.0" httpx

.venv/bin/uvicorn api:app --port 8123 &
BOOKSHOP_KEY=demo-key .venv-mcp/bin/python mcp_server.py http &

.venv/bin/python utcp_demo.py
.venv-mcp/bin/python mcp_demo.py

The timing loop is 50 warm-up calls, then 500 calls wrapped in time.perf_counter(), with statistics.median for p50 and the 475th sorted value for p95. Loopback numbers measure protocol overhead only. Put your real network between the boxes before quoting any of them for your own system.

Sources#

Found this useful? You can buy me a coffee or support with any amount. It pays for hosting and keeps new articles coming.