llms.txt

Version 0.0.1 · Owners: @benallfree

Walkthrough for app owners: llms.txt for AI agents. This page is the technical reference.

An agent that lands on a site reads /llms.txt to learn what the site is and where to go. This extension answers it when your app has no llms.txt of its own: your app's name, a preamble you write in Settings, then sections that extensions and your pb_hooks add. MCP adds one saying the app has an MCP server at /mcp and how to sign in, which an agent browsing the site would otherwise never find.

  • Your own file always wins. Put llms.txt in pb_public or pb_pages (or serve the path from a route) and that answers instead, whole. There's nothing to turn off.
  • Sections merge by heading. Everyone who adds under ## Docs lands in one ## Docs section, in the order they were added.
  • It's public. Anyone can read it, and sections run with your app's full access: add nothing you wouldn't put on your home page.

It provides the llmstxt/v1 contract.

Install · Configure · Use · Integrations · Example

Install

It's built into pocketone and on in every app: a member of the standard set, so a Go build made with standard.New() has it too. On its own:

extkit.Setup(app, []extkit.Extension{llmstxt.New()}, nil, nil)

The module is pocketone.dev/ext/llms-txt.

Configure

Settings → Extensions → llms.txt has one field, the preamble: Markdown placed after the # <app name> heading and before the sections. Start it with your own # heading to replace the app name (the name comes from Settings → Application → Application name). It's kept in the key-value store as _llms-txt/settings, so it rides along in backups. The usual shape is a one-line summary as a quote, then a paragraph:

> Acme Notes: shared notes for small teams.

Notes belong to workspaces; every note has an owner and a list of editors.

To turn the file off on a single app, in pocketone.yaml:

llms-txt:
  enabled: false

On a multisite host that doesn't reach the instances: an instance sets extensions.llms-txt.enabled: false (or pocker's isolate_config does, for every instance).

To change what extensions add, write your own llms.txt instead: it replaces the whole generated file.

Use

Open https://<your app>/llms.txt. With nothing else set up it reads:

# Acme Notes

## MCP

This app has an MCP server. Connect an MCP client to:

    https://notes.example.com/mcp

- Sign in: OAuth 2.1 with dynamic client registration. ...
- Metadata: https://notes.example.com/.well-known/oauth-protected-resource/mcp
- ...

Add sections from pb_hooks

// pb_hooks/llms.pb.js
$llmsTxt.add("Docs", "- [API guide](https://notes.example.com/docs/api): every endpoint, with examples")

// built on each request: query anything, return "" to leave it out
$llmsTxt.add("Public workspaces", (req) => {
  const rows = $app.findRecordsByFilter("workspaces", "public = true", "name", 20, 0)
  return rows.map((w) => `- [${w.get("name")}](${req.origin}/w/${w.id})`).join("\n")
})

add(heading, content) takes Markdown, or a function that builds it per request. The function gets { origin, path } (the address the request reached, for absolute links) and may be async. One that throws leaves its own section out and logs the error; the rest of the file still answers. A hooks reload starts over with the sections your files add again, so they never pile up.

Headings appear in the order first added: Go extensions' sections first, then pb_hooks'. Optional keeps its llms.txt meaning: agents short on room may skip it.

The file is served as text/plain with a five-minute Cache-Control, for GET and HEAD only.

Commands and APIs

Generated from the pocketone binary and the contracts this extension provides.

JavaScript API

What it adds to pb_hooks and page code: llms.txt JavaScript API.

Integrations

Works with

Extension How they fit
MCP Adds ## MCP: the /mcp URL, how to sign in, the protected resource metadata and a docs link. Never the tool list, which depends on who signs in.
Pages Adds ## Pages: every page with its title, private paths and pages with llms: false left out (llmsTxt: false in +config drops it). A pb_pages/llms.txt (or a route there) answers instead of the generated file: this extension's middleware runs just inside Pages' and only fills a 404. A Pages +404 page never replaces the generated file.
robots.txt Private paths (robotstxt/v1) are left out of Pages' section.
Settings Shows the preamble form (settings/v1).
Key-Value Store Keeps the preamble (kv/v1, the private name _llms-txt/settings).
Multisite Every instance answers its own /llms.txt with its own name, preamble, sections and URLs, and its own pb_public or pb_pages file wins. extensions.llms-txt.enabled: false turns it off for an instance.

Add a section from Go

Any extension adds a section through the contract, in Register or later, whoever provides it:

llmstxtv1.Add(app, llmstxtv1.Section{Heading: "Docs", Content: "- [API guide](https://example.com/docs/api)", Source: Name})

llmstxtv1.Add(app, llmstxtv1.Section{Heading: "Status", Source: Name, Render: func(e *core.RequestEvent) (string, error) {
	return "- Open since " + openedAt(e.App), nil // "" leaves it out
}})

Declare WorksWith: extkit.IDs("llmstxt/v1"). extkit.Origin(e) is the request's scheme://host for absolute links, if your section needs one and has no URL setting of its own.

Replace it

Another extension can provide llmstxt/v1 and serve the file its own way from llmstxtv1.Sections(app). This one then steps aside: it serves nothing.

Example

The example app answers /llms.txt with its name and one section it adds itself.

// Command example is a PocketBase app with a generated /llms.txt: the app's name, then a section the app adds itself.
// Run `go run . serve` and open http://127.0.0.1:8090/llms.txt. Put an llms.txt in pb_public and it answers instead.
package main

import (
	"log"

	"ganigeorgiev.com/pocketbase/pocketbase"

	llmstxtv1 "pocketone.dev/ext/contracts/llmstxt/v1"
	"pocketone.dev/ext/extkit"
	llmstxt "pocketone.dev/ext/llms-txt"
)

func main() {
	app := pocketbase.New()
	if _, err := extkit.Setup(app, []extkit.Extension{llmstxt.New()}, nil, nil); err != nil {
		log.Fatal(err)
	}
	llmstxtv1.Add(app, llmstxtv1.Section{Heading: "Docs", Content: "- [API](https://pocketbase.io/docs/api-records/): the records API", Source: "example"})
	if err := app.Start(); err != nil {
		log.Fatal(err)
	}
}

Root path

/llms.txt is the one path outside /api/_c/ an extension serves besides /.well-known/* and /mcp, because a convention outside PocketOne fixes it. It's also the only one an app can replace: the extension answers only what the app left as a 404.

License

MIT