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 ships 54 pre-built manifests covering finance, HR, marketing, ops, and comms connectors. Load them before callingenforce().
Pre-Built Manifests
Custom Manifests
For internal APIs or connectors Grantex does not ship, define your own manifest inline, from a JSON file, or by extending a pre-built manifest. Inline definition: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
- 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, 54 connectors, 340+ tools in production