All technical writing

06 / UNDER THE HOOD

One MCP Server for Claude and ChatGPT

Our customers want to ask questions about their solar plants in the chat app they already use. Some use Claude. Some use ChatGPT. We didn’t want to build two integrations, so we built one remote MCP server and let both connect to it.

It runs on Cloudflare Workers, following Cloudflare’s remote MCP server guide. Users log in with Auth0. The server only shows each user the plants they’re allowed to see.

Two things decided how the project went. Making the server stateless made everything else easier. Auth took longer than everything else combined.

The shape of it

Claude / ChatGPT  ──►  MCP server (Cloudflare Worker)  ──►  plant data
        │                      │
        └──── login ────► Auth0 ◄── token check

The chat app is the MCP client. It calls our Worker over HTTP. The Worker checks the user’s token, works out which plants they can see, and answers the tool call. The data side is the same pipeline output our reports use, so the LLM and the PDF report read the same numbers.

Stateless is a life saver

Older versions of MCP let a server keep a session per client: an initialize handshake, then an Mcp-Session-Id header on every call. It’s tempting, because it feels like the “proper” way to do it. We dropped it.

In our server, every request stands on its own. It carries a bearer token, the Worker validates it, does the work and forgets the request. Nothing is held between calls.

That fits Workers. Instances start and stop whenever Cloudflare wants, and requests from one user can land anywhere. With a session, we’d need somewhere to keep it, a way to find it again, and a story for when it expires halfway through a conversation. Without one, those problems don’t exist. Scaling isn’t something we think about. A restart doesn’t break anyone’s chat. Debugging means reading one request, not rebuilding the history of a session.

The protocol has since gone the same way. The 2026-07-28 spec dropped the handshake and the session header, and each request now carries its own version and capabilities. If your tools are “look something up and return it”, you probably don’t need sessions either.

Auth is the hardest part

Writing the tools was quick. Getting Claude and ChatGPT to log in properly was not.

Remote MCP uses OAuth, and the client does most of the work on its own. When the chat app first hits your server, it expects to:

  1. get told it needs to log in, and where to find your auth metadata
  2. discover the authorization server (Auth0 for us)
  3. register itself as a client, often through dynamic client registration
  4. send the user through login with PKCE
  5. come back with an access token and call your tools with it

If any step is off, the user just sees “couldn’t connect”, with nothing helpful to go on. Our server, the client and Auth0 each have their own view of what’s happening, and you only see one of them at a time.

What I’d check first next time:

  • Metadata the client can find. The client looks at specific well-known URLs. If they’re wrong or missing, it gives up before the user sees a login page.
  • Client registration. Claude and ChatGPT register themselves, and Auth0 has to allow that. The newest spec is moving from dynamic client registration to Client ID Metadata Documents, so check which one each client uses.
  • The token audience. Ask Auth0 for a token meant for your API, and verify that audience on the server. Otherwise you can get a token you can’t validate.
  • Mapping the user to their data. The token says who someone is. You still decide which plants they can see. We do that on every request, which being stateless forces anyway.
  • Testing with both clients. They don’t behave the same during login. Something that works in one can fail in the other.

Two newer MCP features I want to try

MCP Apps: the server draws, the AI fills in the data. This one surprised me. A server can now ship an HTML template as a ui:// resource and link it to a tool. When the tool runs, the chat app renders the template in a sandboxed iframe and fills it with the tool’s result. Instead of the model describing a plant’s output in a paragraph, the user gets our own chart, right in Claude or ChatGPT. It’s an official extension now (SEP-1865, ext-apps), built on what MCP-UI and OpenAI’s Apps SDK started.

Events: an event notifier, or an agent thing? I haven’t explored this yet, partly because I wasn’t sure what it was. Here’s what I found. It’s a protocol feature, not an agent feature. The server tells the client something changed, and the client decides what to do with it. There are two pieces:

  • What’s in the spec today: a client can open a subscriptions/listen stream and get told when tools change or a resource it cares about is updated. That only works while the client keeps the stream open.
  • What’s still being designed: the Triggers and Events working group is working on webhook-style callbacks, so a server can push “new data is available” without a connection held open.

The second one is the interesting one for us. A plant alert could reach the user’s agent as an MCP event, instead of the agent having to ask. It’s the same lesson as replacing polling with callbacks in our Workflows.

What I’d tell myself at the start

Make it stateless from day one. Treat auth as the main project and the tools as the easy part. Test login in both Claude and ChatGPT before writing your third tool, not after your tenth.