Supervisor of a single MCP server instance.
Each instance owns its own names and registries: a unique Names
Registry (which also carries the %OzMcp.Instance.Config{} as meta
data), a duplicate Topics Registry and a duplicate Principals
Registry (which holds one entry for each open session of a principal).
The instance is a tree of three levels. Core owns the three
Registries and the owner of the task table. PubSub holds the processes
of the :pubsub module (only when the module has them). Workers holds
the supervisor of the callbacks, the supervisor of the sessions, the
reaper, the supervisor of the tasks and the processes of the snapshot.
Use the child spec {OzMcp, opts} to embed one or more instances into
the supervision tree of the host application:
children = [
{OzMcp, server: MyApp.McpServer, allowed_origins: ["http://localhost:4000"]},
{Bandit, plug: MyApp.Router, port: 4000}
]
Summary
Functions
The config of a running instance, or :not_running. A Registry that does
not run gives :not_running and never raises.
The static options of the server of the instance ({:ok, opts}), or
:not_running when the instance is not running.
The name of the instance's Names Registry.
The static options of the instance, or their defaults when the instance
is not running. A caller that must not hide that situation uses
fetch_opts/1.
The name of the instance's Principals Registry. It holds one entry for
each open session of a principal, under the key of the principal.
Runs a match specification on the instance's Names Registry, or gives
[] when the instance is not running.
The server module of an instance. An instance that does not run (or a module that is not the name of an instance) answers with its own name: the name of an instance is the server module by default.
The name of the instance's Topics Registry.
A via tuple that addresses key inside the instance's Names Registry.
Looks up a pid that is registered under key in the instance's Names Registry.
A process that died and that the Registry still holds is not running.
Types
@type t() :: atom()
Functions
@spec config(t()) :: {:ok, OzMcp.Instance.Config.t()} | :not_running
The config of a running instance, or :not_running. A Registry that does
not run gives :not_running and never raises.
@spec fetch_opts(t()) :: {:ok, OzMcp.Instance.Config.opts()} | :not_running
The static options of the server of the instance ({:ok, opts}), or
:not_running when the instance is not running.
The name of the instance's Names Registry.
@spec opts(t()) :: OzMcp.Instance.Config.opts()
The static options of the instance, or their defaults when the instance
is not running. A caller that must not hide that situation uses
fetch_opts/1.
The name of the instance's Principals Registry. It holds one entry for
each open session of a principal, under the key of the principal.
Runs a match specification on the instance's Names Registry, or gives
[] when the instance is not running.
The server module of an instance. An instance that does not run (or a module that is not the name of an instance) answers with its own name: the name of an instance is the server module by default.
The name of the instance's Topics Registry.
A via tuple that addresses key inside the instance's Names Registry.
Looks up a pid that is registered under key in the instance's Names Registry.
A process that died and that the Registry still holds is not running.