Install
Scope-Enforced Tools
Create Vercel AI SDK tools with Grantex authorization. The token signature and claims are verified and the required scope is checked at execution time, immediately before the application callback runs:Inspect Grant Scopes
UsegetGrantScopes to check what scopes a token has before creating tools:
Audit Logging
Wrap tools withwithAuditLogging to log every invocation to the Grantex audit trail:
API Reference
createGrantexTool(options)
Execution throws
GrantexScopeError if the verified scope is missing and does
not call the application implementation.
getGrantScopes(grantToken)
Returns unverified string[] scopes decoded from the token’s scp claim. Use this only for display or debugging; protected tool execution performs signature verification.
withAuditLogging(tool, client, options)
GrantexScopeError
Requirements
- Node.js 18+
@grantex/sdk>= 0.1.0ai>= 4.0.0 (Vercel AI SDK)zod>= 3.0.0