Skip to main content

gatra-sdk: Zero-Trust AI Agent Security SDK (Python)

Official Python client SDK for GATRA — the Zero-Trust Security Proxy & Control Plane for AI Agents, Model Context Protocol (MCP) servers, and LLM tool calls.


Overview

gatra-sdk provides native, zero-dependency Python utilities for orchestrating autonomous AI agents behind a GATRA Security Proxy. It enables Python agent frameworks (LangChain, LlamaIndex, CrewAI, AutoGen, or custom MCP clients) to mint local Ed25519 capability tokens and route tool calls through GATRA's cryptographic policy engine.

┌─────────────────┐       ┌───────────────────────────────┐       ┌─────────────────┐
│                 │  HTTP │    GATRA Security Proxy       │  HTTP │                 │
│   LLM Agent /   ├──────>│  • Ed25519 Token Auth         ├──────>│   Downstream    │
│  Orchestrator   │       │  • Stateful Trajectory Caps   │       │   MCP Tool /    │
│  (gatra-sdk)    │       │  • Schema Auto-Discovery      │       │   API Target    │
└─────────────────┘       └───────────────────────────────┘       └─────────────────┘

Key Features

  • Asymmetric Token Minting: Mint short-lived, Ed25519-signed capability tokens locally without contacting a central authorization server.
  • Proxy Client Wrapper: Executing requests through GatraClient automatically injects security headers (X-Capability-Token, X-Gatra-Directive).
  • Ephemeral Task Directives: Pass runtime, per-task guardrails directly in requests while preserving GATRA's Monotonic Restriction Principle.
  • Zero Heavy Dependencies: Pure Python implementation using Standard Library and cryptography for lightning-fast capability token minting.

Installation

pip install gatra-sdk

Quickstart

1. Basic Token Minting & Tool Execution

from gatra import GatraTokenIssuer, GatraClient

# Step 1: Initialize Token Issuer with your base64-encoded Ed25519 private key
issuer = GatraTokenIssuer(private_key_base64="YOUR_BASE64_PRIVATE_KEY")

# Step 2: Mint a capability token bound to a specific trajectory/session
capability_token = issuer.mint_token(
    trajectory_id="session_101",
    tool_pattern="*"
)

# Step 3: Initialize GATRA Client pointing to your security proxy instance
client = GatraClient(
    proxy_url="http://localhost:8080",
    capability_token=capability_token
)

# Step 4: Execute a tool call safely through GATRA
status, response, latency_ms = client.execute_tool(
    path="/v1/action",
    payload={
        "amount": 25.00,
        "currency": "USD"
    }
)

print(f"[HTTP {status}] Executed in {latency_ms}ms:", response)

Ephemeral Task Directives

Orchestrators can dynamically inject tighter guardrails for a specific execution step without altering global proxy policies:

import json

# Define an ephemeral constraint for this specific invocation
ephemeral_directive = json.dumps({
    "max_per_call": 30.00,
    "condition": "payload.currency == 'USD'"
})

# Execute request with directive attached
status, response, latency_ms = client.execute_tool(
    path="/v1/action",
    payload={"amount": 25.00, "currency": "USD"},
    directive=ephemeral_directive
)

API Reference

GatraTokenIssuer

  • __init__(private_key_base64: str) — Initializes issuer with an Ed25519 private key.
  • mint_token(trajectory_id: str, tool_pattern: str, ttl_seconds: int = 3600) -> str — Signs and returns a compact Ed25519 capability token.

GatraClient

  • __init__(proxy_url: str, capability_token: str = None) — Initializes proxy client targeting a GATRA gateway.
  • execute_tool(path: str, payload: dict, directive: str = None) -> tuple[int, dict, float] — Dispatch HTTP POST requests with automatically managed security headers. Returns (status_code, response_json, latency_ms).

Resources


License

Distributed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gatra_sdk-0.1.6.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gatra_sdk-0.1.6-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file gatra_sdk-0.1.6.tar.gz.

File metadata

  • Download URL: gatra_sdk-0.1.6.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for gatra_sdk-0.1.6.tar.gz
Algorithm Hash digest
SHA256 049f6ccc942645cbb9a1ad3d375ebf8eb2db95dde2547d8b44c4ca1180f793f8
MD5 1b8580b33f35dd58760d6f26fbab7dec
BLAKE2b-256 7839851e864ce93f1250782136877014a21267e30bf8d24ac6e412895702669c

See more details on using hashes here.

File details

Details for the file gatra_sdk-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: gatra_sdk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for gatra_sdk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2589c9213bc57e4a3f122f03e4c47a8d9488891684982f604ad1428678c201cc
MD5 525970f3d0b967506c4a860b283009d8
BLAKE2b-256 7700913aa8225f0377584eeacf11e43fcda7c10411e62143d2e7f390f37ce305

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page