Install
Scope-Enforced Tools
Wrap any tool function withcreateGrantexTool to enforce Grantex scope authorization before execution:
scp claim from the JWT directly, no network call needed. If the token doesn’t include the required scope, the tool throws before your function runs.
Audit Logging
AttachGrantexAuditHandler as a LangChain callback to automatically log every tool invocation to the Grantex audit trail:
tool:<toolName>withstatus: 'success'on successtool:errorwithstatus: 'failure'on error
API Reference
createGrantexTool(options)
Creates a LangChain DynamicTool with Grantex scope enforcement.
| Option | Type | Description |
|---|---|---|
name | string | Tool name shown to the LLM |
description | string | Tool description shown to the LLM |
grantToken | string | Grantex JWT from token exchange |
requiredScope | string | Scope required to invoke this tool |
func | (input: string) => Promise<string> | Tool implementation |
GrantexAuditHandler
LangChain callback handler that writes tool invocations to the Grantex audit trail.
| Option | Type | Description |
|---|---|---|
client | Grantex | Authenticated SDK client |
agentId | string | Agent ID for audit attribution |
grantToken | string | JWT (grant ID extracted from grnt or jti claim) |
Requirements
- Node.js 18+
@grantex/sdk>= 0.1.0@langchain/core>= 0.3.0