Skip to main content

Python SDK for the MAIP (Machine Agent Identity Protocol)

Project description

truthlocks-maip

Python SDK for the MAIP (Machine Agent Identity Protocol).

Installation

pip install truthlocks-maip

Quick Start

from truthlocks_maip import (
    MaipClient,
    CreateAgentRequest,
    CreateSessionRequest,
    OfferDelegationRequest,
    CheckGuardrailsRequest,
    Scope,
)

client = MaipClient(api_key="your-api-key")
# For self-hosted: MaipClient(api_key="...", base_url="https://maip.your-company.com")

# Register an agent
agent = client.register_agent(CreateAgentRequest(
    name="my-agent",
    scope=Scope(actions=["read", "write"], resources=["documents/*"]),
    public_key="base64-encoded-public-key",
))

# Create a session
session = client.create_session(CreateSessionRequest(
    agent_id=agent["id"],
    ttl_seconds=3600,
))

# Get trust score
trust = client.get_trust_score(agent["id"])
print(f"Trust level: {trust['level']}, score: {trust['score']}")

# Delegate trust
delegation = client.offer_delegation(OfferDelegationRequest(
    from_agent_id=agent["id"],
    to_agent_id="other-agent-id",
    scope=Scope(actions=["read"], resources=["documents/*"]),
    ttl_seconds=1800,
))

# Check guardrails
result = client.check_guardrails(CheckGuardrailsRequest(
    agent_id=agent["id"],
    action="write",
    resource_id="documents/report.pdf",
))

if result["allowed"]:
    pass  # Proceed with the action

Offline Bundle Verification

Verify receipt bundles without network access:

from truthlocks_maip import verify_bundle

result = verify_bundle(bundle)
if result.valid:
    print(f"Verified {result.receipt_count} receipts")
else:
    print("Bundle verification failed")

API Reference

MaipClient

Method Description
register_agent(request) Register a new agent identity
list_agents(status?, offset?, limit?) List agents with optional filters
get_agent(agent_id) Get an agent by ID
suspend_agent(agent_id) Suspend an active agent
revoke_agent(agent_id) Permanently revoke an agent
create_session(request) Create an authenticated session
terminate_session(session_id) Terminate a session
get_trust_score(agent_id) Get the current trust score
compute_trust_score(request) Compute a fresh trust score
offer_delegation(request) Offer trust delegation
accept_delegation(delegation_id) Accept a delegation
execute_orchestration(request) Execute multi-agent orchestration
check_guardrails(request) Check guardrails before an action

Error Types

Error HTTP Status Description
MaipError any Base error class
UnauthorizedError 401 Invalid or missing API key
NotFoundError 404 Resource not found
LimitExceededError 429 Rate limit or quota exceeded
VerificationError n/a Bundle/receipt verification failed

License

Apache-2.0

Project details


Download files

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

Source Distribution

truthlocks_maip-1.0.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

truthlocks_maip-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file truthlocks_maip-1.0.0.tar.gz.

File metadata

  • Download URL: truthlocks_maip-1.0.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for truthlocks_maip-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fc13af74b51c84276c322a7e2e6dc05035ff3aa9d9530ee7db7f853010214b49
MD5 f688e0ea8f29cdae3f302a925ae47713
BLAKE2b-256 b2f65930bde543b16ba36fd233e48773844e8e9d0aec78d97cefe7c02c2df821

See more details on using hashes here.

File details

Details for the file truthlocks_maip-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for truthlocks_maip-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c7f1fc64618a4a572fa872bd290ca85790f1bd178d897102f6c8c4e40c078ce
MD5 bbe21c3ec75be3ccd2744556270fbae5
BLAKE2b-256 ed1b2955bf127314dd4766dad3e7d1ea9375ec4257c78f55f1b07d527e9a0e2f

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