hearth

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT

README

hearth

hearth is a toolkit for building apps whose API is also a good MCP server: Protobuf options, protoc plugins and a Go runtime, so that 1 Protobuf service gives an app its API, its MCP tools, its permission checks, its events and a versioned manifest. It is for the developers of those apps, and for the agents that call them.

Status: pre-release. The options' extension numbers are in-house until the Protobuf global extension registry grants one.

Documentation: frostyard.github.io/hearth

What it does

  • 3 options on your service. hearth_rpc gives each RPC a permission, an effect (read, write or outward) and where it is reachable (UI, agent or both); hearth_selector marks the request field that scopes the permission, such as a folder; hearth_event declares an event (the options).
  • 4 plugins, 1 source. protoc-gen-hearth-manifest writes the app's manifest.json, protoc-gen-hearth-authz its permission checks, protoc-gen-hearth-mcp its MCP tools, and protoc-gen-hearth-events its event publishers. An RPC with no permission or no effect does not build.
  • Permission checks in the app. Each call is checked against the caller's grant, a list of capabilities on paths, and a stored object is checked in the app's own transaction (permissions).
  • A Connect route from the same service. protoc-gen-connect-go, pinned as a tool of the app's module, writes the app's HTTP API: the generated handler takes the API that the permission checks return, and the generated client satisfies the agent interface of the tools, so 1 service serves the app's UI and its agents. A refusal arrives as permission_denied with the capability the caller needs (the Connect route).
  • MCP tools from your RPCs. Each agent RPC is a tool with a proto3 JSON schema and the hints of its effect, served over stdio with no token (MCP tools).
  • Events that commit with the change. An event is written to an outbox in the change's transaction, and a relay publishes it, losing none on a crash (events).
  • A compatibility gate. hearth manifest diff OLD NEW exits 1 when a change needs the app's next major version (the manifest).

Install

go install github.com/frostyard/hearth/cmd/hearth@latest
go install github.com/frostyard/hearth/cmd/protoc-gen-hearth-manifest@latest
go install github.com/frostyard/hearth/cmd/protoc-gen-hearth-authz@latest
go install github.com/frostyard/hearth/cmd/protoc-gen-hearth-mcp@latest
go install github.com/frostyard/hearth/cmd/protoc-gen-hearth-events@latest

An app's module can also run each plugin with go run at the version its go.mod requires. Install lists the other ways, how to pin a version, and the requirements.

Use

Build the example app, a small notes service, from its README alone: examples/notes-lite. It walks through 1 service with the options, the buf template of the 4 plugins, the handlers and the permission hooks, the outbox and the relay, and the stdio tools. Then check a manifest:

hearth manifest validate gen/manifest.json
hearth manifest diff old/manifest.json gen/manifest.json

How it works

An app on hearth runs in 1 of 2 modes, with the same handlers. Standalone, it needs nothing else: its own user reaches its API over its private socket, as the local user who holds every capability, or its MCP tools over its stdio server, and its events go to an in-process bus. On lodge, frostyard's hub for first-party apps, lodge authenticates each caller and forwards the call on the app's lodge socket, where hearth's adapter trusts the caller's grant only after a peer check, and the app publishes its events to lodge's broker socket, which delivers each event only to a consumer whose grant reads its path. The design shows how the parts fit, and the Connect route is the API of both modes.

Develop

mise install   # the pinned tools: golangci-lint, buf, protoc-gen-go, svu
make ci        # what CI runs, the example app's gate included

Build from source explains each target.

Where to go next

Directories

