---
id: 18450
lang: en
title: "An engineer spent two weeks building his own MCP on NiFi without knowing the standard already existed"
published_at: "2026-11-27 14:33:16"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1113168/?utm_campaign=1113168&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18450"
categories: ["llm", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# An engineer spent two weeks building his own MCP on NiFi without knowing the standard already existed

> **Краткая суть (BLUF):** An engineer spent two weeks building his own way to connect an AI assistant to actions like "find an order," then learned that this already exists: MCP, Anthropic's open protocol for model tools. The author's Apache NiFi version matched only the call "envelope"; MCP already had the tool catalog and parameter schemas. That's why a homegrown prototype should be time-boxed, and the specification should be read in advance.  • Three versions: code in an OpenWebUI tab, 20 web services, one endpoint • NiFi keeps a history of every call and slows the queue under load • MCP already has tools/list, parameter schemas, error codes, and versioning

Businesses don't want an AI assistant that says "tell me." They want it to "do": check the remaining bonus balance, find an order, verify delivery status, create a support ticket. For a model to do that, it has to be connected to tools, and there is an open standard for this: MCP (Model Context Protocol), which Anthropic released in November 2024. The author of this story, who deploys assistants inside companies on the OpenWebUI platform, spent two weeks building the same mechanism himself, on Apache NiFi (a system for building data flows), and only afterward found out that it had all been figured out already. His path is useful as a map of typical mistakes for anyone building tools for agents.

## Three attempts: from a browser tab to a single endpoint

At first, the tools were written directly in the OpenWebUI interface: a Python function with a docstring that the model calls. Fifteen minutes, and for a demo everything works. For a company, that's not enough: the code doesn't live in git and doesn't go through code review, dependencies sit in the platform's container, secrets are stored next to the code, there is no audit of calls, and a long operation blocks the chat.

The next step was moving the tools into separate web services. Secrets and logs fell into place, but once there were twenty endpoints, a different problem appeared. Each one has to be described to the model, and descriptions like "order status," "order information," "order state," and "order history" can only be told apart by the author. The list bloats and the model gets confused. The author caught himself writing not a service but a phone directory for the model, and half of the entries were already out of date.

The third version used one URL, one token, and calls of the form "function name plus parameters." Logs and limits ended up in one place. But with a live model, holes showed up:

- the list of functions had to be enumerated in the prompt, and it went stale faster than it could be edited;
- the model sent "123" instead of 123 and sometimes serialized the parameters twice;
- requests and responses could not be matched, and each function had its own error format;
- when a parameter was updated, all clients silently broke;
- nobody knew what the server could actually do.

The author had built a transport and called it a protocol. It's like inventing an envelope and declaring it mail.

## What turned out to be shared with MCP

Once the system was running, the author searched for existing solutions. First he found JSON-RPC 2.0, which is nearly twenty years old and has the same fields: jsonrpc, id, method, params. Then he found MCP, and the specification read like a checklist against his own code: initialize, tools/list, tools/call, params.arguments, error codes, version negotiation. His homemade version matched only on the call: it had no request identifier, no standard error codes, no tool catalog, no parameter schema (inputSchema based on JSON Schema), no initial handshake, and no version negotiation. It also lacked resources, prompts, and notifications.

An important detail: the model itself does not speak MCP. This is a protocol between the host application (the platform with the assistant) and the tool server. The host receives the catalog, schemas, and results, while the model sees a ready-made list of functions. So the value of MCP lies in the agreements around the call: how to learn what a server can do, how to describe parameters so the model fills them in correctly, how to respond to an unknown method, and how to avoid breaking clients during an update.

## Why NiFi

The author has worked with NiFi for about ten years and has already built a Telegram bot and an order management system on it, so he didn't have to struggle with an unfamiliar tool. For such a server, the advantages are:

- Data Provenance. Every call becomes a FlowFile with a history: what the model asked for, which parameters it made up, what the loyalty system replied, and at which processor everything stopped. The question "why did the assistant deduct the bonuses twice" gets an answer in two minutes, not two days.
- Back pressure. If the model calls the same tool twenty times in a row, a queue with a threshold slows the intake instead of bringing everything down in a cascade.
- Retries. When an external API goes down, the request waits and tries again rather than getting lost.
- Routing. RouteOnAttribute keyed on method and params.name works as a dispatcher: a new tool is a new branch of the graph, not a new service.

The scheme is simple: HandleHttpRequest accepts POST /mcp, EvaluateJsonPath extracts method, id, and params.name, RouteOnAttribute splits requests by the methods initialize, tools/list, tools/call, and ping, then come InvokeHTTP, ExecuteSQL, or ExecuteScript, after which a response with jsonrpc and the same id is assembled. Since OpenWebUI at the time spoke OpenAPI rather than MCP, the dispatcher has two facades: /mcp and /functions, with one logic inside. Later it turned out that the Open WebUI team had already published a bridge called mcpo, which exposes an MCP server as OpenAPI. The author found it, just like MCP itself, only after he had written his own.

## Takeaway for practitioners

The author is not urging anyone to ignore specifications: they should be read, and the sooner the cheaper. His point is different: a bicycle built by hand turns someone else's standard from an instruction manual into an explanation, because you recognize your own decisions and dead ends in it. The conditions are these: the exercise should have a time limit, and the homemade build should be easy to throw away once a standard appears. If you're building integrations for agents, start with MCP. If you want to build your own out of curiosity, compare by the roles of the fields rather than by their names, and don't confuse transport with protocol.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1113168/?utm_campaign=1113168&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18450
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
