Your CLI Tool Needs an MCP Server: Shipping One in a Day, Protocol by Hand
Your CLI Tool Needs an MCP Server: Shipping One in a Day, Protocol by Hand Published on 2026-09-11 · xbrowser v1.23.1 Every CLI tool built before 2026 is asking itself the same question: how do AI agents discover me? The answer the ecosystem converged on is the Model Context Protocol — MCP. If Claude Desktop, Cursor, or any MCP-capable client can list your tool's capabilities and call them, your…
In 2026, every CLI tool needs to consider how AI agents discover its capabilities. The Model Context Protocol (MCP) has become the standard for this. xbrowser, a CLI tool with 57 commands and 130+ site plugins, recently shipped xbrowser mcp, an MCP server exposing seven browser tools. This post details the build process, bugs encountered, and the decision to write the protocol layer from scratch.
The official MCP SDK is sufficient, but the authors chose to write the protocol layer manually for three reasons. Firstly, the required protocol surface is minimal, making a custom implementation simpler. Secondly, dependency discipline is improved by avoiding new dependencies, leading to a cleaner install process. Lastly, debugging is easier when the protocol layer is small enough to understand fully.
The MCP server's design decision is to avoid rewriting automation logic. Each tool call uses the same functions as the CLI: executeChain or executeCommand. This approach ensures a single execution path to test, a single place for bug fixes, and automatic feature parity with the CLI. The chosen tools for agents are chosen for ergonomics rather than CLI symmetry. They include browser_navigate, browser_act, browser_read, browser_snapshot, browser_screenshot, browser_network, and browser_replay.
During a smoke run, two bugs were discovered. The first was the CLI eating the protocol, which was fixed by short-circuiting stdin collection in the MCP layer. The second bug was a shutdown race condition when the browser was launching and a request was timed out. This was resolved by using an inflight counter, ensuring the process only exits when stdin is closed and nothing is pending.
Testing an MCP server does not require an existing client. A simple smoke script can validate the server's functionality. Once the server is running, any MCP-capable agent can be used to test the tool's functionality. The xbrowser MCP server is MIT-licensed and available on GitHub and npm.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.