<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bogdan Ionut Gheorghe</title>
    <description>The latest articles on DEV Community by Bogdan Ionut Gheorghe (@bogdangheorghe).</description>
    <link>https://dev.to/bogdangheorghe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F897569%2Ff7a9b723-914e-4df7-bbed-97e78dd2a50e.png</url>
      <title>DEV Community: Bogdan Ionut Gheorghe</title>
      <link>https://dev.to/bogdangheorghe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bogdangheorghe"/>
    <language>en</language>
    <item>
      <title>My Raspberry Pi 5 has been my AI assistant on WhatsApp since June</title>
      <dc:creator>Bogdan Ionut Gheorghe</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:13:53 +0000</pubDate>
      <link>https://dev.to/bogdangheorghe/my-raspberry-pi-5-has-been-my-ai-assistant-on-whatsapp-since-june-1fol</link>
      <guid>https://dev.to/bogdangheorghe/my-raspberry-pi-5-has-been-my-ai-assistant-on-whatsapp-since-june-1fol</guid>
      <description>&lt;p&gt;Since June, a Raspberry Pi 5 has been running my general assistant, and I talk to it on WhatsApp. I'm not near the Pi right now, and it's still answering.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hardware
&lt;/h2&gt;

&lt;p&gt;A Raspberry Pi 5 with 16 GB of RAM, booting from an SD card.&lt;/p&gt;

&lt;p&gt;The agent runs on &lt;a href="https://openclaw.ai" rel="noopener noreferrer"&gt;OpenClaw&lt;/a&gt;, an open-source, self-hosted agent gateway. The Pi only runs the gateway: it keeps the agent's memory, runs its schedules and handles the chat. The thinking happens at the model providers. OpenClaw works with several of them; I use Anthropic's Claude models (Opus, Sonnet and Fable) and ChatGPT.&lt;/p&gt;

&lt;p&gt;That split is why a small computer is enough: the Pi never runs a model itself. It stays on all day, and the agent keeps working when my laptop is closed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I use it for
&lt;/h2&gt;

&lt;p&gt;It's a general assistant, so I ask it all sorts of things, but most of it is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;searching for things&lt;/li&gt;
&lt;li&gt;making presentations&lt;/li&gt;
&lt;li&gt;technical advice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When something is complicated, it creates other agents of its own to work on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it connects to WhatsApp
&lt;/h2&gt;

&lt;p&gt;OpenClaw links to a WhatsApp account the same way WhatsApp Web does: you scan a QR code from WhatsApp, under Linked devices. After that, the agent sends and receives messages as that number.&lt;/p&gt;

&lt;p&gt;You can give the agent its own number, with a cheap prepaid SIM, and message it like any other contact. Or you can link your own number and talk to it in your "Message yourself" chat. That's quicker, but the agent is then logged in as you.&lt;/p&gt;

&lt;p&gt;The Pi doesn't need any open ports for this. It calls out to WhatsApp, so nothing on the internet has to reach it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lock it down first
&lt;/h2&gt;

&lt;p&gt;An agent that can search, write files and act for you is worth protecting. On an always-on Pi, these are the basics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Only your number can talk to it.&lt;/strong&gt; In OpenClaw that's an allowlist on the WhatsApp channel; strangers can't even ask for access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The gateway listens only on the Pi itself&lt;/strong&gt;, not on your network.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No shell commands from chat&lt;/strong&gt;, and file access limited to the agent's own workspace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A firewall&lt;/strong&gt; that blocks everything incoming except SSH, &lt;strong&gt;SSH keys&lt;/strong&gt; instead of passwords, and &lt;strong&gt;automatic security updates&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What went wrong
&lt;/h2&gt;

&lt;p&gt;Only memory, when it ran out. Nothing else has given me trouble.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;I first set it up in June. Later I put the setup into scripts and rebuilt it with them, which made it smooth.&lt;/p&gt;

&lt;p&gt;Looking back, the setup is the trivial part, and the experience is the best part.&lt;/p&gt;

