Skip to main content
tool(fn, { description }) from @bijectionhq/library-mcp offers one query or mutation as a tool. tools(subtree, descriptions?) offers every function of a subtree, each named by its key, with an optional map from key to description. The function may be exposed (allow) or internal; the server is then one more way in, so give it the same care as allow.
Tool names are [A-Za-z0-9_.-]{1,128}. The tool takes its schemas from the function’s contract. args produce a JSON Schema 2020-12 input schema and returns an output schema, which also types structuredContent. The generated skill reference lists the function’s refuses codes. A tool cannot redeclare its argument types. The result has a JSON text block, and present(value) can add content blocks. Declare JSON-compatible arguments. annotations are hints to the client and grant nothing. A query tool is marked readOnlyHint: true.

Who a call runs as

The route runs the tool’s function with ctx.call, under the server’s under label, as the principal the server’s verifier admitted. A mutation tool joins the request’s transaction. A query tool reads in the same frame. Every guard over the acts judges the call. A guard on act.enter(fn) judges entering the function from the server, as it does for any other caller. Guards on the function’s writes, submits and grave acts judge them in the same transaction:
Place the guard in the tree beside the function; its path is its identity. A view’s calls and the model’s calls look the same to the server. Put a confirmation step inside any destructive function rather than relying on which surface called it.

Refusals

Every refusal refuses the request’s transaction: ctx.refuse, a false assumption of a strict write (Absent, Exists), a guard (Forbidden), missing authority (Disallowed) and any other host code. The host answers the call as a tool result with isError: true. Its text is <code>: <message> for the model, and _meta["com.bijection/error"] carries the typed refusal:
code is a host code, with its public reason when it has one, or one of the function’s declared refuses, with kind: "app" and, when refuses declares a payload for that code, its data. On Forbidden, guard is the path of the guard that refused. A function that throws without refusing also answers isError, and nothing it wrote commits.

Retries answer once

A client that may retry a mutation tool sends an identity for the call in params._meta["com.bijection/once"]. The host answers a call with the same caller, once, tool name and arguments with the first call’s result for a day, committing nothing new. The same once with another call refuses Invalid. A refused first call records nothing, so a retry runs again. Without once, every call is a new call.
A lost reply leaves the result Unknown: send the same request again with the same once. A view’s client does this for you (Views).