Path Synopsis
Package authz is hearth's permission runtime: a grant holds capabilities, each on a path, and a check answers whether a caller may do 1 thing to 1 object.
Package authz is hearth's permission runtime: a grant holds capabilities, each on a path, and a check answers whether a caller may do 1 thing to 1 object.
cmd
hearth command
Command hearth generates and checks what an app on hearth publishes from its Protobuf service: its manifest.
Command hearth generates and checks what an app on hearth publishes from its Protobuf service: its manifest.
protoc-gen-hearth-authz command
Command protoc-gen-hearth-authz writes an app's permission checks from the Protobuf options of its service.
Command protoc-gen-hearth-authz writes an app's permission checks from the Protobuf options of its service.
protoc-gen-hearth-events command
Command protoc-gen-hearth-events writes an app's event publishers from the Protobuf options of its event messages.
Command protoc-gen-hearth-events writes an app's event publishers from the Protobuf options of its event messages.
protoc-gen-hearth-manifest command
Command protoc-gen-hearth-manifest writes an app's manifest.json from the Protobuf options of its service.
Command protoc-gen-hearth-manifest writes an app's manifest.json from the Protobuf options of its service.
protoc-gen-hearth-mcp command
Command protoc-gen-hearth-mcp writes an app's MCP tools from the Protobuf options of its service.
Command protoc-gen-hearth-mcp writes an app's MCP tools from the Protobuf options of its service.
Package connectserver serves an app's API over Connect, on the app's 2 sockets: its private socket, where its own user works, and its lodge socket, where lodge forwards a user's calls.
Package connectserver serves an app's API over Connect, on the app's 2 sockets: its private socket, where its own user works, and its lodge socket, where lodge forwards a user's calls.
Package events is hearth's event runtime: 1 event is a CloudEvents 1.0 envelope with no data, its author is the caller of the change's context, and its topic names the app, the object, the verb and the segments of the object's path.
Package events is hearth's event runtime: 1 event is a CloudEvents 1.0 envelope with no data, its author is the caller of the change's context, and its topic names the app, the object, the verb and the segments of the object's path.
broker
Package broker is hearth's transport to the broker that lodge embeds: it publishes each event to the NATS server, through lodge's Unix socket, and waits for JetStream's acknowledgement before it returns (lodge ADR-0022).
Package broker is hearth's transport to the broker that lodge embeds: it publishes each event to the NATS server, through lodge's Unix socket, and waits for JetStream's acknowledgement before it returns (lodge ADR-0022).
inproc
Package inproc is hearth's in-process event transport: 1 bus delivers each event to the subscribers of the same process, on the goroutine that published it, and it drops an event that it has already delivered.
Package inproc is hearth's in-process event transport: 1 bus delivers each event to the subscribers of the same process, on the goroutine that published it, and it drops an event that it has already delivered.
outbox
Package outbox is hearth's transactional outbox: an app writes each event in the transaction that makes the change, and a relay publishes the events in order, after the transaction has committed.
Package outbox is hearth's transactional outbox: an app writes each event in the transaction that makes the change, and a relay publishes the events in order, after the transaction has committed.
gen
internal
cmd/corrections-base command
Command corrections-base checks the corrections inbox against the base of a pull request: no record file is deleted or renamed since then, and no record changes in a field other than an empty promoted_to that is now filled (frostyard/core ADR-0081, row B2 of its repository baseline).
Command corrections-base checks the corrections inbox against the base of a pull request: no record file is deleted or renamed since then, and no record changes in a field other than an empty promoted_to that is now filled (frostyard/core ADR-0081, row B2 of its repository baseline).
e2e
Package e2e is hearth's end-to-end demo app: an in-memory note service on the generated permission checks and MCP tools of testdata/e2e/proto/frostyard/demo/v1/demo.proto.
Package e2e is hearth's end-to-end demo app: an in-memory note service on the generated permission checks and MCP tools of testdata/e2e/proto/frostyard/demo/v1/demo.proto.
model
Package model builds an app's model from the Protobuf files that a hearth plugin is asked to generate, and checks every rule of docs/specs/options.md.
Package model builds an app's model from the Protobuf files that a hearth plugin is asked to generate, and checks every rule of docs/specs/options.md.
natstest
Package natstest runs an embedded NATS server, with JetStream, for the tests of hearth's event transports.
Package natstest runs an embedded NATS server, with JetStream, for the tests of hearth's event transports.
protoschema
Package protoschema builds the JSON Schema of the proto3 JSON form of 1 message, for the input and output schema of a generated MCP tool.
Package protoschema builds the JSON Schema of the proto3 JSON form of 1 message, for the input and output schema of a generated MCP tool.
repocheck
Package repocheck holds tests that keep repository-wide rules that no compiler checks: the documentation rules of AGENTS.md (every relative link resolves, every doc is indexed), the repository boundary (no private host names or addresses), and hearth's import boundary (hearth imports no lodge, frostyard app or Pocket code, in Go or in Protobuf).
Package repocheck holds tests that keep repository-wide rules that no compiler checks: the documentation rules of AGENTS.md (every relative link resolves, every doc is indexed), the repository boundary (no private host names or addresses), and hearth's import boundary (hearth imports no lodge, frostyard app or Pocket code, in Go or in Protobuf).
workflowcheck
Package workflowcheck holds the tests that keep the repository's own files in line with frostyard/core: the GitHub Actions workflows within ADR-0021 (external actions pinned to a full commit SHA, permissions declared at the top, and checkouts that do not keep the token), the files of the repository baseline (ADR-0071, rows B1, B2, B6 and B13), and the buf configuration of ADR-0085 (no remote plugin, and every module dependency pinned by digest).
Package workflowcheck holds the tests that keep the repository's own files in line with frostyard/core: the GitHub Actions workflows within ADR-0021 (external actions pinned to a full commit SHA, permissions declared at the top, and checkouts that do not keep the token), the files of the repository baseline (ADR-0071, rows B1, B2, B6 and B13), and the buf configuration of ADR-0085 (no remote plugin, and every module dependency pinned by digest).
Package lodge is an app's adapter to lodge, the hub of frostyard's first-party apps.
Package lodge is an app's adapter to lodge, the hub of frostyard's first-party apps.
Package manifest holds hearth's app manifest: the types of format major 1, the canonical JSON encoding, and the compatibility rules that `hearth manifest diff` applies.
Package manifest holds hearth's app manifest: the types of format major 1, the canonical JSON encoding, and the compatibility rules that `hearth manifest diff` applies.
Package mcpserver serves an app's generated MCP tools over the Go MCP SDK (github.com/modelcontextprotocol/go-sdk).
Package mcpserver serves an app's generated MCP tools over the Go MCP SDK (github.com/modelcontextprotocol/go-sdk).
Package schema holds the JSON Schema of hearth's app manifest, format major 1, and the validation that a manifest passes before an app or lodge reads it.
Package schema holds the JSON Schema of hearth's app manifest, format major 1, and the validation that a manifest passes before an app or lodge reads it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL