AxioRank Docs
Integrations

Mastra

Put every tool a Mastra agent runs behind the AxioRank gateway.

The @axiorank/sdk/mastra adapter wraps a Mastra tool so AxioRank scores its arguments before it runs. The tool's id is the name sent to AxioRank.

Install

npm install @axiorank/sdk

Guard a tool

import { AxioRank } from "@axiorank/sdk";
import { guardTool } from "@axiorank/sdk/mastra";

const axio = new AxioRank({ apiKey: process.env.AXIORANK_API_KEY! });

const deploy = guardTool(deployTool, axio, { onDeny: "return" });
// ...then hand `deploy` to your Mastra agent as usual.

guardTools wraps an entire tools record in one call. A denied call raises AxioRankDeniedError by default; onDeny: "return" returns a model-readable refusal instead.

Correlate a run

Pass axio.trace() instead of axio to give every call in one agent run a shared trace id on the gateway.

Next steps

On this page