&lt;p&gt;If you run an agent on a Pi, or are thinking about it, I'd like to hear what you use it for.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Claude, an AI assistant, wrote this post from my answers to its questions, and added the notes on WhatsApp and security. The setup and the experience are mine.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bogdan&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ai</category>
      <category>selfhosted</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Put a TypeScript MCP server on Cloudflare Workers</title>
      <dc:creator>Bogdan Ionut Gheorghe</dc:creator>
      <pubDate>Tue, 17 Nov 2026 11:25:40 +0000</pubDate>
      <link>https://dev.to/bogdangheorghe/put-a-typescript-mcp-server-on-cloudflare-workers-1lbm</link>
      <guid>https://dev.to/bogdangheorghe/put-a-typescript-mcp-server-on-cloudflare-workers-1lbm</guid>
      <description>&lt;p&gt;A stdio MCP server only works on the machine that starts it. Once you want it in another client, on another laptop, or shared with a teammate, it needs a URL.&lt;/p&gt;

&lt;p&gt;This post takes a small TypeScript MCP server that runs on stdio and serves it from a Cloudflare Worker, behind an API key. It uses the official MCP TypeScript SDK v2 and the 2026-07-28 protocol revision, which is stateless: every request stands on its own, so there are no sessions to keep, which suits Workers well.&lt;/p&gt;

&lt;p&gt;The change is two new files: a Worker entry of about 40 lines and a short Wrangler config.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js 20 or newer&lt;/li&gt;
&lt;li&gt;A Cloudflare account (the free plan is enough for this)&lt;/li&gt;
&lt;li&gt;An MCP client: Claude Code, Cursor or VS Code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Start from a stdio server that works
&lt;/h2&gt;

&lt;p&gt;I'll use my free starter, &lt;a href="https://github.com/kitwire/mcp-server-starter-lite" rel="noopener noreferrer"&gt;mcp-server-starter-lite&lt;/a&gt; (MIT). It has two example tools, &lt;code&gt;current-time&lt;/code&gt; and &lt;code&gt;convert-units&lt;/code&gt;, and a &lt;code&gt;buildServer()&lt;/code&gt; function that creates the server. If you have your own server, the steps are the same as long as you can build your &lt;code&gt;McpServer&lt;/code&gt; from a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/kitwire/mcp-server-starter-lite.git
&lt;span class="nb"&gt;cd&lt;/span&gt; mcp-server-starter-lite
npm install
npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tests start the server over stdio and call both tools with the official MCP client.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Add a Worker entry
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;src/worker.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timingSafeEqual&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'node:crypto'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createMcpHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;localhostAllowedOrigins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;originValidationResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@modelcontextprotocol/server'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;buildServer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./server.js'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="no"&gt;MCP_API_KEY&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// One handler for the whole isolate. It calls buildServer() for every request,&lt;/span&gt;
&lt;span class="c1"&gt;// because the 2026-07-28 protocol is stateless: no sessions to keep.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createMcpHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;buildServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'/mcp'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Not found'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Browsers send an Origin header. Accept only localhost and this Worker's&lt;/span&gt;
        &lt;span class="c1"&gt;// own hostname. Other clients send no Origin and pass this check.&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;badOrigin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;originValidationResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;localhostAllowedOrigins&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;badOrigin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;badOrigin&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;hasValidKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MCP_API_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Unauthorized'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'www-authenticate'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Bearer'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mcp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sha256&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;createHash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha256'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Compare digests, not the raw strings, so a wrong key takes the same time&lt;/span&gt;
