Build an MCP Server That Survives Production: Notes From Shipping Lazy Shot

An afternoon suffices to build an MCP server for a demo: a single tool, one happy path, and a screen recording. Yet, creating one that an agent invokes two hundred times daily on another person’s machine is an entirely different task, and the protocol accounts for almost none of that work.

Here are the notes we put together while shipping the MCP server inside Lazy Shot, a desktop screenshot app where agents use the capture, library and marker tools just as frequently as people do. We lay out the choices we made and why. This document does not include the product’s source code, and any JSON provided is marked as illustrative. We verified the protocol details against the 2026-07-28 revision of the specification; if you are reading this later, please verify them again.

Why most MCP servers are demos

In September, our survey of desktop screenshot servers categorized 93 of them. The totals along each axis offer a solid practical definition of "demo":

  • 31 provide images exclusively as inline base64; 18 provide file paths.
  • 77 retain nothing. 9 maintain a searchable archive of their captures.
  • 9 provide annotation.
  • 42 received no stars, and within the broader set, 13 READMEs made claims the code did not fulfill.

Not one of those servers is broken. Returning a screenshot after capturing one makes a tool a valid MCP server. Yet it becomes insufficient once the agent requires yesterday’s capture, a call fails, or a user reports "it stopped working" with nothing available to examine.

A production server deals with four things the demo ignores. What does the agent do when a call fails? How much context does the result use? What state remains after the call? What does the user give you when things break?

MCP tool design: four groups and verbs an agent can guess

The server offers 23 tools. This creates a large interface for the model to manage, making the menu the first design challenge.

The tools are divided into four categories: Capture (take a picture), Manage (find, name, and remove pictures in the library), Markers (pin numbered markers on them), and OCR (read the text in them). The protocol lacks any concept of tool groups. This organization exists within the documentation and naming conventions, offering both the model and any human reviewing the tool list a four-item framework before a twenty-three-item one.

Most of the weight lies in the names:

  • Verb first, noun second, single vocabulary. capture_region, capture_window, capture_display. search_screenshots, delete_screenshot. add_markers, edit_screenshot. An agent that has seen capture_window can infer capture_display without reading the list.
  • A list_ for each identifier a tool requires. Since capture_display receives a display, list_displays exists. Because get_marker_preset receives a preset name, list_marker_presets exists. Should an argument be learnable only via trial and error, the agent will learn it through trial and error.
  • A single task for each tool. Assigning a name to a capture is assign_keyword, a distinct call, rather than a flag on four capture tools.

The spec's guidance is brief: names should be 1 to 128 characters long, drawn from letters, digits, underscore, hyphen and dot, and unique per server. The 2026-07-28 revision adds that servers should return tools/list deterministically, allowing clients to cache it and prompt caches to keep hitting.

Tool annotations are present as well: readOnlyHint, destructiveHint, idempotentHint, openWorldHint. Populate them accurately, since clients rely on them to determine when to request confirmation. Avoid constructing security on top of them: the spec instructs clients to regard annotations as untrusted unless the server is trusted.

Transport: MCP streamable HTTP on localhost

The specification outlines two standard transports. With stdio, the client starts the server as a subprocess and communicates via its standard streams. In Streamable HTTP, the server operates as an independent process featuring one endpoint that takes POST requests and responds to each with either a JSON object or a request-scoped SSE stream. The legacy HTTP+SSE transport was deprecated as of revision 2025-03-26, so do not begin there.

Local servers usually pick stdio, and for command-line tools, that’s the correct choice. Since our server runs within a desktop application, the decision goes the other way. In stdio, the client manages the server’s lifecycle by launching the process and terminating it. A GUI app is already active, holds the screen-capture permission on macOS, manages the library and settings window, and is initiated by a user. A subprocess launched by a client would simply be a second program needing to locate the first. Consequently, the app acts as the listener, with clients connecting to it:

# Claude Code; check the syntax against your client's current docs
claude mcp add --transport http lazy-shot http://127.0.0.1:5055/mcp

The price we pay for this:

  • No stdio. Of the 93 servers surveyed, 80 prioritized stdio, while certain clients still communicate solely via stdio. Such clients require a bridge—a small stdio process that relays to the HTTP endpoint—and mcp-remote is the typical solution. This introduces an additional component on the user's end.
  • The server's lifespan is tied to the app's runtime. No mechanism initiates it on demand. Should an agent attempt to contact a closed app, a connection error will result.
  • A port. 5055 is the default. Should another process occupy it, the server grabs the next available port, displaying the active one in Settings → MCP. Failing outright beats auto-incrementing while hiding the outcome, because that would leave the user's config pointing at a port secretly owned by another program.

Lazy Shot Settings, MCP pane: server running on port 5055, bound to 127.0.0.1, with connection snippets

Settings › MCP in Lazy Shot 0.0.10: the status line shows the port actually in use, the bind address defaults to 127.0.0.1, and the snippets are ready to paste.

