Skip to main content

Install

Scope-Enforced Tools

Create Vercel AI SDK tools with Grantex authorization. Scope is checked at construction time — if the token is missing the required scope, createGrantexTool throws immediately:

Inspect Grant Scopes

Use getGrantScopes to check what scopes a token has before creating tools:

Audit Logging

Wrap tools with withAuditLogging to log every invocation to the Grantex audit trail:

API Reference

createGrantexTool(options)

Throws GrantexScopeError if scope is missing.

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.0
  • ai >= 4.0.0 (Vercel AI SDK)
  • zod >= 3.0.0
Last modified on July 11, 2026