Erxes Support Agent
Expose curated tRPC procedures as agent-callable tools and manage them from the tool registry. This guide follows version 3.1.7 (03acdf712c).
For the annotation pattern, see GraphQL & tRPC. For gateway auth, see Authentication.
How agent tools work
There is no mastra_api backend plugin in the checked revision. Agent capability comes from the generic agent-tools layer in backend/erxes-api-shared/src/utils/agent-tools/ (manifest.ts, endpoints.ts, auth.ts, types.ts, responseLimit.ts):
- A tRPC procedure is invisible to agents by default.
- Adding
.meta({ agent: { description, permission } })admits it. Helpers exist atbackend/core-api/src/utils/agentMeta.ts,backend/plugins/sales_api/src/trpc/agentMeta.ts, andbackend/plugins/frontline_api/src/trpc/agentMeta.ts. - The platform auto-mounts
GET /agent-tools/manifestandPOST /agent-tools/callon every plugin with atrpcAppRouter. - Calls enforce tenant curation (default-deny per plugin), HMAC service auth (
x-erxes-agent-authviaJWT_TOKEN_SECRET), user permission checks, destructive-operation approval, and a response byte cap (default 64KB).
Mutations whose names match /(remove|delete|merge|destroy)/i require explicit user approval. Use typed Zod inputs so the manifest can describe fields.
Tool registry UI
frontend/plugins/mastra_ui/src/pages/tools/ToolFormPage.tsx manages the tool registry:
- Built-in types (
webSearch,fetchUrl,calculator) versuserxes-operationtools fed byMASTRA_AVAILABLE_ERXES_TOOLSruntime introspection. - Fields for
toolId,name,description, response fields, and theisEnabledtoggle. - Mutations
MASTRA_TOOL_CREATE/MASTRA_TOOL_UPDATEwith duplicate-guard via theMASTRA_TOOLSmap.
Only annotate safe, well-scoped procedures. Never annotate raw-mongo helpers, system-user internals, device-sync endpoints, or bulk-update utilities.