The server binds to 127.0.0.1 by default. The spec says local servers should bind only to localhost, and that they must also verify the Origin header to stop DNS rebinding attempts from web pages.

A note on revisions: protocol-level sessions were dropped from this transport in revision 2026-07-28, making cross-call state an explicit handle passed as a standard tool argument. This pattern functions across all revisions; begin there.

An MCP server example: what a capture returns

Per the MCP spec, tool results may include text, images, audio, resource links, and embedded resources, along with an optional structuredContent value capable of validation against an outputSchema. Since image content within the result is base64, it enters the model's context regardless of whether the model required a visual inspection.

Our capture tools yield a path. The result comprises a few fields, consuming a few dozen tokens of context; the image incurs no cost until the agent opens the file. Our file-path-first design notes contain the extended argument, covering scenarios where inline base64 is appropriate, while a separate token cost breakdown details the arithmetic for an image's cost once read.

An example output, formatted as the spec defines. The field names used here are specific to this article and do not represent Lazy Shot's schema:

{
  "content": [
    { "type": "text", "text": "{\"path\":\"/Users/me/shots/settings-before.png\",\"keyword\":\"settings-before\",\"width\":1440,\"height\":900}" }
  ],
  "structuredContent": {
    "path": "/Users/me/shots/settings-before.png",
    "keyword": "settings-before",
    "width": 1440,
    "height": 900
  },
  "isError": false
}

Three principles underlie this.

Small and flat. A model reads the result on every call. Stop once you return the fields the subsequent call requires.

Stable names. Once a field bears the name path in one tool, it bears path in every other, indefinitely. Both agents and the rule files humans author rely on pattern-matching field names. Altering that name is a breaking change, regardless of whether any schema enforces it.

Text and structure together. The spec suggests that tools providing structured content should also serialize it into a text block to accommodate older clients. Perform both actions; the redundancy costs only a few dozen tokens.

One strict rule governs the path contract: the caller and server must reside on the same filesystem. /Users/me/shots/… cannot be opened by a remote agent. Being a localhost server makes this true by design, offering half the justification for our selection.

Error contracts: the difference between a protocol error and a tool error

The spec offers tools two modes of failure, and it is simple to pick the incorrect one.

Protocol errors are JSON-RPC errors: unknown tools, malformed requests, or the server crashing. The spec characterizes these as issues the model is unlikely to resolve.

A tool execution error is a standard outcome with isError: true: a downstream call that failed, input failing validation, or a business rule denying the action. Clients should route these to the model for self-correction and retry. The spec explicitly categorizes input validation here: a window title matching nothing counts as a tool error, not -32602.

Within a tool error, every message should answer three questions: the nature of the failure, the utility of a retry, and the alternative action. Lazy Shot's tool errors today carry a stable code such as window_not_found and a plain message; the illustrative example below shows the full contract we recommend:

{
  "content": [
    { "type": "text", "text": "No window matches title \"Setings\". Retrying the same call will not help. Open windows include \"Settings\" and \"Simulator\"; call capture_window with one of those." }
  ],
  "structuredContent": {
    "code": "WINDOW_NOT_FOUND",
    "retryable": false,
    "hint": "Use a title from the list, or capture_display."
  },
  "isError": true
}

Authors often overlook the retryable flag. One more attempt after a second suits a window that is still opening. It does not suit a reached daily call cap, and an agent unable to distinguish the two will waste its remaining calls discovering this. State in model-readable words which case applies, and provide a field scripts can branch on.

We raised the same issue about licensing without a phone-home, where cryptography proved easy and the error taxonomy demanded the real effort. For an MCP server, the interface is largely composed of failure messages, which a model reads and then acts upon.

Logging as a first-class feature

Every MCP operation in Lazy Shot writes to the app's rotating session log, heretic-lazy-shot_<timestamp>.log in ~/.heretic-lazy-shot/logs/ (%USERPROFILE%\.heretic-lazy-shot\logs\ on Windows), with an [MCP] tag: TOOL_CALL with the arguments, then TOOL_OK with a duration or TOOL_FAIL with the error. For a bug report, Settings → System copies the system info in one click, and the user attaches the log file to the email.

It comes down to support. If an agent workflow fails, the reporter typically has only the agent's summary. The log remains the sole account produced by a non-speculative source.

The line format we would use for any server includes the timestamp, tool name, safe arguments, outcome, error code if present, and duration. Each operation takes one greppable line. A one-click export of the logs matters just as much, and it is the piece Lazy Shot still lacks: logs hidden in a directory won't reach you.

Stay local. The 2026-07-28 revision deprecated protocol-level logging to the client, advising stderr logging on stdio or OpenTelemetry usage instead. For an app lacking telemetry, a file on the user's disk that they choose to send is the suitable option.

Terminal with Lazy Shot MCP log lines: a successful capture, a failed capture_window with window not found, then a successful search

