Skip to main content

Autonomous Workloads SDK

SDK for securing autonomous workloads and machine-to-machine communication.

Configure Workload Identity Using a SDK

Learn how to configure workload identity using a SDK.

Step 1: Install AuthSec SDK

pip install git+https://github.com/authsec-ai/sdk-authsec.git

Import Dependencies

from authsec_sdk import QuickStartSVID

Example Usage

from AuthSec_SDK import (
mcp_tool, # unprotected tool decorator
protected_by_AuthSec, # protected tool decorator
run_mcp_server_with_oauth, # function to run MCP server with OAuth
QuickStartSVID # SPIRE workload identity
)

@mcp_tool(
"get_spire_identity",
description="Get current SPIRE workload identity (SPIFFE ID and certificate paths)",
inputSchema={"type": "object", "properties": {}}
)
async def get_spire_identity(arguments: dict) -> list:
"""Get SPIRE workload identity information"""
try:
svid = await QuickStartSVID.initialize(socket_path="your/agent/path.sock")
result = {
"status": "success",
"spiffe_id": svid.spiffe_id,
"certificate": str(svid.cert_file_path),
"private_key": str(svid.key_file_path),
"ca_bundle": str(svid.ca_file_path),
"auto_renewal": "enabled (30 min)"
}
return [{"type": "text", "text": json.dumps(result, indent=2)}]
except RuntimeError as e:
# SPIRE not enabled
return [{"type": "text", "text": json.dumps({
"status": "disabled",
"message": str(e),
"note": "To enable SPIRE, add 'spire_socket_path' parameter to run_mcp_server_with_oauth()"
}, indent=2)}]
except Exception as e:
# SPIRE enabled but error occurred
return [{"type": "text", "text": json.dumps({
"status": "error",
"error": str(e),
"note": "SPIRE is enabled but agent connection failed"
}, indent=2)}]

Main Server Entry Point

if __name__ == "__main__":
import sys

run_mcp_server_with_oauth(
user_module=sys.modules[__name__],
client_id="your_client_id",
app_name="Secure MCP Server with AuthSec",
host="0.0.0.0",
port=3008,
)

Install and configure Spire Agent.

Learn how to deploy SPIRE agents on Kubernetes, Docker, and VM environments.

Step 1: Add Helm Repository

# Add AuthSec Helm repo
helm repo add authsec https://charts.authsec.ai
helm repo update

Step 2: Create values.yaml

cat > icp-agent-values.yaml <<EOF
# ICP Agent Configuration
image:
repository: your-docker-registry.example.com/icp-agent
tag: latest
pullPolicy: Always

# Agent settings
agent:
tenantId: "your-tenant-id-here"
clusterName: "my-k8s-cluster"
icpServiceUrl: "https://your-icp-server.example.com/spiresvc"
logLevel: info
socketPath: /run/spire/sockets/agent.sock

# Service Account
serviceAccount:
create: true
name: icp-agent

# Security Context
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
add:
- SYS_PTRACE # Required for process attestation
seccompProfile:
type: RuntimeDefault

# Resources
resources:
limits:
cpu: "500m"
memory: "512Mi"
requests:
cpu: "100m"
memory: "128Mi"

# Health probes
healthProbe:
enabled: true
port: 8080
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 10
failureThreshold: 3
readinessProbe:
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3

# Tolerations (run on all nodes)
tolerations:
- operator: Exists

# Node selector (optional - restrict to specific nodes)
nodeSelector: {}
# role: worker

# Affinity (optional)
affinity: {}
EOF

Step 3: Install Agent

# Install in default namespace
helm install icp-agent authsec/icp-agent \
-f icp-agent-values.yaml \
--namespace default \
--create-namespace

# Wait for DaemonSet to be ready
kubectl rollout status daemonset/icp-agent -n default

Step 4: Verify Installation

# Check DaemonSet
kubectl get daemonset -n default

# Check pods (should be 1 per node)
kubectl get pods -n default -l app=icp-agent -o wide

# Check logs
kubectl logs -n default -l app=icp-agent --tail=50

# Check health
kubectl exec -n default -l app=icp-agent -- curl http://localhost:8080/healthz