grantex-strands
Strands Agents SDK integration for the Grantex delegated authorization protocol - scope-enforced agent tools.
Wrap Strands tool functions with Grantex grant token scope checks so agents only receive tools they have been authorized to use.
Install
Version 0.2.0 is a breaking release requiring Python 3.11+ and
grantex 0.7+. Online tools forward audience to client.enforce().
The default verified mode checks signatures and scopes, not current
revocation. This helper has no amount extractor; for capped tools call
Grantex.enforce(..., amount=...) directly before execution. Do not use
caps_mode="warn" or "off" as production spend enforcement. See the
migration guide.
pip install grantex-strands==0.2.0 grantex==0.7.0
You also need the Strands Agents SDK installed:
pip install strands-agents
Quick Start
from grantex_strands import create_grantex_tool
def get_calendar_events(date: str = "") -> str:
return f"events for {date}"
read_calendar = create_grantex_tool(
name="read_calendar",
description="Read upcoming calendar events",
grant_token=grant_token,
required_scope="calendar:read",
func=get_calendar_events,
)
# Pass read_calendar into your Strands agent tools list.
If the verified grant token does not include the required scope, create_grantex_tool raises PermissionError immediately and the tool is not created.
Enforcement Modes
Verified mode is the default. It verifies the grant token against JWKS and checks the verified scp claim:
tool = create_grantex_tool(
name="read_calendar",
description="Read upcoming calendar events",
grant_token=grant_token,
required_scope="calendar:read",
func=get_calendar_events,
)
Online mode delegates enforcement to a Grantex client:
tool = create_grantex_tool(
name="read_calendar",
description="Read upcoming calendar events",
grant_token=grant_token,
required_scope="calendar:read",
func=get_calendar_events,
client=grantex_client,
connector="calendar",
online=True,
)
API Reference
create_grantex_tool()
Creates a Strands-compatible tool with Grantex scope enforcement.
| Parameter | Type | Description |
|---|---|---|
name |
str |
Tool name |
description |
str |
Tool description |
grant_token |
str |
JWT grant token from Grantex |
required_scope |
str |
Scope that must be present in the token |
func |
Callable[..., str] |
Function to wrap |
jwks_uri |
str |
JWKS URL used to verify the grant token |
issuer, issuer_did, audience |
str | None |
Optional JWT claim validation settings |
clock_tolerance |
int |
Clock tolerance in seconds for token verification |
client |
Any |
Grantex client instance for online mode |
connector |
str | None |
Connector name for online mode |
online |
bool |
Use client.enforce() instead of offline JWT scope checking |
get_tool_scopes()
Returns the scopes embedded in a grant token. Invalid tokens return an empty list.
Requirements
- Python 3.11+
grantex >= 0.3.12strands-agents >= 0.1
Grantex Ecosystem
This package is part of the Grantex ecosystem. See also:
grantex- Core Python SDKgrantex-crewai- CrewAI integrationgrantex-openai-agents- OpenAI Agents SDK integrationgrantex-adk- Google ADK integration
License
MIT
Ownership
Grantex is owned by Orchestrum Technologies LLP. Inventor and owner: Sanjeev Kumar. Ownership contact: sanjeev@orchestrum.in or mishra.sanjeev@gmail.com.
Metadata
Release files for grantex-strands 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| grantex_strands-0.2.0.tar.gz | 8.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| grantex_strands-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / grantex_strands-0.2.0.tar.gz
| Download URL | grantex_strands-0.2.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90ce6243fefa733cf3e2fc108ac1d2caf8ad685e121f273f6985938f26004c58
|
|
BLAKE2b-256 checksum How to use checksums |
92265e6122f43c8fe8dffe08e2d3afab06e85aa6c9ef2e1b605a755bdea5ea8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / grantex_strands-0.2.0-py3-none-any.whl
| Download URL | grantex_strands-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
598a8f51f7f520a46a2c0e645d7611b197113eb34b78061c51d44f3b4c648a17
|
|
BLAKE2b-256 checksum How to use checksums |
6f2b8782d5558b6eb187f41a6c4196c63279c2747ce6dfb8548102b288edce09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|