Skip to content

feat(mcp): the app server as a Cloudflare Worker at an address of ours (#272) - #273

Merged
alekswebnet merged 3 commits into
mainfrom
feat/mcp-worker
Nov 24, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/mcp-worker

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #272. Part of #210.

The app server gets a host: a Cloudflare Worker at mcp.embed-my.org. Nothing is deployed by this PR. Merging it puts the Worker in the repository; deploying is a step for someone signed in to the Cloudflare account (below).

Why a Worker

  • A limit reached there stops only Workers. The free plan gives 100,000 requests a day and bills nothing. The limit is the account's: over it, every Worker of the account answers an error until midnight UTC. Nothing on another host is touched, the demo and the organisation's site among them.
  • Not the demo's Vercel project. A function there was built and proven locally, then dropped: on its plan the whole account shares 4 CPU-hours a month, and over the limit the account is paused until someone acts, the demo and /embed with it. The endpoint has no sign-in, so anyone could bring that about.
  • The address is one line of config, since the domain's zone is on the same account: Cloudflare writes the DNS record and the certificate.

What changed

The MCP package (packages/mcp)

  • createApp() is exported as @missing-elements/h5p-mcp/app. It was a handler nobody outside the package could import.
  • It takes three more options, for a bundle with no package folder beside its code, where import.meta finds nothing: version, card, references. Without them it reads what it read before. A references folder that is not the author package's is refused as the server starts, so a wrong path does not quietly thin the answers.
  • bin/h5p-mcp.mjs is marked executable in git, as bin/h5p-mcp-app.mjs already is. pnpm sets that bit on every install once another workspace package depends on this one, so the file would otherwise show as changed after each install.

The Worker (apps/mcp-worker, new, private)

  • src/worker.mjs: the same handler, started by the first call.
  • scripts/stage.mjs gathers what the server reads as it runs into staged/ (not in git): the library pack's parts, the brief and the type files, the card. wrangler.jsonc attaches them to the Worker as modules, which its file system shows under /bundle, so the server's Node entry reads them as on a computer. 17 MB of the 64 MiB a Worker may be. They are modules, not static assets: nothing of them is served.
  • It writes no log of a call and has nowhere to keep one. observability.enabled is false, which switches off Workers Logs: no invocation log and no trace is stored. No store is bound. One address: no workers.dev name, no preview addresses. What Cloudflare counts for any Worker and domain, requests, statuses, CPU time, is outside that setting; the privacy policy is to name it from Cloudflare's own documents.
  • One new development dependency, wrangler, with the Workers runtime it starts (workerd). workerd's install script only checks its binary and stays off, as every dependency's does here; it is named in pnpm-workspace.yaml so the install says nothing.

Checked

  • In the Workers runtime, by apps/mcp-worker/tests/worker.test.ts (6 tests): wrangler bundles the Worker and starts it on this computer, and each answer is held to the Node server's, word for word: the tools, the list of types, a type's file, a type's fields from its part, a source checked, one refused, the card and its address. A path of what it carries answers 404, a body over 1 MB answers 413, and the config is held to its logs off, no store and one address.
  • The MCP package's tests, 31, one of them new: a host that gives its card, its version and its type files is answered from those, and a folder that is not the author package's is refused.
  • pnpm typecheck over the whole repository.
  • wrangler deploy --dry-run: 181 modules attached, 17.4 MB to upload, no bindings.

Not known until it is deployed

  • CPU on the free plan. It allows 10 ms a request, with leeway for an overrun now and then. A check took 14 to 22 ms a call on a laptop in the local runtime, and the first list of types 250 ms. If errors show: the paid plan ($5 a month, 30 s a request), or the parts as static assets, read by the author package's entry for a page.
  • Start-up. A Worker may take 1 s to start; this one is 17 MB. A deploy says how long it took.
  • No region. A Worker runs near its caller and cannot be held to one region below the Enterprise plan.

To deploy, after the merge

From the repository's root, signed in to the Cloudflare account that has the embed-my.org zone:

pnpm install
pnpm --filter @missing-elements/h5p-mcp-worker exec wrangler login
pnpm --filter @missing-elements/h5p-mcp-worker deploy:worker

The sign-in opens a browser and stays on that computer: no token of the account is in the repository or in GitHub.

@socket-security

socket-security Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedwrangler@​4.167.0981009296100

View full report

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 21 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/mcp/lib/answers.mjs Resolved
Comment thread design/mcp.md Resolved
Comment thread packages/mcp/README.md Resolved
Comment thread design/mcp.md Resolved
Comment thread design/layout.md Resolved
…used at the start, and the notes say what the Worker's log setting and the free plan's limit cover (#272)

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread design/mcp.md Resolved
…and why the Worker's address gets no answer either way (#272)
@alekswebnet
alekswebnet merged commit 83f4f5e into main Nov 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host the app server on a Cloudflare Worker, at an address of ours

1 participant