Skip to main content

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:
That is all you need. The 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 calling enforce().

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:
From a JSON file:
From a directory (load all at once):
Auto-generate from source code:
Extend a pre-built manifest:
Custom and pre-built manifests are identical at runtime. The enforce() engine, permission hierarchy, and JWT scope resolution make no distinction between them.

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:
Browse all 53 with grantex manifest list. Mix pre-built and custom manifests freely — most production deployments use both.

LangChain Integration

Wrap any LangChain tool with wrap_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.
See CLI manifest reference and CLI enforce reference for full details.

Permission Hierarchy

Grantex uses a four-level permission hierarchy. Higher levels subsume all lower levels: Coverage rules:

Scope Format

Tool enforcement scopes use the format:
Examples:

Complete Example

A full agent with scope enforcement from token exchange to tool execution:

Last modified on April 5, 2026