Documentation Index
Fetch the complete documentation index at: https://docs.grantex.dev/llms.txt
Use this file to discover all available pages before exploring further.
What it does
This example demonstrates the@grantex/anthropic integration by building scope-enforced tools for Claude:
- Register an agent and obtain a grant token via the sandbox flow
- Create scoped tools using
createGrantexToolwith JSON Schema (calendar:read,email:send) - Use
GrantexToolRegistryto manage tools and dispatchtool_useblocks - Invoke tools via
client.messages.create()(ifANTHROPIC_API_KEYis set) or directly - Demonstrate
GrantexScopeError— attempting to execute a tool withstorage:delete(a scope not in the grant) throws aGrantexScopeErrorwithrequiredScopeandgrantedScopesproperties - Inspect scopes offline using
getGrantScopes()to decode the JWT without a network call - Inspect the audit trail to see the logged actions
Prerequisites
- Node.js 18+
- Docker (Docker Desktop or Docker Engine with Compose)
Run
Start the local Grantex stack from the repository root:ANTHROPIC_API_KEY:
Expected output
WithoutANTHROPIC_API_KEY (direct invocation):
Environment variables
| Variable | Default | Description |
|---|---|---|
GRANTEX_URL | http://localhost:3001 | Base URL of the Grantex auth service |
GRANTEX_API_KEY | sandbox-api-key-local | API key. Use a sandbox key for auto-approval |
ANTHROPIC_API_KEY | (none) | Optional. Set to use Claude for real tool use |
Source code
The full source is inexamples/anthropic-tool-use/src/index.ts.