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

pip install grantex-strands

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

Metadata

Release files for grantex-strands 0.1.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.1.1
File Size Uploaded Provenance Actions
grantex_strands-0.1.1.tar.gz 6.6 kB Without provenance Details for grantex_strands-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 12.5 kB

Release files / grantex_strands-0.1.1.tar.gz

Download URL grantex_strands-0.1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b49024fb187bb22c0e80747c434bf8a7c5d38f755791b86ed06d4267a4074a9c
BLAKE2b-256 checksum
How to use checksums
b69011004abcd877ccf401f332618a0019302dd4eb174fd99a22ee6ff3be6338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

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

Download URL grantex_strands-0.1.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a48a9d2063e300a81809f6dbf0187a2e5a64f5ceb92dbb43681bd9ad6dc22afc
BLAKE2b-256 checksum
How to use checksums
bbb3abf602ed5f2f946f436f9c51e973d3ad1672dcc03ce959d0f44c400a9c47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for grantex-strands 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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