&lt;span class="c1"&gt;// to reject however many characters it gets right.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hasValidKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;given&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'authorization'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;given&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;timingSafeEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;given&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things happen in there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;createMcpHandler&lt;/code&gt;&lt;/strong&gt; turns a server factory into a web-standard &lt;code&gt;fetch&lt;/code&gt; handler. It calls &lt;code&gt;buildServer()&lt;/code&gt; once per request, so keep that function cheap: create database clients and the like once, outside it. Clients that still speak the older 2025-11-25 revision are answered too, through a stateless fallback the SDK turns on by default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Origin check.&lt;/strong&gt; The MCP spec asks servers to validate the &lt;code&gt;Origin&lt;/code&gt; header, so a web page can't use a visitor's browser to reach the server. On fetch runtimes the SDK leaves this to you. Command line clients and editors send no &lt;code&gt;Origin&lt;/code&gt; and pass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The API key check.&lt;/strong&gt; One shared key, read from a Worker secret. If the secret is missing, every request gets a 401, so a deploy without it fails closed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The stdio entry (&lt;code&gt;src/index.ts&lt;/code&gt;) stays as it is. Both entries use the same &lt;code&gt;buildServer()&lt;/code&gt;, so a tool you add works in both.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Configure Wrangler
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -D wrangler
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;wrangler.jsonc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"my-mcp-server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"src/worker.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"compatibility_date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// node:crypto needs Node.js compatibility on Workers.&lt;/span&gt;
  &lt;span class="nl"&gt;"compatibility_flags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nodejs_compat"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For local runs, Wrangler reads secrets from &lt;code&gt;.dev.vars&lt;/code&gt;. Create one with a test key and keep it out of git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"MCP_API_KEY=local-test-key"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .dev.vars
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;".dev.vars"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Run it locally
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx wrangler dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs the Worker on your machine at &lt;code&gt;http://localhost:8787&lt;/code&gt;, in workerd, the same runtime Cloudflare runs. A request without the key gets a 401:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -i -X POST http://localhost:8787/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now connect Claude Code to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http my-server http://localhost:8787/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer local-test-key"&lt;/span&gt;
claude mcp list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;claude mcp list&lt;/code&gt; should show &lt;code&gt;my-server&lt;/code&gt; as connected. Ask something like "Convert 42 km to miles" and watch the request arrive in the &lt;code&gt;wrangler dev&lt;/code&gt; output. Remove the local entry when you're done with &lt;code&gt;claude mcp remove my-server&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Deploy
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx wrangler login
npx wrangler deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;wrangler deploy&lt;/code&gt; prints the Worker's address, something like &lt;code&gt;https://my-mcp-server.&amp;lt;your-subdomain&amp;gt;.workers.dev&lt;/code&gt;. Your MCP endpoint is that address plus &lt;code&gt;/mcp&lt;/code&gt;. Until you set the key, it answers every request with a 401.&lt;/p&gt;

&lt;p&gt;Generate a key and store it as a secret:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl rand -hex 32
npx wrangler secret put MCP_API_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the key when Wrangler asks for it. The secret applies to the deployed Worker straight away; you don't need to deploy again.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Connect your clients
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Claude Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http my-server https://my-mcp-server.&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-subdomain&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;.workers.dev/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Cursor&lt;/strong&gt;, in &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt; (all projects) or &lt;code&gt;.cursor/mcp.json&lt;/code&gt; (one project):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"my-server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://my-mcp-server.&amp;lt;your-subdomain&amp;gt;.workers.dev/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer YOUR_KEY"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;VS Code&lt;/strong&gt;, in &lt;code&gt;.vscode/mcp.json&lt;/code&gt;. The &lt;code&gt;inputs&lt;/code&gt; block makes VS Code ask for the key once and store it, instead of keeping it in the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"inputs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"promptString"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"mcp-key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"MCP server API key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"servers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"my-server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://my-mcp-server.&amp;lt;your-subdomain&amp;gt;.workers.dev/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer ${input:mcp-key}"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What this setup doesn't do yet
&lt;/h2&gt;

&lt;p&gt;It's enough for you and a few people you trust. Before you give the URL to more people, these are the gaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One key for everyone.&lt;/strong&gt; Every caller is the same identity, and removing one person means changing the key for all of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No OAuth.&lt;/strong&gt; Claude's custom connectors on the web and in the desktop app connect with OAuth, not with a fixed header, so this Worker can't be added there as it is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No storage.&lt;/strong&gt; The two example tools don't keep anything. Tools that do need Workers KV, D1 or another database, with data kept per caller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No tests for the HTTP side.&lt;/strong&gt; The repo's tests cover stdio. Nothing tests the key check, the Origin check or the Worker entry.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The starter repo is MIT, and everything in this post is yours to use. If a step doesn't work for you, tell me in the comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Claude, an AI assistant, wrote this post. Every command in it was run before publishing.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Bogdan&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>cloudflare</category>
      <category>typescript</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