One greppable line per event: a capture that worked, a capture_window that failed because no window matched, and the search that followed.

Tools vs resources vs prompts

The official server concepts page divides the three primitives based on who is in control. Tools operate under model control, meaning the model chooses to invoke them. Resources are application-driven, with the client determining what enters context. Prompts remain user-controlled, typically selected by a person via a slash command.

Thus: when the model determines the timing, it's a tool. Read-only context that a client may attach is a resource. A reusable workflow intentionally initiated by a person is a prompt.

Lazy Shot puts tools at the center. Actions like capturing, searching, naming, and marking occur at moments the agent picks, and since library lookups require arguments, they count as tools as well. The server includes a small set of resources and two built-in prompts for multi-step jobs, yet we avoid designing around them for a practical reason: client support for resources and prompts is uneven, and a capability that half your clients never surface cannot be the only way to reach something. Thus, anything essential gets a tool.

Small designs that mattered

Collisions auto-suffix. assign_keyword assigns a brief, memorable name to a capture. Should rocket already exist, the capture is renamed to rocket-2, and the result reflects this change. Otherwise, the agent might fabricate rocket-new-final in response to an error, or an overwrite might render the previous capture inaccessible. By returning the final name, the system ensures the agent's subsequent call remains accurate.

Markers fork by default. add_markers creates a new library entry, a copy carrying the markers as a metadata layer, unless the caller explicitly asks for an in-place edit. The source remains exactly as recorded. Should an agent mark the incorrect region, you have merely incurred the cost of one additional entry, and the before/after pairing is preserved.

Soft delete. delete_screenshot marks a capture as deleted rather than erasing the original file. Since a model equipped with a delete tool will inevitably target the wrong item, ensure this error is merely annoying.

Directed capture with a record. The act of capture is triggered solely by an explicit invocation: each capture is an explicit tool call, recorded in the app's log. The rationale for this approach is detailed in our article on directed versus ambient capture; regarding server design, a record the user can inspect proves less costly than a permission prompt.

All four reflect the same choice. Because agents repeat, guess and retry, any tool should tolerate both incorrect and duplicate calls.

Trade-offs we accept

  • No stdio. As detailed earlier, this is the first flaw we cite whenever comparing our server to others.
  • Limited to macOS and Windows desktops. There is no Linux version, no headless option, and no support for CI pipelines. The server requires a display and a running app to function.
  • Localhost by design. The server binds to 127.0.0.1 by default, and remote or cloud-hosted agents are unable to use the paths it returns: the path contract wouldn't last the journey.
  • A closed-source app. No npx line exists. The cookbook repo recipes are open, but the server is not.
  • A free-tier limit of 10 daily calls. Sufficient to test a loop, insufficient to execute one.

The stdio gap is the first thing we would revisit, probably by documenting one supported bridge rather than leaving the choice to each user.

A checklist for MCP server authors

Our checklist for capture tools covers the duties a capture tool has toward the user. This one deals with the server.

 1. Name tools verb_noun from one small vocabulary. Add a list_ tool for every ID another tool takes.
 2. Return tools/list in a stable order.
 3. Return small, flat results. Keep field names identical across tools and across releases.
 4. Send structuredContent and the same JSON as text.
 5. Return references to large artifacts, not the bytes, when caller and server share a disk.
 6. Reserve JSON-RPC errors for broken requests. Everything the model can fix is isError: true.
 7. Every error says what failed, whether a retry helps, and what to call instead.
 8. Make writes safe to repeat: suffix on collision, fork on edit, soft-delete on delete.
 9. Write one log line per operation, and ship a one-click export of the logs.
10. On HTTP: validate Origin, and show the user the port you bound.
11. Set annotations truthfully and assume clients distrust them.
12. Document what the server does not do, next to what it does.

FAQ

When should a new MCP server pick stdio over Streamable HTTP? If the client can launch your server as a process and nothing else needs to be running, stick with stdio, which has the broadest support across clients. But if the server embeds in a long-running app or handles multiple clients simultaneously, go with Streamable HTTP and design for a bridge. Avoid beginning with the deprecated HTTP+SSE transport.

When does a failure count as a protocol error versus isError? A JSON-RPC protocol error occurs with an unknown tool, malformed request, or server crash. Conversely, a tool result with isError: true covers bad input, missing targets, quotas, or failed downstream calls, since the model can interpret this to adjust its subsequent action.

Does Lazy Shot's server expose resources and prompts or only tools? The system is centered on tools. The agent's tasks—capturing, searching, naming, and marking—are executed via tool calls, and no critical functionality relies on a client handling the other two primitives.


Heretic Lazy Shot: screenshot, annotation, and beautification for macOS and Windows, built for humans and for agents. One-time license, €14.99 for one device or €29.99 for three. No subscription, no account, no telemetry on content. Activation is online with an offline grace period. The trial ships inside the download, no card. Try Lazy Shot →

Related posts