Skip to main content

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.

PyPI Python License

Homepage | Docs | GitHub

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.1 grantex==0.7.1

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.12
  • strands-agents >= 0.1

Grantex Ecosystem

This package is part of the Grantex ecosystem. See also:

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.

Authority hardening requires Python SDK 0.7.1 (current_authority), not just a valid JWT signature. Bind the audience and trusted human/agent identities, and check the issuer before every execution. This does not create human consent or automatically consume action decisions/spend caps. Existing offline defaults remain offline. Verify registry availability before installation. See the SDK execution authority guide.

Metadata

Release files for grantex-strands 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grantex-strands 0.2.1
File Size Uploaded
grantex_strands-0.2.1.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grantex-strands 0.2.1
File Interpreter ABI Platform
grantex_strands-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / grantex_strands-0.2.1.tar.gz

Download URL grantex_strands-0.2.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
05d65e0a45860e0dfde79f89d71aa9f4b89cdef1e5667e42e96943558b3e9f6f
BLAKE2b-256 checksum
How to use checksums
a9dcbe553854b37f02329bbc9cde2efdbdc71750906a83c083a23116fe76614a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / grantex_strands-0.2.1-py3-none-any.whl

Download URL grantex_strands-0.2.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46b105cf6856035f4b587d8c52b963054b41449887ec31aa4e28400481afda27
BLAKE2b-256 checksum
How to use checksums
6e47f7864d7d25e5e448c221f3476dc3f7d56e4092cadb9fc2d1a6862175f496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

0.2.2

2 release files

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page