Dev.to AI πŸ€– Ai πŸ‘ 2 πŸ“– 3 min read

Wiring a hosted MCP server into three clients: what actually broke

I run a public web data API with a hosted MCP endpoint, so I have spent a stupid amount of time adding the same server to three different MCP clients. This is the practical version: what the config looks like, and the fo

I run a public web data API with a hosted MCP endpoint, so I have spent a stupid amount of time adding the same server to three different MCP clients. This is the practical version: what the config looks like, and the four things that go wrong when you copy an example from a README.

The endpoint in question is https://api.cleanfetch.dev/mcp β€” streamable HTTP, key-based auth, one tool per endpoint.

The shape that works everywhere

MCP clients disagree about almost everything except the two facts that matter: the transport is streamable HTTP and the key goes in a header.

{
  "mcpServers": {
    "cleanfetch": {
      "type": "http",
      "url": "https://api.cleanfetch.dev/mcp",
      "headers": {
        "x-api-key": "cf_live_..."
      }
    }
  }
}

Authorization: Bearer <key> is accepted too. Pick one and keep it consistent per client, because a client that sees both headers can end up sending a stale one.

What broke, in order of frequency

1. type: "http" versus no type field. Older configs omit type and rely on the client inferring it from the URL. Newer ones reject the config as invalid without it. If a client silently ignores your server, add the explicit type before you debug anything else.

2. The key in an environment variable that the client never sees. Desktop clients launch the MCP process with their own environment, not your shell's. ${CLEANFETCH_API_KEY} expands to an empty string and you get a 401 that looks like a bad key. Either hard-code it in the config file for local testing, or use the client's own secret store.

3. Tool names with slashes. The convention here is one tool per live endpoint, named with an underscore instead of a slash: hackernews_top, not hackernews/top. Any example config that shows a slash-separated name was written by someone reading the REST docs, not the MCP tool list.

4. Assuming MCP calls are free or separately billed. They are not. Tool calls pass through the same gateway as REST β€” same credits, same cache, no second pool. A cached tool result costs zero, a 5xx result is not charged, and a plan_required or free_tier_exhausted error comes back with the REST status code rather than a friendly MCP-shaped message.

What the client actually receives

Each tool returns structuredContent plus a text block containing the same JSON. That is deliberate: clients that render structured content get a table, clients that only show text still get something readable, and your code can parse either.

The envelope inside is the same one REST returns: data plus meta with requestId, lookupStatus, creditsCharged, latencyMs, cached. When an agent tells you a number is wrong, requestId is how you find the actual call.

Debugging order that saves time

When a client shows no tools at all, check in this order: is the URL reachable from that machine over HTTPS (some corporate proxies block POST to non-standard paths), does the config have an explicit transport type, is the key present in the client's environment, and finally, does the tool list arrive (some clients cache the tool list until restart).

Nine times out of ten it is the environment variable. The tenth time it is a proxy.

Why hosting instead of running locally

The alternative is running a local MCP server per data source, which means installing a package per network, keeping them updated, and dealing with their respective rate limits yourself. Hosting the same catalogue behind one endpoint means one URL, one key, one bill β€” and the setup docs live in one place instead of thirty READMEs.

Setup steps for each client are in the hosted MCP docs, and the credits model is in credits and limits. If you want to test the catalogue before committing to a key, the OAuth signup gives 30 credits.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.