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 grant token does not include the required scope, create_grantex_tool raises PermissionError immediately and the tool is not created.

Enforcement Modes

Offline mode is the default. It decodes the grant token payload and checks the scp claim without a network call:

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
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+
  • 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.0

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.0
File Size Uploaded Provenance Actions
grantex_strands-0.1.0.tar.gz 6.1 kB Without provenance Details for grantex_strands-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 11.6 kB

Release files / grantex_strands-0.1.0.tar.gz

Download URL grantex_strands-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
91fec1c7c9922eee49245678d8077706861cac78e33bfa25601ae93a5ad75180
BLAKE2b-256 checksum
How to use checksums
a8c4685e3563897549b04d6fd517cad4ab76ffd2c2a7dacf483fc1d479be3de7
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.0-py3-none-any.whl

Download URL grantex_strands-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58200132a8ea2207b0e5a6543e5f59f3514a3fe5f41266515b8c7b01cd86c226
BLAKE2b-256 checksum
How to use checksums
7419aaea92a6cbc1227b60d1bbe3716d595d01ffc9a237924ee2aa5349d045e0
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.0

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