Lesson 35.5 · 5 of 6 · 6 min read · Reviewed 24 Nov 2026
The N×M problem: why a shared protocol pays off
By the end, you can
- Estimate the integration work for N apps and M tools, with and without a shared protocol.
- Explain what a shared protocol standardises and what it leaves to each app and server.
Lesson 35.1 counted the pieces. This lesson asks the question a team lead asks: when does a shared protocol actually save work, and what exactly does it take off your plate?
The arithmetic
Take N AI apps (a chat assistant, an IDE agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done., a support bot) and M tools or data sources (tickets, a wiki, a database). Without a standard, every pair needs its own glue.
| Without a protocol | With a shared protocol | |
|---|---|---|
| Pieces to build | N × M | N clients + M servers |
| 4 apps, 12 tools | 48 | 16 |
| Add a 13th tool | +4 | +1 |
| Add a 5th app | +12 | +1 |
The total gap matters, but the marginal cost matters more. Without a protocol, every new tool costs N pieces of work and every new app costs M. With one, each costs a single piece.
The economics beyond the count
Building is the cheap part. Most of the cost lands later.
- Maintenance. When the ticket system changes its API, pairwise glue needs N fixes, usually by N different teams. With a protocol, the owner of the ticket server fixes one server.
- Testing. Pairwise glue gives N × M combinations to test. A protocol lets you test each client and each server against the protocol, so N + M test suites.
- Ownership. The team that knows a system can ship its server. App teams stop learning every tool’s quirks.
- Network effects. Each new server is worth more as more apps adopt the protocol, and the reverse. The Language Server Protocol did the same for editors and programming languages: one language server works in many editors.
A worked example
Use made-up effort units. Custom glue costs 5 days to build and 1 day a year to maintain. Speaking the protocol costs more per side, because you implement the general case: 8 days for an app’s client, 6 days for a tool’s server, and 1 day a year each.
| 4 apps, 12 tools | Build | Maintenance per year |
|---|---|---|
| Custom glue | 48 × 5 = 240 days | 48 days |
| Shared protocol | 4 × 8 + 12 × 6 = 104 days | 16 days |
Now try 1 app and 2 tools. Glue costs 2 × 5 = 10 days; the protocol costs 8 + 12 = 20. A protocol has a fixed cost per side, so for one app and a couple of tools, glue is cheaper. It pays off once both sides grow, and ready-made servers and clients you did not have to build tip the balance early.
What a shared protocol standardises
| Standardised by the protocol | Still your job |
|---|---|
| Message format (JSON-RPC 2.0 requests, responses, notifications) | Deciding when the model should call a tool |
Discovery (tools/list, resources/list, prompts/list) |
Writing clear tool names and descriptions |
| Shapes of tools, resources and prompts, with JSON Schema inputs | The business logic behind each tool |
| Result and error shapes | Permissions, consent prompts and least privilege (34.5) |
| Transports (stdio, Streamable HTTP, 27.4) | Hosting, monitoring and rate limits |
| Version and capability negotiation (35.6) | Whether a server is trustworthy at all |
A protocol makes integration uniform, not safe or good. A badly described tool is just as confusing to the model over a standard wire.
How it goes wrong
- Private extensions. If each app adds its own fields and servers start depending on them, you are back to pairwise glue with extra steps.
- Lowest common denominator. A feature one tool needs may not exist in the protocol yet. Teams then bolt on a side channel and lose the savings.
- Version drift. Apps and servers on different protocol revisions can fail to talk. Negotiation (35.6) exists for this, but someone must keep both sides current.
- Wrapping a bad API. A server that mirrors 200 raw endpoints as 200 tools is standard, and still unusable.
In practice
Track three numbers before and after adopting a protocol: how many integrations you maintain, how long it takes to connect a new tool to every app, and how many places change when one tool’s API changes. If those numbers fall, the protocol is paying off.
Key points
- Pairwise glue costs N×M integrations; a shared protocol costs N clients plus M servers, so N+M.
- The bigger saving is maintenance: a change to one tool's API touches one server, not N integrations.
- A protocol has a fixed cost per side, so it only pays off once several apps and several tools share it.
- The protocol fixes messages, discovery, schemas, errors, transports and negotiation. Tool quality, consent and security stay with you.
Find where a shared protocol breaks even
Compare the build and maintenance effort of custom glue with a shared protocol, and find the point where the protocol starts to pay off.
You will have: A cost model with glue_cost(), protocol_cost() and break_even(), and a table for four organisations.
Steps
- Write glue_cost(): one piece per app-tool pair, each with a build cost and yearly upkeep.
- Write protocol_cost(): one client per app and one server per tool, each with its own build cost and upkeep.
- Print a table of both costs over two years for four sizes of organisation.
- Write break_even() to find the smallest number of tools where the protocol costs no more than glue.
- Work out what a 13th tool adds with 4 apps under each approach.
Done when
- With 4 apps and 12 tools, build effort is 240 days for glue and 104 for the protocol.
- With one app the protocol never breaks even; with 4 apps it breaks even at 2 tools.
- A 13th tool costs 20 days of glue but 6 days with the protocol.
Open in the Playground No API key needed.
Starter code (Python)
# Illustrative effort in days, not real figures.
GLUE_BUILD = 5 # custom glue for one app-tool pair
PROTO_CLIENT = 8 # one app learns to speak the protocol
PROTO_SERVER = 6 # one tool ships a protocol server
UPKEEP = 1 # days per year to maintain any one piece
def glue_cost(apps, tools, years):
# TODO: one piece of glue per app-tool pair; each costs GLUE_BUILD plus UPKEEP per year
return 0
def protocol_cost(apps, tools, years):
# TODO: one client per app and one server per tool, each with its own build cost plus UPKEEP per year
return 0
def break_even(apps, years, max_tools=50):
# TODO: return the smallest number of tools where the protocol costs no more than glue, or None
return None
print(f"{'apps':>4} {'tools':>5} {'glue':>6} {'protocol':>9} (2 years)")
for apps, tools in [(1, 2), (2, 3), (4, 12), (10, 30)]:
print(f"{apps:>4} {tools:>5} {glue_cost(apps, tools, 2):>6} {protocol_cost(apps, tools, 2):>9}")
for apps in (1, 2, 4):
t = break_even(apps, 2)
print(f"break-even for N={apps}:", "never" if t is None else f"{t} tools")
# TODO: print the extra days a 13th tool costs with 4 apps, for glue and for the protocol
Show a solution
# Illustrative effort in days, not real figures.
GLUE_BUILD = 5 # custom glue for one app-tool pair
PROTO_CLIENT = 8 # one app learns to speak the protocol
PROTO_SERVER = 6 # one tool ships a protocol server
UPKEEP = 1 # days per year to maintain any one piece
def glue_cost(apps, tools, years):
pairs = apps * tools
return pairs * (GLUE_BUILD + UPKEEP * years)
def protocol_cost(apps, tools, years):
return apps * (PROTO_CLIENT + UPKEEP * years) + tools * (PROTO_SERVER + UPKEEP * years)
def break_even(apps, years, max_tools=50):
for tools in range(1, max_tools + 1):
if protocol_cost(apps, tools, years) <= glue_cost(apps, tools, years):
return tools
return None
print(f"{'apps':>4} {'tools':>5} {'glue':>6} {'protocol':>9} (2 years)")
for apps, tools in [(1, 2), (2, 3), (4, 12), (10, 30)]:
print(f"{apps:>4} {tools:>5} {glue_cost(apps, tools, 2):>6} {protocol_cost(apps, tools, 2):>9}")
print(f"build only, 4 apps and 12 tools: glue {glue_cost(4, 12, 0)}, protocol {protocol_cost(4, 12, 0)}")
for apps in (1, 2, 4):
t = break_even(apps, 2)
print(f"break-even for N={apps}:", "never" if t is None else f"{t} tools")
new_glue = glue_cost(4, 13, 0) - glue_cost(4, 12, 0)
new_proto = protocol_cost(4, 13, 0) - protocol_cost(4, 12, 0)
print(f"13th tool with 4 apps: glue +{new_glue} days, protocol +{new_proto} days")