Why Scope Enforcement Matters
AI agents call real APIs — Salesforce, Jira, Stripe, S3 — using shared service account credentials. The credentials themselves do not restrict what an agent can do. Without enforcement, an agent authorized to read contacts can also delete contacts if the underlying credential allows it. Grantex scope enforcement closes this gap: every tool call is checked against an explicit permission manifest before execution, ensuring agents can only perform the actions their grant token authorizes.Quick Start
Add scope enforcement to your agent in five lines:enforce() call decodes the JWT, resolves the tool’s required permission from the manifest, and checks whether the token’s scopes cover it.
Loading Manifests
Grantex enforces permissions on any connector you define. You bring the manifest, Grantex enforces it. Load manifests before callingenforce().
Custom Manifests — Define Your Own
Every tool your agent calls — whether it’s an internal API, a new SaaS connector, or a proprietary service — can be enforced with a custom manifest. No waiting for a Grantex release, no dependency on us. Inline definition:Pre-Built Manifests — 53 Included
As a convenience, Grantex ships 53 pre-built manifests covering finance, HR, marketing, ops, and comms connectors. Use them as-is or as a starting point:grantex manifest list. Mix pre-built and custom manifests freely — most production deployments use both.
LangChain Integration
Wrap any LangChain tool withwrap_tool() to enforce scope checks automatically on every invocation:
Express / FastAPI Middleware
Add one-line enforcement to your tool execution endpoints:CLI Workflow
The CLI provides a complete manifest workflow: list available manifests, validate your agent’s tools against them, and dry-run enforcement.Permission Hierarchy
Grantex uses a four-level permission hierarchy. Higher levels subsume all lower levels:| Level | Permission | Allows | Example Tools |
|---|---|---|---|
| 0 | read | Query, list, get, search, fetch, download | get_contact, list_invoices, search_emails |
| 1 | write | Read + create, update, send, upload | create_lead, send_email, update_issue |
| 2 | delete | Read + write + delete, remove, void, terminate | delete_contact, void_envelope, reject_application |
| 3 | admin | Everything | run_payroll, run_period_close, force_stock_reset |
| Granted Scope | READ Tools | WRITE Tools | DELETE Tools | ADMIN Tools |
|---|---|---|---|---|
tool:X:read | Allowed | Denied | Denied | Denied |
tool:X:write | Allowed | Allowed | Denied | Denied |
tool:X:delete | Allowed | Allowed | Allowed | Denied |
tool:X:admin | Allowed | Allowed | Allowed | Allowed |
Scope Format
Tool enforcement scopes use the format:| Scope | Meaning |
|---|---|
tool:salesforce:write:* | Write access to all Salesforce tools |
tool:s3:read:* | Read-only access to S3 tools |
tool:stripe:write:*:capped:500 | Write access to Stripe tools, capped at $500 per operation |
tool:jira:admin:* | Full admin access to all Jira tools |
Complete Example
A full agent with scope enforcement from token exchange to tool execution:Related Resources
- Custom Manifests guide — define manifests for any connector, no dependency on Grantex
- Tool Manifests concept — permission hierarchy, scope format, fail-closed behavior
- TypeScript SDK enforce() reference
- Python SDK enforce() reference
- CLI manifest commands
- CLI enforce test command
- AgenticOrg case study — 35 agents, 53 pre-built + custom manifests in production