Skip to Content
@package-system

Tools

Schema-first tool definitions: strict JSON Schema, the x-neuralis extension, and result bounding.

Every package tool starts with a schema, not with code: one .json file in tools/ named after the tool (weather_forecast.json defines weather_forecast), a strict JSON Schema for its input, and one x-neuralis block carrying the Neuralis metadata. An invalid tool schema fails the package load for every trust tier, so native and project packages share one contract.

Root schema rules

RuleWhy
$schema is required, and must be the exact string "http://json-schema.org/draft-07/schema#"The load check accepts that spelling or the same URL without the #, nothing else: https://…, a trailing / or another draft names a meta-schema the dispatch-time validator cannot compile.
The tool's NAME — its file name — must match ^[A-Za-z0-9_-]{1,64}$The intersection every provider accepts; a provider that refuses one name refuses the whole tool list, so a name outside it fails the package at load. MCP permits . and :, so name a tool admin_tools_list, never admin.tools.list; a dotted name from a connected MCP server is withheld from the model for that run and reported on the agent's setup view.
title is requiredCatalog display.
type must be "object"MCP wire shape.
additionalProperties: false at the rootThe model must not send unexpected properties.
Every property declares type, anyOf, oneOf, or $refNo untyped inputs.
Several verbs on one tool: each verb is a root key holding its own closed object ({ "plan": { … } }) — never an action enum over one flat object, nor a root anyOf of shapesNesting reaches every provider alike (the Gemini adapter drops if/then/allOf, keeps nested objects) and dispatch rejects a field outside its verb; a root anyOf beside the closed root rejects every call. Document the order in which keys sent together apply; refer to an immutable item by a stable number. Approval never reads an argument's VALUE, so a destructive verb is a tool of its own unless its root key is declared in x-neuralis.askOnKeys (below).
required is an array of stringsStandard JSON Schema.
Root description is an operating contract: the outcome the tool enables, when to choose it, and its decisive recovery/safety boundaryThe model receives it with the full schema on every step. Keep property descriptions input-specific and long procedures in skills; automatic rules keep the constraints needed before activation.
No legacy x-tool, x-output, or x-validation blocksOne canonical extension: x-neuralis.

A tool-name preflight in code imports TOOL_NAME_PATTERN and isWireSafeToolName from @neuralis/package-system/tool-name — free of React and Node built-ins, so safe in server and browser graphs (the validation and client barrels are not).

Reserved input keys

Identity is never sourced from tool input — the runtime reads it from the verified session ticket — so the validator rejects every SessionContext field name (plus the bundled session) as a top-level input property: userId, projectId, agentId, conversationId, requestId, toolUseId, delegateRunId, delegateMode, role, priority, rolePriorities, grantedFeatures, spendLimits, llmRateLimitRpm, agentAccess, agentOwnership, displayName, session. The ban is root-only by design — only there could a model-supplied key be mistaken for caller identity — so the same names stay legitimate nested domain fields (todos[].priority, members[].userId, a chat message role). Handlers receive the verified session separately — see Sessions.

Open-bag normalization

The validator injects a default propertyNames constraint on every nested open object bag (additionalProperties: true without its own propertyNames), blocking __proto__, constructor, prototype and any key starting with __ or $. Declare your own propertyNames for a different shape; the root is exempt because it is closed anyway.

The x-neuralis extension

"x-neuralis": {
  "family": "weather",
  "operation": "weather.forecast",
  "transport": "embedded",
  "defaults": { "days": 3 },
  "annotations": { "readOnlyHint": true, "category": "network", "estimatedDurationMs": 2000 },
  "ui": { "presentation": "card", "cardType": "weather.result", "icon": "cloud-sun" },
  "requires": { "features": ["weather.read"] }
}
FieldRequiredRules
operationyesDotted path, /^[a-z][a-z0-9]*(\.[a-z][a-z0-9_]*)*$/ (e.g. catalog.list).
transportyesOne of embedded, mcp, http, stdio, remote.
familynoGroups tools for UI and gating; /^[a-z][a-z0-9-]*$/.
defaultsnoObject of default parameter values.
annotationssee belowMCP-style hints, the risk category, the optional cancellable promise.
uinopresentation (inline | card | explored), cardType, icon.
requiresnoFeature gate — see below.
askOnKeysnoRoot keys whose PRESENCE makes a call ask for approval — below.
concurrencySafenotrue only: two calls may run at once. Requires readOnlyHint: true; not beside askOnKeys.

Unknown x-neuralis keys are rejected, recovery included: recovery posture comes from the platform's mutation-safety policy at runtime.

askOnKeys — a per-key approval posture

The approval guarantee is resolved per tool and never reads an argument's value. The one declared exception is presence-based: a call that SENDS one of the listed root keys turns an otherwise-quiet posture into an approval request — {"delete": false} asks too. It can only make a call ask, never grant one approval would have stopped.

