Sitemap
Lynn Langit

Lynn Langit

Cloud Architect who codes.

Lessons from a MCP Build

A three-phase journey from local prototype to GCP Cloud Run — and the three bugs I didn’t see coming.

5 min readMar 4, 2026

--

What I Was Trying to Do

My learning-ethical-ai GitHub Repo is a curated collection of markdown files — case studies, frameworks, and analysis covering AI safety, agentic AI risks, and healthcare AI ethics. I wanted to connect that repository directly to Claude Desktop, so that Claude could read, reason over, and surface that content dynamically using MCP tools and resources.

Simple enough, right?

The goal was a fully remote, cloud-hosted MCP server running on Google Cloud Run, serving content fetched live from GitHub, accessible to Claude Desktop anywhere over the public internet.

Three phases. Three surprises.

Press enter or click to view image in full size
MCP Server Development Phased Approach

Phase 1: Fully Local

I started building for my local filesystem using Google Antigravity and Gemini 3.1. Using these tools, I was able to build a local mcp server in minutes.

Press enter or click to view image in full size
Quick start with Google Antigravity

The server ran via uv run server.py using Standard IO (stdio) transport. The data came from a local clone of the repo, recursively searched with Path.rglob(). First I used the Antigravity-included MCP Inspector tool to test the server code.

Press enter or click to view image in full size
First test of the new server with the MCP Inspector Tool

Test with Claude Desktop

Claude Desktop on macOS connected over that local stdio stream.
It worked. First try.

That’s the thing about local prototypes — they’re deceptively clean. No proxies. No network hops. No reverse engineering what Cloud Run is actually doing to your HTTP headers. When everything lives on one machine, complexity evaporates.

I took a screenshot (shown below) and decided to keep going with the build. Time to figure out how make it work faster.

Press enter or click to view image in full size
Local testing of my new mcp server in Claude Desktop — it works!

Phase 2: Remote Data, Local Execution

Phase two was about detaching the data layer from the local filesystem. I swapped the Path.rglob() logic for live HTTPS fetches from raw.githubusercontent.com. The server still ran locally over stdio, but now it pulled markdown content from GitHub into an in-memory cache (which I built) with a 5-minute TTL.

Claude Desktop read that remote content as if it were local. The cache refresh was invisible. Everything passed cleanly through the local stdio stream.

The architecture was starting to feel real. The nest step: deploy the local server from my laptop into the public cloud.

Phase 3: Fully Remote on GCP Cloud Run

Cloud Run requires SSE (Server-Sent Events) transport instead of stdio. That's the first thing that changes. The second thing that changes is that your server is now behind GCP's reverse proxy — and that proxy has opinions about HTTP Host headers.

Get Lynn Langit’s stories in your inbox

Join Medium for free to get updates from this writer.

Here’s what broke, and how I fixed it.

Bug 1: The Wrong FastMCP Package

I started with mcp.server.fastmcp — the FastMCP submodule bundled natively inside the mcp SDK. On Cloud Run, it failed with "Empty Error" and HTTP 421 Invalid Host Header responses. Ugly, cryptic, and not at all obvious.

The fix was surprisingly specific: downgrade to the standalone fastmcp==2.13.0 PyPI package. This version natively supports MCP_BASE_URL configuration, which tells the server how to construct its URLs when sitting behind a reverse proxy. The bundled submodule didn't.

One line in requirements.txt. It took quite a bit of time to debug to find it.

Bug 2: Synchronous Threads Killing SSE Heartbeats

My GitHub fetching logic used synchronous urllib.request calls. On startup, the server downloaded 24 markdown files — all of them, simultaneously, in synchronous threads.

Under that load, the Python event loop blocked for up to 10 seconds. During that window, the FastMCP web server couldn’t send SSE heartbeats. Claude Desktop interpreted the silence as a dead connection and terminated.

Gemini (in Antigravity) to the rescue! It helped me to implement a key fix: rewrite everything async. httpx.AsyncClient for HTTP fetches, asyncio throughout all tool definitions. The event loop stayed unblocked. Heartbeats kept flowing. Claude Desktop stayed connected.

This is a common pattern I’ve seen in data pipeline work — synchronous I/O sneaking into async contexts and causing silent failures under load. It always looks fine in testing. It always breaks in production.

Bug 3: The Wrong Proxy Tool

To connect Claude Desktop to an SSE server, you need something to translate between SSE and stdio. I initially reached for the third-party mcp-proxy tool. It failed — couldn't parse the payload efficiently enough under real conditions.

The fix was switching to FastMCP’s own native proxy command:

uvx fastmcp run [URL]

One command. It wraps the remote SSE endpoint directly and handles the translation natively. No third-party dependency. No parsing overhead.

Key Learnings

Press enter or click to view image in full size
Learnings from this build

Three bugs. Three phases. All of them taught me something I already “knew” but hadn’t fully internalized for MCP workloads specifically:

Cloud deployment isn’t just a hosting change — it’s an architectural stress test.

Reverse proxies, network latency, async event loops, and SSE heartbeat timing interact in ways that local stdio development hides completely. The prototype phase isn't wasted time. But it can lull you into confidence you haven't earned yet. Google Antigravity and Gemini helped me make my idea real on the cloud in just a few hours work too.

What’s Next

The server is live. Claude Desktop connects to it over the public internet. The learning-ethical-ai content — AI safety frameworks, agentic AI risk analysis, healthcare ethics case studies — is now dynamically accessible to me using Claude Desktop as a client as MCP tools and resources.

Press enter or click to view image in full size
Testing the local and remote mcp servers in Claude Desktop

The full development summary, including the architecture diagram and phased breakdown, lives in my repo: https://github.com/lynnlangit/learning-ethical-ai/tree/main/08-mcp-server

If you’re building MCP servers and planning to ship them to GCP Cloud Run I hope you can learn from the bugs above before you start. Happy building!

--

--