Guides

Run operations from another Worker

Write drafts, publish or speak MCP from a Worker of the same account, over a service binding to HollwareOps, with a personal token.

Run operations from another Worker

A site reads Hollware over the Hollware entrypoint, which only reads. A Worker of the same account that writes, such as a job that imports every night or an agent on Workers, uses a second entrypoint, HollwareOps: every operation of Hollware, and MCP, over a service binding. Nothing crosses the internet.

Export it

A project made with 1.1 exports it already. A project made before adds one line to src/worker.ts, then deploys:

export class Hollware extends hollware.Hollware {}
export class HollwareOps extends hollware.HollwareOps {}

Bind it

In the wrangler.jsonc of the other Worker, with the name of your Hollware Worker in service:

"services": [{ "binding": "HOLLWARE_OPS", "service": "my-cms", "entrypoint": "HollwareOps" }]

Type the binding with HollwareOpsRpc of @hollware/server, and give the Worker a personal token as a secret:

npx hollware token create --label nightly-import --scopes content:read,content:write --remote --token-file nightly.token
npx wrangler secret put HOLLWARE_TOKEN < nightly.token

Call an operation

createOpsClient of @hollware/client takes the binding and the token, and call is typed by the operation:

import { createOpsClient } from '@hollware/client'

const hollware = createOpsClient({ binding: env.HOLLWARE_OPS, token: env.HOLLWARE_TOKEN })

const draft = await hollware.call('create_draft', {
  collection: 'blog',
  locale: 'en',
  slug: 'nightly-report',
  markdown: '---\ntitle: Nightly report\ndescription: What changed today.\n---\n\nEverything ran.\n',
})

Every operation of the MCP tools is there, by the same name, with the same input and output.

Speak MCP

The same binding serves MCP at any path: send it the requests an MCP client sends, with the token in Authorization.

const answer = await env.HOLLWARE_OPS.fetch('https://cms.example.com/mcp', {
  method: 'POST',
  headers: {
    authorization: `Bearer ${env.HOLLWARE_TOKEN}`,
    'content-type': 'application/json',
    accept: 'application/json, text/event-stream',
  },
  body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'describe_site', arguments: {} } }),
})

What the token decides

HollwareOps checks no Host and no Origin: the binding itself proves the caller is a Worker of your account. Every call still runs as a personal token (hw_pat_…), or as the grant of an agent (hw_agt_…):

  • the site is the token's, and its scopes are the token's, intersected with the role of its person today;
  • the activity log names the token's person as the actor, with the client binding;
  • a read token, an unknown one, an expired one or a revoked one is refused as unauthorized, and a missing scope as insufficient_scope.

Keep the token a secret of the Worker, never a var: whoever holds it acts as its person.