Noizu.MCP.RenderCtx (Noizu MCP v0.1.6)

Copy Markdown View Source

Render context threaded through every description render site.

A %RenderCtx{} carries the knobs that tailor how tool/field descriptions are resolved for a given caller: the requested verbosity (0–9), and — as seams for later work (spec §3) — an optional runner and model. defaults holds the resolved default chain (annotation < server < deployment/global), used when no explicit verbosity is supplied.

%Noizu.MCP.RenderCtx{
  verbosity: 0..9 | nil,     # nil ⇒ resolve via the defaults chain
  runner:    atom | nil,     # e.g. :codex, :grok, :claude (not yet consulted)
  model:     atom | String.t() | nil,
  defaults:  %{verbosity: 5}
}

default/0 yields the zero-config context (verbosity resolves to the built-in 5). Existing call sites that render descriptions without a context use it, so single-string tools render exactly as before.

effective_verbosity/1 resolves a context's verbosity to a concrete 0..9 level via the defaults chain. Note that a description's own annotation-level default verbosity (default_verbosity:) slots between an explicit verbosity and these defaults — that step lives in Noizu.MCP.Description.resolve/2, which owns the annotation value.

Summary

Functions

The zero-config render context (verbosity resolves to the built-in default).

The built-in default verbosity (5) used when nothing else applies.

Resolve this context's verbosity to a concrete 0..9 level.

Resolve the server/global default-verbosity chain into a defaults map.

Types

t()

@type t() :: %Noizu.MCP.RenderCtx{
  defaults: %{optional(:verbosity) => integer()},
  model: atom() | String.t() | nil,
  runner: atom() | nil,
  verbosity: 0..9 | nil
}

Functions

default()

@spec default() :: t()

The zero-config render context (verbosity resolves to the built-in default).

default_verbosity()

@spec default_verbosity() :: 0..9

The built-in default verbosity (5) used when nothing else applies.

effective_verbosity(render_ctx)

@spec effective_verbosity(t()) :: 0..9

Resolve this context's verbosity to a concrete 0..9 level.

Explicit verbosity wins; otherwise the defaults.verbosity chain applies; otherwise the built-in 5. Out-of-domain values are clamped to 0..9.

server_defaults(server)

@spec server_defaults(module() | term()) :: %{verbosity: 0..9}

Resolve the server/global default-verbosity chain into a defaults map.

Precedence: the server module's use Noizu.MCP.Server, default_verbosity: N option > the :noizu_mcp, :default_verbosity application env > the built-in 5. Feeds RenderCtx.defaults when a context is built from session assigns.