[HN Gopher] Show HN: I built an MCP server using Cloudflare's co...
       ___________________________________________________________________
        
       Show HN: I built an MCP server using Cloudflare's code mode pattern
        
       Read this article by Cloudflare this morning
       https://blog.cloudflare.com/code-mode/ the main argument being that
       LLMs are much better at writing typescript code than tool calls
       because they've seen typescript code many more times.  HN
       Discussion: https://news.ycombinator.com/item?id=45399204
       https://news.ycombinator.com/item?id=45386248  Deno provides a
       great sandbox environment for Typescript code execution because of
       its permissions system which made it easy to spin up code that only
       has access to fetch and network calls.  Stick an MCP proxy on top
       of that and you've got "CodeMode" (code intermixed with MCP tool
       calls) for more advanced workflow orchestration.
       https://github.com/jx-codes/codemode-mcp  There's a lot of things
       that can be improved here. Like a virtual file system for the agent
       to actually build up its solution instead of being forced to one
       shot the solution but the bones are there.
        
       Author : jmcodes
       Score  : 54 points
       Date   : 2025-09-28 16:23 UTC (6 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | fabmilo wrote:
       | I was just reflecting on this blog post after reading it this
       | morning. What do you think on code mode after implementing it? At
       | this point would not be better to just have a sandboxed api
       | environment with customizable api/tools endpoints? basically an
       | RL environment :)
        
         | jmcodes wrote:
         | Yeah the main value is definitely the code execution layer. You
         | could easily generate a type-safe client from your REST,
         | GraphQL, TRPC layer, expose it to the Deno layer and list the
         | types as a resource or something. No need to involve MCP at
         | all. You're basically just defining a stdlib for the LLM.
         | 
         | If you run `deno check` before executing the code you'd get the
         | type-safety loop (working on this now)
         | 
         | Later I want to see what'd happen if you give the LLM a repo of
         | sorts to store useful snippets and functions with comments for
         | later use. So the LLM itself would save workflows, be able to
         | import them into the Deno environment and chain those together.
         | 
         | It definitely needs a prompt that tells it to use the MCP
         | server but I can see it being pretty powerful.
         | 
         | I only did simple tests like get Reddit posts, their comments,
         | find the weather on those days, stick them in duckdb, and run
         | some social media metric queries.
         | 
         | I could see that same test being: "find me leads, filter by
         | keywords, run against some parquet file stored somewhere using
         | duckdb, craft an email for my boss."
         | 
         | I'm kind of ranting but I think this a pretty exciting
         | approach.
         | 
         | Edit: GraphQL style codegen layer but for all your APIs seems
         | like a pretty obvious middle layer for this, maybe next
         | weekend.
        
           | danielser wrote:
           | I came here looking for partial solutions to fill gaps in our
           | own attempts at CodeMode service. However I'll give you some
           | hope ;)
           | 
           | > Later I want to see what'd happen if you give the LLM a
           | repo of sorts to store useful snippets and functions with
           | comments for later use. So the LLM itself would save
           | workflows, be able to import them into the Deno environment
           | and chain those together.
           | 
           | OMG this is the first thing you should do. We have similar
           | now and its freaking amazing. Just discussing yesterday how I
           | can't remember it going off the rails since implementing
           | automem last week even.
           | 
           | Best thing it does, fully recaps all your daily
           | accomplishments, across all platforms (Claude Code, Claude
           | Desktop, ChatGPT, Cursor).
           | 
           | https://i.postimg.cc/Z0tYGKvf/Screenshot-2025-09-28-at-3-15-.
           | .. https://i.postimg.cc/SQX6bTzV/Screenshot-2025-09-28-at-3-1
           | 6-...
           | 
           | Called Automem by a friend of my (Jack Arturo), currently
           | closed-source, though I'm sure you could reverse engineer it
           | enough.
           | 
           | - its a hosted stack of FalkorDB + QDrant - has endpoints for
           | creating/retrieving memories - embeds stuff using ChatGPT
           | models - Uses Graph nodes for relating memories together -
           | Has a dream/sleeping phase which degrades long term memory
           | relevant, finds and tracks patterns and more. - Has an MCP
           | which connects any AI directly to memory - Automated hooks
           | which record memory queues on commit, deploy, learning
           | moments - Automated storing of all queued memories on chat
           | end. - A lot more magic under the hood too.
           | 
           | So in reality you get a near biological memory, useful by any
           | MCP agent. To be fair Jack has about a 2 month head start on
           | the rest of us with this idea haha.
           | 
           | --
           | 
           | The setup were building will be an always running setup, so
           | it also has a scheduling runtime in Node that uses MD files
           | to create automatable workflows, some uses agents, some just
           | run bash. They can call mcps, tools, run commands, log
           | output, use automem etc, all in human readable text.
           | 
           | https://i.postimg.cc/Y246Bnmx/Screenshot-2025-09-28-at-3-11-.
           | .. https://i.postimg.cc/ThM2zY5Z/Screenshot-2025-09-28-at-3-1
           | 7-... https://i.postimg.cc/vT6H26T7/Screenshot-2025-09-28-at-
           | 3-17-...
           | 
           | PS Keep up the great work on your codemode service, got some
           | great ideas from yours to incorporate to ours that should
           | resolve the one or 2 issues we had outstanding. Will share if
           | I get it working, https://github.com/danieliser/code-mode if
           | it gets any where
        
         | nivertech wrote:
         | Can you expand on the RL thing?
         | 
         | Just because an agent "lives" in the environment, doesn't make
         | it RL. It needs a reward function, or even better something
         | like Gym.
        
           | danielser wrote:
           | or did he mean Real Life environment which is how i read it,
           | with access to real APIs and tools etc.
        
       | kordlessagain wrote:
       | This is a terrible idea masquerading as innovation. Cloudflare
       | wants you to believe LLMs write TypeScript better than they make
       | tool calls, but they're really just creating another dependency
       | on their infrastructure.
       | 
       | 1. Tool calls are intentionally simple; adding a code generation
       | layer introduces needless complexity and failure points.
       | 
       | 2. Cloudflare already acts as a man-in-the-middle for ~20% of the
       | Internet with limited transparency about government data requests
       | 
       | 3. This is clearly designed to drive adoption of their Worker
       | platform and create lock-in for AI agent developers
       | 
       | Similar to their x402 payment scheme that reinvents HTTP 402
       | under their control, the community has already built alternatives
       | (see the Aperture implementation from Lightning) that don't
       | require surrendering more of your stack to Cloudflare.
       | 
       | Remember what's happening here: a company with unprecedented
       | visibility into web traffic wants even more control over how AI
       | agents interact with the internet. Even if you don't believe that
       | AI will eventually self govern itself, this is a horrible idea to
       | limit individual's ability to automate portions of their access
       | to the web.
       | 
       | No thanks.
        
         | dennisy wrote:
         | Whilst I agree that Cloudflare have a vested interest here,
         | there have been other proposers of this concept such as
         | huggingface.
         | 
         | https://huggingface.co/blog/smolagents
        
         | danielser wrote:
         | Is this not just GraphQL for MCP/Tools?
         | 
         | In which case your likely wrong, people do want it, and AI will
         | be very good at orchestrating simple patterns.
         | 
         | CF definitely has a vested interest.. The problem for them now
         | that I see is that THEY DIDN"T ACTUALLY LAUNCH IT... but did
         | describe what it is/does in complete detail.
         | 
         | Now there are gonna be dozens of non CF locked clones, just
         | like the one OP linked.
        
       | gavmor wrote:
       | > LLMs are much better at writing code than at tool calling.
       | 
       | Wait, really? This is harder to get right:
       | 
       | ``` { "jsonrpc": "2.0", "id": 102, "method": "tools/call",
       | "params": { "name": "book_flight", "arguments": { "origin":
       | "SFO", "destination": "JFK", "departureDate": "2025-10-15",
       | "returnDate": "2025-10-18", "passengers": 2, "cabinClass":
       | "business" } } } ```
       | 
       | Than the equivalent... but with `method: "POST"` boilerplate,
       | etc? Or is it literally the chaining of tools that's missing from
       | --and fundamentally faulty in--MCP client implementations?
        
         | jmcodes wrote:
         | So this is a first pass to capture the workflow part (mix code
         | and MCP calls).
         | 
         | The fetch code isn't any better than the tool code I agree, but
         | typescript code is more common so I'd guess this would be too?
         | 
         | But anyway I think the real power comes with the type-safety
         | part that I left out this morning (working on it now). From
         | what I understand Cloudflare is essentially generating an SDK
         | for the LLM to write code against.
         | 
         | Instead of writing that fetch call. The LLM would generate
         | 
         | ``` const redditResults = await
         | redditMCP_getTopPosts(subreddit); const insertMutation = await
         | duckdb_Insert("SQL STUFF", redditResults.map(...)); const
         | results = await duckDb_Query(args: duckDb_QueryArgs); return
         | resultsInSomeNiceFormat; ```
         | 
         | Where the method names come from the MCP server tools, and the
         | argument types are autogenerated from the MCP schemas
         | themselves.
         | 
         | No idea if this is a valuable workflow or not personally. I
         | just thought it was cool and wanted to tinker with it.
        
           | danielser wrote:
           | Correct, this is like giving the LLM full specs on your
           | GraphQL endpoint, and telling it have fun, get only what you
           | need.
           | 
           | Except it can use Typescript to manipulate the data mid
           | stream.
           | 
           | So in reality this is MCP Middleware + MCP Orchestration +
           | Tool Call Efficiency.
           | 
           | It will save tokens as well due to only returning what it
           | needs, but more so just think of going from 10 consecutive
           | tool calls, to 1 call that gives you everything you need and
           | nothing you don't, with 1/10th the time taken to accomplish.
        
       | WilcoKruijer wrote:
       | I find it interesting how this project uses all three major
       | JavaScript runtimes in a single project. Bun for the code itself,
       | Deno for sandboxing and Node for running the MCP server. Says
       | something about the ecosystem.
        
         | jmcodes wrote:
         | Says something about my coding haha.
         | 
         | Yeah since it's using Deno it'd be cool just use Deno
         | throughout. Definitely gotta clean up the code quite a bit.
        
           | malnourish wrote:
           | Why Deno over Bun? Forgive my naivety, I was a backend dev
           | for years and am only now familiarizing myself with the JS/TS
           | ecosystem
        
       | luckydata wrote:
       | does this approach actually work? is it more reliable than plain
       | mcp calls?
        
         | danielser wrote:
         | Think of GraphQL, this gives the AI all the structure via
         | Typescript of the MCP / API / Tools, lets it orchestrate its
         | own response.
         | 
         | So once it has the API shape in memory, it could make dozens of
         | tool calls in a single call.
         | 
         | It isn't about token saving, its about time/efficiency of tool
         | usage/response time accumulation.
         | 
         | Instead of 20 separate tool calls one after the other, you get
         | one larger, orchestrated one that only returns exactly what it
         | needed.
        
       | cpard wrote:
       | The valuable lesson from what Cloudflare claims is that if you
       | want to make an LLM perform as you expect you have to build
       | considering their strengths and weaknesses.
       | 
       | You can see the same behavior if you try to ask an LLM to code in
       | an API that is not commonly used.
       | 
       | When it comes to MCP tooling I followed a different path but with
       | similar assumptions.
       | 
       | There are tools that LLMs have been Rled to death to use. So I'm
       | modeling my tools after them.
       | 
       | Specifically, I try to have a "glob" tool, used to let the LLM
       | figure out structure. A search and a read tool and use regexp as
       | much as possible for passing parameters.
       | 
       | You can see an early version of this pattern here:
       | https://github.com/typedef-ai/fenic/blob/main/examples/mcp/d...
       | 
       | It has been working well, at least in terms of the model knowing
       | how to invoke and use the tools.
       | 
       | I have to say though that each model is different. I see
       | differences between Claude code and Codex when I use the MCP for
       | development, at least on how good they are in retrieving the
       | information they need.
       | 
       | Maybe I should try to run some benchmarking and compare more
       | formally
        
       ___________________________________________________________________
       (page generated 2025-09-28 23:00 UTC)