Skip to content
← All writing
2026-06-12 · 12 min read architecturefundamentalsprotocolsabstraction

The M x N Problem: One Pattern Behind USB, LSP, and MCP

Every 'USB-C for X' pitch is the same old trick: insert a standard interface and turn M x N integrations into M + N.

What you'll get out of this post

The punchline up front: there is nothing new here. Every one of these technologies applies one fundamental engineering pattern -- when pairwise integrations grow as a product, insert a standard interface and make them grow as a sum. Master the pattern once and every future instance becomes obvious on sight.


The problem: integration cost grows as a product

Start with the shape of the problem, stripped of any specific technology.

You have M consumers on one side (applications, editors, computers -- things that want capabilities) and N providers on the other (services, languages, peripherals -- things that have capabilities). Every consumer wants to work with every provider. The naive approach: write a custom adapter for each pair.

Pairwise integration: every consumer adapts to every provider

Consumer A
→
Consumer B
→
Consumer C
→
...M consumers

Each one writes custom glue for every provider below

↓

Provider 1
→
Provider 2
→
Provider 3
→
...N providers

M x N adapters -- each written, tested, and maintained separately

The cost isn't just the count. Three structural problems come with it:

  1. Quadratic-ish growth. With 5 consumers and 8 providers you maintain 40 adapters. Adding one consumer costs 8 new adapters; adding one provider costs 5. Every new participant pays a toll proportional to the size of the other side.
  2. Everyone must know everyone. Each adapter encodes knowledge of one consumer's internals and one provider's internals. Change either side and every adapter touching it breaks.
  3. Capabilities get trapped. The adapter you wrote for pair (A, 1) is useless to consumer B, even though B wants exactly the same capability. The work can't be shared because it was never expressed in shared terms.

If you've done real engineering, your instinct at this point is already whispering the fix -- and your instinct is right.


The fix: a standard interface in the middle

Define one interface that captures what consumers and providers actually need to say to each other. Then:

Standard interface: each side implements it exactly once

Consumer A
→
Consumer B
→
Consumer C

M implementations of 'speaks the standard'

↓

One standard interface

↓

Provider 1
→
Provider 2
→
Provider 3

N implementations of 'speaks the standard'

The total work drops from M x N adapters to M + N implementations, and -- just as important -- the marginal cost changes: a new participant pays a constant toll (implement the standard once) instead of a toll proportional to the other side. That's what lets an ecosystem grow without melting.

Notice the deeper shift in who knows whom. Before: every pair knows each other intimately. After: nobody knows anybody -- both sides know only the standard. That's the textbook definition of decoupling, achieved by adding a layer in between.

Key Concept

Indirection

"All problems in computer science can be solved by another level of indirection" -- commonly attributed to David Wheeler, and quoted so often because it keeps being true (provenance in Sources). An indirection layer is anything you put between two parties so they stop depending on each other directly: a pointer, an interface, a protocol, a broker. The famous corollary is just as important: "...except the problem of too many layers of indirection." Every layer you add buys decoupling and costs overhead -- the skill is knowing when the trade is worth it. The M x N collapse is one payoff of indirection among several; the full principle has its own post.


The same trick, four decades running

Here's the pattern instantiated across history. For each row, ask: what are the two multiplying sides, and what does each side now implement exactly once?

One pattern, many costumes

HeaderMeaningExample
USBPeripherals x computersDevice speaks USB once; host provides a USB port and stack once
LSPEditors x programming languagesLanguage ships one language server; editor ships one LSP client
TCP/IPApplications x physical networksApps target sockets; any network that moves IP packets works
LLVM IRLanguages x CPU architecturesCompiler frontend emits IR; one backend per chip compiles IR
JDBC/ODBCApplications x databasesApp codes against one API; each DB vendor ships one driver
Shipping containerCargo x transport modesGoods packed once; ships, trains, and trucks all handle one box
MCPAI applications x tools/data sourcesTool ships one MCP server; AI app embeds one MCP client

Two of these deserve a closer look, because they're the ones people name-drop most and explain least.

USB: peripherals x computers

Before USB (mid-1990s), the back of a PC was a zoo of connectors: keyboards and mice on PS/2 ports, printers on parallel ports, modems on serial ports, plus a pile of vendor-proprietary plugs. Every pairing of "device category" and "computer platform" needed its own connector, its own signaling, often its own driver -- built by the peripheral maker, supported by the computer maker. Classic M x N: M kinds of devices times N kinds of hosts.

USB collapsed that into one contract: a device implements the USB spec once, a computer provides USB once, and any compliant device works on any compliant host. The peripheral maker no longer designs per-platform plugs; the computer maker no longer ships per-device ports. Each side meets the standard, not each other.

LSP: editors x programming languages

