<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Deco My Tree notes]]></title><description><![CDATA[Deco My Tree notes]]></description><link>https://decomytree.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 01:59:56 GMT</lastBuildDate><atom:link href="https://decomytree.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[An MCP Server in Under 300 Lines That Can Write a Note but Never Read One]]></title><description><![CDATA[Notes from building a small MCP server on Cloudflare Workers: agents can look up a tree and leave a note, but no tool ever reads one.]]></description><link>https://decomytree.hashnode.dev/mcp-server-that-can-write-a-note-but-never-read-one</link><guid isPermaLink="true">https://decomytree.hashnode.dev/mcp-server-that-can-write-a-note-but-never-read-one</guid><category><![CDATA[mcp]]></category><category><![CDATA[mcp server]]></category><category><![CDATA[Cloudflare Workers]]></category><category><![CDATA[ai agents]]></category><category><![CDATA[API Design]]></category><dc:creator><![CDATA[Ömer Ercan]]></dc:creator><pubDate>Thu, 19 Nov 2026 14:59:30 GMT</pubDate><content:encoded><![CDATA[<p>I build Deco My Tree, a free website where you make a Christmas tree, share its link, and friends hang gifts with short notes on it. The notes stay sealed until Christmas Day, and only the tree's owner can read them.</p>
<p>I added a Model Context Protocol (MCP) server to it, so an assistant such as Claude or ChatGPT can look up a friend's tree and leave a note on it when you ask. The whole handler is one JavaScript file of under 300 lines, running on Cloudflare Workers. This post is about the choices in that file, and mostly about the thing that isn't in it: there is no tool that reads a note.</p>
<h2>What the server does</h2>
<p>One endpoint, <code>https://decomytree.link/mcp</code>, no sign-in, four tools:</p>
<table>
<thead>
<tr>
<th>Tool</th>
<th>What it does</th>
<th>Touches data</th>
</tr>
</thead>
<tbody><tr>
<td><code>get_tree</code></td>
<td>Looks up a tree by link or 8-character code: name, type, gift count, opening day</td>
<td>reads</td>
</tr>
<tr>
<td><code>list_gifts</code></td>
<td>Lists the gift ids a note can hang on a tree</td>
<td>reads</td>
</tr>
<tr>
<td><code>leave_message</code></td>
<td>Hangs a gift with a note of up to 500 characters on a tree</td>
<td>writes</td>
</tr>
<tr>
<td><code>days_until</code></td>
<td>Days to Christmas, Christmas Eve, New Year's Day or Valentine's Day in a time zone</td>
<td>reads</td>
</tr>
</tbody></table>
<p>A second endpoint, <code>/mcp/account</code>, adds <code>my_trees</code> for an owner who has allowed the app through OAuth: their trees' names, links, gift counts and opening days.</p>
<p>You can talk to it with nothing but curl. On 19 November this call...</p>
<pre><code class="language-bash">curl -s https://decomytree.link/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"days_until","arguments":{"occasion":"christmas","time_zone":"Europe/Istanbul"}}}'
</code></pre>
<p>...returned this:</p>
<pre><code class="language-json">{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [{ "type": "text", "text": "36 days until Christmas (Friday, December 25, 2026). Time zone: Europe/Istanbul." }],
    "structuredContent": { "occasion": "christmas", "date": "2026-12-25", "days": 36, "timeZone": "Europe/Istanbul" }
  }
}
</code></pre>
<p>The answer comes twice: a sentence for the model and structured data for code. Every successful call does that.</p>
<h2>Choice 1: stateless and POST only</h2>
<p>The server speaks Streamable HTTP but keeps no sessions and opens no event stream. A GET gets a 405 and a one-line explanation. Every POST is answered on its own as plain JSON, which works because the server never needs to ask the client anything. There is nothing to store between calls and nothing to clean up.</p>
<p>It accepts three protocol versions (2025-11-25, 2025-06-18 and 2025-03-26). If a client asks for one it doesn't know, the server answers with the newest and lets the client decide whether it can live with that.</p>
<h2>Choice 2: agents can write, never read</h2>
<p>This is the decision I care about most. A note on a tree is for one person, so no tool returns a note, and no OAuth scope would unlock one. The only scope is <code>trees:read</code>, and it covers names, links, codes, gift counts and opening days.</p>
<p>Making that a missing tool rather than a permission check means there is nothing to misconfigure. A bug in an authorization check leaks data. A tool that doesn't exist can't.</p>
<p>It also keeps the biggest pile of untrusted text away from the agent. Notes are written by strangers, and whatever an agent reads can end up steering it. The one user-written string that still comes back is the tree's name: at most 30 characters, with swear words replaced by stars. I still treat it as untrusted, but the surface is small.</p>
<h2>Choice 3: honest tool annotations</h2>
<p>MCP lets a server describe what a tool does to the world. Four tools are marked <code>readOnlyHint: true</code>. <code>leave_message</code> is the odd one out, and its definition (property descriptions trimmed) says so:</p>
<pre><code class="language-json">{
  "name": "leave_message",
  "title": "Leave a gift with a message",
  "description": "Hangs a gift with a message on a tree for the person you act for. Send only words they wrote or approved, to a tree whose link they were given; no bulk or automated messages. The owner reads it on the tree's day and always sees the sender name.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "tree": { "type": "string" },
      "sender_name": { "type": "string", "minLength": 1, "maxLength": 30 },
      "message": { "type": "string", "minLength": 1, "maxLength": 500 },
      "gift": { "type": "string" },
      "show_sender_name": { "type": "boolean", "default": true }
    },
    "required": ["tree", "sender_name", "message", "gift"],
    "additionalProperties": false
  },
  "annotations": {
    "readOnlyHint": false,
    "destructiveHint": false,
    "idempotentHint": false,
    "openWorldHint": true
  }
}
</code></pre>
<p>It isn't read-only. It isn't destructive, because it deletes nothing. It isn't idempotent, because calling it twice hangs two gifts. And it is open-world: it changes a tree that belongs to someone else. A client can use those flags to ask "send this?" before calling the tool, which is what I want from anything that writes to another person's tree.</p>
<h2>Choice 4: rules for the model, enforcement for everyone</h2>
<p>The tool description and the server's <code>instructions</code> field say the same thing to the model: send only words the person you act for wrote or approved, and no bulk or automated messages.</p>
<p>The enforcement lives somewhere else. <code>leave_message</code> has no sending logic of its own. It calls the same <code>deliverMessage</code> function as the public REST API, so the word filter and the per-minute limits for an address and for a tree apply to agents exactly as they apply to people. One code path means a rule added to the API can't be forgotten in the MCP layer.</p>
<p>One thing differs on purpose: the "who sent this" hint (rough city and device) that the website records for owners with Pro is never stored for an agent's message.</p>
<p>When a send fails, the error ends with a next step written for the model: "Rephrase it without those words" for a word-filter rejection, "Wait a minute before sending more" for a rate limit, "Check the link" for an unknown tree. A bare status code leaves the model to guess.</p>
<h2>Choice 5: boring input handling</h2>
<ul>
<li>The <code>tree</code> argument can be a full link or a bare code. A short regex pulls <code>tree=</code> out of a link, after a length check at 300 characters so the regex never sees a huge string.</li>
<li>Schemas set <code>additionalProperties: false</code> and real maximum lengths (30 characters for a name, 500 for a note), the same numbers the REST API enforces.</li>
<li>A body over 64 KB gets a 413, a batch of more than 10 messages gets a 400, and an address that asks too often gets a 429 with a JSON-RPC error.</li>
<li>An unknown tool is error -32602 and an unknown method -32601. Notifications get a 202 and no body.</li>
</ul>
<p>None of it is clever. It is the list I would want to find in someone else's server.</p>
<h2>Signing in without handing over the account</h2>
<p><code>/mcp/account</code> uses OAuth 2.0 with PKCE and dynamic client registration. A client such as Claude registers itself, the owner signs in and allows it, and the client comes back with a token. Tokens last an hour, and access ends after 30 days, or sooner if the owner changes their password. An agent with no browser can register and be claimed by the owner with a 6-digit code instead.</p>
<h2>Making the site readable for agents</h2>
<p>Every page on the site also exists as Markdown at the same address with <code>.md</code> on the end. There is an <code>llms.txt</code>, an OpenAPI file, an API catalog (RFC 9727) and an MCP server card. An agent that never calls a tool can still answer a question about the site from those files, and they are generated alongside the HTML pages.</p>
<h2>What I would copy</h2>
<p>If you are putting MCP in front of a consumer product, these are the five habits I would keep:</p>
<ol>
<li>Decide what an agent must never see, and make that a missing tool, not a permission check.</li>
<li>Mark every tool honestly, especially the ones that act on someone else's data.</li>
<li>Reuse your API's code path so the rules live in one place, and write down the places where you deliberately differ.</li>
<li>Write errors that tell the model what to do next.</li>
<li>Keep it testable with curl. It is JSON-RPC over POST; if you can't poke it by hand, debugging it will hurt.</li>
</ol>
<p>The docs for the API, the server and the rules for apps and agents are on the <a href="https://decomytree.link/developers">developers page</a>, and the machine-readable description is the <a href="https://decomytree.link/mcp/server-card">server card</a>. If you build something on top of it, the one rule is the one the tool gives the model: only send what the person you act for wrote or approved.</p>
<p>I build Deco My Tree, so read this as a builder's notes, not a neutral review. Questions are welcome in the comments.</p>
]]></content:encoded></item></channel></rss>