It is valid only on a tool with destructiveHint: true whose category is write, execute, network or machine (every other category asks about every call anyway, so there it is rejected at load), with at most eight distinct keys, each a real root property of the tool's own input schema. A writer whose delete key must be confirmed keeps its ordinary edits quiet without splitting into two tools.

Risk category is mandatory for native tools

annotations.category classifies the tool for guard-profile evaluation and is required on every natively-authored tool: read, write, execute, network, machine, credential, admin, or unknown. Imported tools (external MCP servers) default to unknown plus destructiveHint: true, and unknown is approval-required in every guard profile. Features answer "may this caller access the capability"; the category answers "what approval posture applies once access is granted".

The boolean hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) and estimatedDurationMs are optional MCP annotations. With no ui.cardType and no explicit ui.presentation, readOnlyHint: true renders the call in the compact explored style — set ui.presentation when the user must look at the result.

annotations.cancellable — what happens when a run is stopped

cancellable is an optional boolean, a promise about your handler: when a person stops the turn, the platform hands it the run's abort signal and waits for it to finish, with only your trust tier's execution ceiling as a backstop — declare it only for a tool that returns promptly once the signal fires.

Left off (the default), the tool is never interrupted: after a short grace the platform stops waiting and tells the model the call was interrupted, while the handler runs to completion, its result discarded — the safer answer for anything that mutates state.

requires — feature gating on tools

requires.features is the one declarative source of tool feature-gating. A caller missing any listed feature never sees the tool — not in the model-facing catalog, hosted MCP or the client snapshot — and a direct dispatch is rejected with a generic message. requires.escalations is catalog metadata only: it documents stronger features a handler may demand based on its input, without itself gating. Semantics and the shared predicate: Features and access.

A complete example

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "List Catalog",
  "type": "object",
  "additionalProperties": false,
  "description": "List all items in the catalog. Returns an array of items with id, name, and status.",
  "properties": {
    "filter": {
      "type": "string",
      "enum": ["active", "archived", "all"],
      "default": "active",
      "description": "Optional filter by status."
    }
  },
  "required": [],
  "x-neuralis": {
    "operation": "catalog.list",
    "transport": "embedded",
    "annotations": { "readOnlyHint": true, "category": "read" }
  }
}

Handlers pair with schemas by filename — tools/catalog_list.json with src/tools/catalog_list.ts, natively or in a project package's WASM build. See Lifecycle and Building for WASM for the handler contracts.

Result shape and bounding

A handler returns { content, isError?, structuredContent?, _meta? }. content is a string or an array of MCP text, image, audio or resource blocks; any other block type is silently dropped. Image, audio and resource blocks reach the model payload intact (video rides an embedded resource with a video/* mimeType — there is no video block), and an external server's resource_link is normalized into resource. The in-product model reads only content, so put the facts it needs there. structuredContent is JSON for card rendering and external MCP clients. _meta is UI/runtime-only and is stripped before the model ever sees it — put accounting and runtime metadata under _meta.neuralis.*.

Every result is bounded so one call can never flood a conversation:

PartitionDefault cap
content[].text (total)20,000 characters
structuredContent (serialized)20,000 characters
_meta (serialized)256,000 characters

Bounding keeps what it can — arrays shrink from the tail, top-level strings clip, primitive metadata survives — and truncated text carries a marker with the original and capped counts. The cap applies inside handlers, at the dispatch funnel and on external MCP results. These are kernel defaults; the in-product agent passes its own, admin-tunable caps.

Settled-header status convention

The chat card header draws one status icon from structuredContent: ok: true (or a string status of success / completed / pending_review) renders the green check, ok: false the red X; any other string status names the icon and its tone (error / fail red, partial amber, a word containing pending the in-flight spinner). A completed call with no marker settles as committed. Never reuse status for a domain value (an HTTP status code belongs under httpStatus), and never emit a settled status word containing pending other than pending_review: a card that claims to run forever cannot be dismissed.

Keep a card body still and let the header icon carry "this is running" — no CSS keyframe animation such as Tailwind's animate-spin or animate-pulse (App surfaces → Cards).

Binding a tool to a card

x-neuralis.ui.cardType routes a result to a package's own card surface: the value must equal a declared card's type. Card type resolves first-match-wins — an app marker on the result, then ui.cardType, then operation, then structuredContent.kind/.type, then the tool name, then default. An unmatched cardType falls back to the generic default card — often deliberate, so packaging only warns, and that warning is the only signal if you meant to ship your own card.

A sandboxed iframe card gets a second, tighter budget (the one-way card-data channel: 131,072 bytes in total, 16,384 characters per string). So:

  • Put the headline in the structure. A card that must parse a 20,000-character content blob to find a count renders a truncation marker instead; return the few fields the surface draws — a count, a status, a short top-N array — as top-level structuredContent keys.
  • The full result is a separate source of truth. Paginate and summarize; the live card view is bounded on purpose, and running, success and error must all render from whatever arrived.

On this page