Agents

The MCP server

culm mcp gives an agent six local tools to build a site and export images: describe⁠, write⁠, find⁠, measure⁠, build⁠, and render⁠. On a folder it also offers add_package⁠, which can ask for a package and cannot approve one (see "What protect refuses" below and packages.md). Start with ordered JSON edits. Use culm mcp --full for low-level operations or importing existing source.

The server has no accounts and no identity. It does not sign anyone in and does not know who is calling. The one secret it uses is a random token on the local port, which keeps other programs on the same machine out (see "The local port").

For the folder the server works on, see folder-sites.md. For the operations a tool takes, see "Changing a site" in overview.md.

Starting it

culm mcp                    # standard input and output
culm mcp --port 3333 # also a local port, with a token
culm mcp --chrome /path/to/chrome
culm mcp --full # general editing API, including read, apply, diff and restore
culm mcp --sections # five tools; each write replies with a short receipt

culm mcp speaks the protocol on standard input and output, and writes nothing else to standard output. Run it from the project folder. A host that starts it as a child process, such as an editor or an agent runner, needs no port.

--port n also opens the SDK's HTTP transport on 127.0.0.1:n⁠. The server then runs until standard input ends (or it gets SIGINT or SIGTERM), so a host that closes the pipe stops it, port included. --chrome and CULM_CHROME name the Chrome that measure opens.

culm mcp refuses to start (exit 1, problems on standard error) when culm.json⁠, any file in blocks/ (including a nested one) or any file in data/ (a field declaration or a row) has a problem, because no registry can be built. Any other problem in the files does not stop it: every tool answers with the located problems as a refusal until the files load again.

A host process builds the same server over its own storage:

import { createMcpServer, protect, toolsOnGuard } from '@culmjs/tools'

const server = createMcpServer({
  store, // a SiteStore: memoryStore, fileStore, or your own
  registry,
  site: 'main', // the store's name for the site
  data, // rows for data sources
  jsonOps: true, // same six tools as the CLI; omit for the full SDK interface
  // sections: true, // the five-tool receipt profile (culm mcp --sections)
  // the two guards `culm mcp` uses; your own `Allow` can be added to the chain
  allow: (op, doc, head) =>
    protect(op, doc, head) ?? toolsOnGuard(op, doc, head),
  // browser, executable, out, locate, pageFile, build, folder: all optional
})

createMcpServer returns an unconnected SDK Server⁠. Connect it to a transport yourself. build is UNSUPPORTED_CAPABILITY unless you pass a build function. A product that keeps its site as a folder gets the package guards and the agent-read redaction from folderMcpOptions⁠, which is remote by default: see hosting the MCP server. A host with its own store and packages is outside that recipe.

Edit this page on GitHub