Engineering Journal
Schema Editor
Schema Editor

Adding MCP to a Tool Is Not an AI Feature. It Is an API Design Problem.

2026-06-04

TLDR

MCP integration is marketed as a way to make your tool AI-native. The protocol is five lines. The hard part is defining a serialization contract that gives the AI something it can reason about. This is an API design problem, not an AI problem. Teams that understand this ship working integrations. Teams that do not ship broken ones.


What the Industry Does

The default pattern for MCP tool integration is: receive the tool call, return the tool's native serialization format, and let the AI figure out the structure. Return the SVG, return the HTML, return the JSON config. The tool already has a format. Use it.

This pattern is fast. It is also wrong for most tools because native formats are optimized for serialization and deserialization by the tool, not for reasoning by an LLM.

Why It Fails for This Problem Class

A diagram editor's native format (SVG) encodes visual rendering. It has nested groups, transform attributes, CSS classes, and system elements mixed with user content. An LLM parsing SVG to understand a circuit must reverse-engineer semantic structure from rendering intent. It does this unreliably.

The inverse case is clearer: would you design a REST API that returned HTML as the response format and expected the client to parse it? No. The HTML is optimized for display. The API response should be structured data optimized for the consumer.

An MCP tool call is an API call. The response should be structured data optimized for the AI consumer. Not the rendering format optimized for the display layer.

The Better Approach

Design the AI-facing representation before writing the MCP server. Answer three questions:

  1. What entities does the AI need to know about? (Components, connections, metadata.)
  2. What properties of those entities are relevant to AI reasoning? (Type, position, connections. Not CSS classes, not internal IDs, not rendering attributes.)
  3. What operations does the AI need to perform? (Read the diagram. Suggest additions. Validate connectivity.) The read representation should support these operations.
Then write the serialization that answers these questions. Then wire the MCP server to return it. The wiring takes an hour. The representation design takes a day.

What You Give Up

A well-designed AI representation is a maintenance commitment. When the editor's internal model changes, the _buildPayload() function must be updated. This is a permanent cost proportional to how often the internal model changes.

The alternative (return the native format) has zero maintenance cost for the MCP integration specifically. It has ongoing cost in unreliable AI responses that must be debugged, improved, and worked around in the prompt.

The maintenance cost is real. The broken AI responses are also real. In most cases, a well-maintained serialization contract is cheaper than permanent AI unreliability.

When the Common Pattern Is Right

Return the native format when: the native format is already a clean semantic representation (a well-defined JSON schema, not SVG or HTML), the AI integration is exploratory and you are not sure what the AI needs to do yet, or the tool's state is simple enough that the native format is also the optimal AI-facing format. A tool whose state is a flat list of named items does not need a separate AI serialization layer.

Read this post in the full Engineering Journal →