Skip to content

Check a catalog when a supervision tree starts - #150

Merged
HackTuah merged 1 commit into
mainfrom
catalog-at-boot
Dec 6, 2026
Merged

HackTuah merged 1 commit into
mainfrom
catalog-at-boot

Conversation

@HackTuah

@HackTuah HackTuah commented Dec 6, 2026

Copy link
Copy Markdown
Member

What

BeamMCP.Transport.HTTP checks only that its catalog module exports capabilities/0. It does not call it, because Plug may run the transport's initialisation at the host's compile time (under forward or any Plug.Builder pipeline). A catalog that BeamMCP.Server.new/1 refuses, such as a tool whose pattern ECMA-262 does not read or two tools with one name, is then answered 500 / -32603 on every request. UPGRADING's 1.0.2 row says both transports refuse such a catalog at startup. The stdio transport does; the HTTP transport did not.

BeamMCP.Catalog.child_spec/1 adds a startup check a host puts in its supervision tree:

children = [
  {BeamMCP.Catalog, catalog: MyApp.Catalog},
  {Bandit, plug: {BeamMCP.Transport.HTTP, catalog: MyApp.Catalog, ...}, port: 4000}
]
  • It calls BeamMCP.Catalog.validate/2 once and keeps no process: a temporary child that answers :ignore.
  • A catalog it refuses fails the tree's start with {:invalid_catalog, catalog, reason}, before the children after it.
  • It takes :catalog and :pattern_dialect, and raises ArgumentError on anything else when the spec is built.

The transport's initialisation is unchanged. Checking there when not compiling would change startup for correct hosts whose catalog reads state that a later child creates.

Docs

  • README: the HTTP section shows the check before the server.
  • The transport's moduledoc: says what its initialisation checks and points to the child.
  • UPGRADING: the 1.1.0 pattern row names the child; a note corrects the 1.0.2 row.
  • CHANGELOG and docs/public-api.txt: child_spec/1 is listed.

Tests

test/beam_mcp/catalog_at_boot_test.exs:

  • A good catalog starts and the tree goes on, with nothing of the check kept.
  • An atomic-group pattern, and two tools with one name: the start fails with the same reason as validate/2, and the next child never starts.
  • pattern_dialect: :pcre admits the atomic group.
  • Bad options raise.
  • An HTTP host with Bandit after the check does not come up, while the transport's own initialisation accepts that catalog.

Checks

tools/gate.sh passes on this tree. The suite passes on Elixir 1.20 with OTP 29.

The HTTP transport checks only that its catalog exports capabilities/0,
because Plug may run its initialisation at the host's compile time. A
catalog BeamMCP.Server.new/1 refuses was then answered 500 on every
request, while UPGRADING's 1.0.2 row said both transports refuse it at
startup.

BeamMCP.Catalog.child_spec/1 makes {BeamMCP.Catalog, catalog: M} a
child that calls validate/2 once and keeps no process. A catalog it
refuses fails the tree's start with {:invalid_catalog, catalog, reason},
before the children after it. The README and the transport's docs show
it before the server, and UPGRADING corrects the 1.0.2 row.

Signed-off-by: Ayla Croft <ayla@scriptkittyos.com>
@HackTuah
HackTuah merged commit 36f5f41 into main Dec 6, 2026
25 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.

1 participant