This one needs its terms unpacked, because "editors x languages" is compact to the point of cryptic.

The product feature in question is editor intelligence: autocomplete, go-to-definition, hover documentation, error squiggles as you type. Delivering it requires code that deeply understands a specific language -- a parser, a type checker, a symbol index. Call that the "language smarts."

Before LSP (2016), language smarts lived inside each editor. VS Code needed its own TypeScript engine; Vim needed a separate TypeScript plugin; Emacs a third; JetBrains a fourth. Now multiply by Python, Go, Rust, C++... Every (editor, language) pair was a separate implementation, written by whoever cared enough, with wildly uneven quality. M editors times N languages.

The Language Server Protocol drew a line down the middle: the language smarts move into a standalone process called a language server (one per language -- gopls for Go, rust-analyzer for Rust, pyright for Python), and the editor keeps only a generic LSP client that asks standardized questions like "what completions go here?" and "where is this symbol defined?". A language team writes one server and every editor benefits; an editor implements one client and instantly gets smart about every language with a server. M + N.

✅

The test for whether you've internalized the pattern

You read "MCP gives AI apps a standard way to connect to tools" and your reaction is: "so tools are the language servers, AI apps are the editors, and MCP is playing the role of LSP." When a new protocol maps itself onto the pattern in your head automatically, you've stopped learning instances and started owning the principle.


Why a standard layer works: the narrow waist

There's a name for the architecture this produces: the hourglass, or "narrow waist." Many things on top, many things on the bottom, and one deliberately small interface in the middle that everything funnels through.

The canonical example is the internet itself. Above IP: the entire zoo of applications and protocols -- HTTP, email, video calls, games. Below IP: every physical transport ever invented -- Ethernet, Wi-Fi, fiber, satellite, cellular. The waist -- IP's "best-effort delivery of packets" -- is tiny, almost insultingly simple. That's not a weakness; it's the entire design:

This explains a design choice that otherwise looks like a flaw in every standard you'll meet: good waists are minimal, and minimal means features get left out. Which brings us to the costs.


What the pattern costs (the part the hype skips)

If standard interfaces were free, everything would be one. They're not, and knowing the price list is what separates "applies the pattern" from "applies the pattern well."

1. The lowest common denominator. The standard can only carry what both sides agreed on. LSP exposes "completions" and "diagnostics" -- but an IDE with a native, deeply-integrated engine (think IntelliJ's own Java support) can still do things a generic LSP client can't, because it isn't limited to the standardized question set. Any capability that doesn't fit the waist either gets dropped or gets bolted on as a nonstandard extension -- and extensions quietly reintroduce the M x N coupling the standard was meant to kill.

2. A real layer of overhead. One more process, one more serialization round-trip, one more handshake. For a single consumer talking to a single provider, the indirection layer is pure cost -- you pay the toll and collect none of the reuse.

3. Standards need pain before they can exist. A standard is a peace treaty, and nobody signs a peace treaty before the war. USB arrived after two decades of connector zoo; LSP after three decades of per-editor plugins; MCP after a couple of years of every AI app hand-rolling the same integrations. Propose the standard before the M x N pain is widely felt, and you don't end the war -- you become one more combatant. (This is the famous "now there are 15 competing standards" failure mode.)

⚠️

The corollary that saves you from over-engineering

The pattern only pays when both sides actually multiply. One consumer, or one provider, or a pair that will never grow -- hardwire it and move on. Inserting a protocol layer "because that's the clean way" when M = 1 is how you pay cost #2 forever while collecting nothing.


Iron rules

⚡ Iron Rule #1

Cost that grows as a product is a design smell

The moment integration work scales as M x N -- every new participant paying a toll proportional to the other side -- stop writing adapters. Define the interface, make each side implement it once, and turn the product into a sum.

⚡ Iron Rule #2

An indirection layer is bought, not free

Every layer purchases decoupling and pays for it in fidelity (lowest common denominator) and overhead (latency, complexity). The trade is only worth it when both M and N are genuinely greater than one and growing. Otherwise, hardwire.

⚡ Iron Rule #3

Learn the waist, not the logo

When the next "USB-C for X" arrives, ask three questions: What are the two multiplying sides? What does each side implement exactly once? What got cut to keep the waist narrow? If the answers are crisp, the protocol is solving a real M x N problem. If they aren't, it's a brand looking for a war to end.


See the pattern live

Abstract patterns stick when you watch one instance up close. The freshest instance is MCP, and I've covered it from both ends:

Read those with this post in mind, and MCP stops being a new thing to learn. It's the old thing, wearing this year's costume.

For the parent principle underneath this whole post -- what an indirection layer is, the four distinct things it can buy, and what each layer costs -- see Another Level of Indirection: The Oldest Trick in CS.


Sources