What is AgentSecrets?
The Zero-Knowledge Difference
How AgentSecrets Works
Installation
Quick Start
Migrating from .env Files
Migrating from Vault / AWS
Migrating from dotenv-vault
Production Checklist
Credential Exposure
What Zero-Knowledge Means
The Proxy Model
The Three-Layer Model
Environments
Agent Identity
Storage Modes
The No get() Principle
Secret-Level Policies
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Account (init / login)
Server & Self-Hosting (server)
Docs
Shell Autocompletion
Keychain Auth
Secrets
Environments
Credential Proxy
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
Integrations Overview
Claude Desktop
Cursor
OpenClaw
HTTP Proxy (Any)
LangChain (Soon)
CrewAI (Soon)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
Ecosystem Overview
Zero-Knowledge MCP Server
Server Overview
5-Layer Architecture
Self-Hosting Guide
Authentication & Keys
Workspaces & Teams
Projects & Scope
Environments
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Security Overview
Anti-Impersonation & Process Verification
Encryption Model
Zero-Knowledge Sync
Proxy Security Layers
Threat Model
OWASP Top 10 Mitigation
Security FAQ
Third-Party Audit
Reporting Vulnerabilities
Guides Overview
Building on the SDK
Stripe Integration
OpenAI Integration
Multi-Agent Setup
Onboarding Team
CI/CD Pipeline
Publishing ZK MCP
Rotating Credentials
Auditing Team Activity
Dev to Production
Kubernetes Deployment
Monorepo Setup
Production Proxy Hardening
vs .env Files
vs HashiCorp Vault
vs AWS Secrets Manager
vs dotenv-vault
vs Infisical
When Not to Use
Proxy Not Starting
Proxy Not Resolving
Domain Blocked
Sync Conflicts
MCP Not Connecting
Session Token Errors
Proxy Session Authorization
Keychain Storage & Backends
SSRF & Destination Rules
Installation Issues
Error Codes Reference
Frequently Asked Questions
v3.1.x
v3.0.0
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
GuidesBuilding on the SDK

Building with the Python SDK

This guide covers building tools, agent workflows, and MCP servers with AgentSecrets, ensuring credentials remain protected from process memory and LLM prompt contexts.

Deployment Context: Currently, AgentSecrets operates locally on your development machine or server environment, where the local CLI and keychain-auth daemon broker secret resolution. Fully managed cloud workspace delegation for end-users is on the future product roadmap.


Using Official Vendor SDKs (Interception & Credential Helper)

When building applications with standard Python client libraries (stripe, openai, anthropic, langchain), initialize init() at startup and supply credential.<KEY> placeholders to your client configurations:

import stripe from agentsecrets import init, credential # 1. Initialize interception at application startup init() # 2. Configure official libraries with zero-knowledge credentials stripe.api_key = credential.STRIPE_SECRET_KEY # 3. Use standard SDK methods def get_account_balance(): return stripe.Balance.retrieve() def create_payment_charge(amount: int, currency: str = "usd", source: str = "tok_visa"): return stripe.Charge.create( amount=amount, currency=currency, source=source )

How it works:

  • Application memory holds only the placeholder reference string ("AS_SECRET_STRIPE_SECRET_KEY").
  • When an outgoing API call is made, the interceptor routes the request through the local proxy.
  • Real keys are resolved by keychain-auth and injected directly into the outbound TLS stream at the network transport boundary.

Direct Proxy Calls via AgentSecrets Client

For custom API endpoints or raw HTTP communication without third-party libraries, use the AgentSecrets context manager:

from agentsecrets import AgentSecrets class PaymentService: def __init__(self, project: str = "payments"): self.project = project def get_balance(self): with AgentSecrets(project=self.project) as client: response = client.call( "https://api.stripe.com/v1/balance", bearer="STRIPE_KEY" ) return response.json()

Building Zero-Knowledge MCP Servers

To build Model Context Protocol (MCP) tools for Claude Desktop or Cursor:

  1. Scaffold from template:
    git clone https://github.com/The-17/zero-knowledge-mcp cd zero-knowledge-mcp
  2. Implement tools using init() or client.call(): Tools accept and pass key names. LLM assistants invoke tools and receive responses without the credential ever entering the prompt context window.

Unit Testing with MockAgentSecrets

Test your tools and agent workflows offline without needing a running proxy daemon:

from agentsecrets.testing import MockAgentSecrets from agentsecrets.client import Response def test_payment_balance(): mock = MockAgentSecrets() mock.set_response( "https://api.stripe.com/v1/balance", Response( status_code=200, body='{"object": "balance", "available": [{"amount": 420000, "currency": "usd"}]}', headers={} ) ) # Test execution response = mock.call("https://api.stripe.com/v1/balance", bearer="STRIPE_KEY") result = response.json() assert result["available"][0]["amount"] == 420000 assert len(mock.calls) == 1 assert mock.calls[0].bearer == "STRIPE_KEY" assert mock.calls[0].url == "https://api.stripe.com/v1/balance" # No plaintext credentials exist in test traces
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.