Skip to main content

🛡️ StarkGate SDK

Official Python SDK for StarkGate — The Universal Firewall for AI Agents.

Installation

pip install starkgate-sdk

Quick Start

from starkgate import StarkGate

guard = StarkGate(api_key="sk_live_your_key")

result = guard.evaluate(
    agent_id="my-bot",
    policy_id="pol_safe",
    action_type="sql_query",
    payload={"query": "DROP TABLE users;"}
)

if result.is_denied:
    print(f"🛑 Blocked: {result.reason}")

Decorator Protection

from starkgate import StarkGate

guard = StarkGate(api_key="sk_live_your_key")

@guard.protect(agent_id="devops", policy_id="pol_prod", action_type="terminal")
def run_command(cmd: str):
    import os
    os.system(cmd)

run_command("ls -la")  # ✅ Allowed
run_command("rm -rf /")  # ❌ Blocked

Async Support

import asyncio
from starkgate import StarkGate

async def main():
    guard = StarkGate(api_key="sk_live_your_key")
    result = await guard.async_evaluate(
        agent_id="trading-bot",
        policy_id="pol_trading",
        action_type="execute_trade",
        payload={"amount": 50000, "ticker": "AAPL"}
    )
    print(result.decision)

asyncio.run(main())

LangChain

pip install "starkgate-sdk[langchain]"
from starkgate.langchain_guard import make_starkgate_tool

# hors-ligne : politique inline, aucun serveur
tools = [make_starkgate_tool(policy=my_policy)]
# cloud      : politique gérée côté serveur
# tools = [make_starkgate_tool(api_key="sk_live_...", policy_id="pol_x")]

OpenAI (function calling)

pip install "starkgate-sdk[langchain]"   # ou sans LangChain
from starkgate.openai_guard import make_starkgate_function, run_starkgate_call

tools = [make_starkgate_function(policy=my_policy)]          # mode local
# … app de chat avec tools=tools ; le modèle renvoie tool_calls …

verdict = run_starkgate_call(policy=my_policy, action_type="transfer",
                            payload={"op": "payday"})
if verdict["decision"] == "ALLOW":
    exécuter_l_action()
else:
    # disjoncteur : bloqué, preuve dans verdict["auditHash"]
    refuser(verdict)

Engine local (hors-ligne)

Le moteur d'évaluation peut tourner sans aucun serveur — bit-à-bit identique au moteur serveur (mêmes verdicts, mêmes auditHash). Idéal pour l'edge, l'air-gap, le drone, la voiture ou le satellite.

from starkgate import engine

policy = {
  "id": "pol-1", "name": "demo", "mode": "enforce", "defaultDecision": "ALLOW",
  "rules": [{
    "id": "r1", "name": "block payday", "enabled": True,
    "condition": {"field": "op", "operator": "eq", "value": "payday"},
    "decision": "DENY", "message": "Bloqué.", "riskLevel": "high",
  }],
}

verdict = engine.evaluate(
  {"agentId": "bot", "policyId": "pol-1",
   "actionType": "transfer", "payload": {"op": "payday"}},
  policy,
)
print(verdict["decision"], verdict["auditHash"])  # DENY sha256:…

Serveur MCP

Expose StarkGate à n'importe quel agent (Claude Desktop, Cursor, claude-code…) via le Model Context Protocol.

pip install "starkgate-sdk[mcp]"
python -m starkgate.mcp_server            # stdio

Outils : evaluate (cloud ou local), evaluate_local (100 % hors-ligne) et verify (re-vérifie une preuve sans le serveur).

Exemple de config claude_desktop_config.json :

{
  "mcpServers": {
    "starkgate": {
      "command": "python",
      "args": ["-m", "starkgate.mcp_server"]
    }
  }
}

Démo de bout en bout

pip install "starkgate-sdk[mcp]"
python examples/demo.py

Enregistre un compte, crée une policy, évalue ALLOW + DENY en production, puis re-vérifie la preuve cryptographique hors-ligne — « Trust the Math, not the Platform. »

License

MIT

Release files for starkgate-sdk 0.2.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 starkgate-sdk 0.2.0
File Size Uploaded
starkgate_sdk-0.2.0.tar.gz 501.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for starkgate-sdk 0.2.0
File Interpreter ABI Platform
starkgate_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 999.2 kB

Release files / starkgate_sdk-0.2.0.tar.gz

Download URL starkgate_sdk-0.2.0.tar.gz
Size 501.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2872c63fb92322bbc58370ec8a092c83295b03cad545d885cf3251834a30dd58
BLAKE2b-256 checksum
How to use checksums
aeebb246b7883192f3f36e9a38e31774361155d131d46a9ce6291f908053a1d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / starkgate_sdk-0.2.0-py3-none-any.whl

Download URL starkgate_sdk-0.2.0-py3-none-any.whl
Size 497.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4db4814c76c21c886bb65a4dcb8bbdb8d16854055b473cb90c6ebd370a44c730
BLAKE2b-256 checksum
How to use checksums
076f198652723b375e25afc83c0a407abec21c552157ca148b0a23321048cf38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

This release

0.2.0 This release

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