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

Prerequisite: Make sure the GATRA proxy binary is running locally on port 8080:

./bin/gatra start -c policy.json -k "<YOUR_BASE64_PUBLIC_KEY>" --port 8080 --target http://localhost:3000

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 at localhost:8080
client = GatraClient(
    proxy_url="http://localhost:8080",
    capability_token=capability_token
)

# Step 4: Execute a tool call safely through GATRA Proxy
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.7.tar.gz (4.3 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.7-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gatra_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 4.3 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.7.tar.gz
Algorithm Hash digest
SHA256 b3d40b1cfde72f65502f3bbf73ee99a88a94ef71e0d43902bf116f29231452b0
MD5 ab273ec70efa3ebb97e063debb05a147
BLAKE2b-256 48b34c86fd734822d7868edbc6a555993a42f9f2e230105073711810be1792ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gatra_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f987c0572d0b3498d2cdda3499d50e26044caa065a76a2ed96248a4c970077ba
MD5 5c68d038ea6390ddda3c006cdba776f4
BLAKE2b-256 ed5a35cb1caf7d95f22d6ffa42af65ebea366454183be42713360be3e6e72a0b

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