Skip to main content

Overview

The enforce API verifies that an agent’s grant token includes sufficient scope to call a specific tool on a specific connector. It combines JWT verification with manifest-based permission resolution in a single call.

enforce()

Check whether a grant token permits a tool call.

Parameters

Response: EnforceResult

Example

Capped Scopes

When a token includes a capped scope, pass the amount to enforce against the cap:

load_manifest()

Load a single tool manifest into the client. Must be called before enforce() for the corresponding connector.

Example


load_manifests()

Load multiple tool manifests at once.

Example


ToolManifest

A manifest declares the permission level required for each tool on a connector.

Constructor

get_permission()

Look up the required permission for a tool. Returns None if the tool is not in the manifest.

add_tool()

Add a tool to an existing manifest. Useful for extending pre-built manifests with custom tools.

from_file()

Create a manifest from a JSON file on disk:
The JSON file format:

from_dict()

Create a manifest from a Python dictionary:

Permission

A class representing the four permission levels in the hierarchy.
Higher levels subsume all lower levels: admin > delete > write > read.

covers()

Check whether this permission level covers a required permission level:

is_valid()

Check whether a string is a valid permission level:

wrap_tool()

Wrap a LangChain StructuredTool so that enforcement runs automatically before every invocation.

Example


FastAPI Integration

Use GrantexAuth from grantex_fastapi as a FastAPI dependency for automatic enforcement on tool execution routes:

Last modified on April 4, 2026