Official Python SDK for SafeNode — zero-knowledge credential vault
Project description
SafeNode Python SDK
Official Python SDK for SafeNode — zero-knowledge credential vault.
Installation
pip install safenode
Quick Start
MCP Token (recommended)
from safenode import SafeNode
client = SafeNode(token="kvt_your_token_here")
Or use the environment variable:
export SAFENODE_TOKEN=kvt_your_token_here
import os
from safenode import SafeNode
client = SafeNode() # reads SAFENODE_TOKEN automatically
Email + Password
from safenode import SafeNode
client = SafeNode(
email="user@example.com",
password="your-password",
passphrase="your-vault-passphrase",
vault_id="your-vault-uuid",
)
Usage
Proxy Requests
Forward HTTP requests through a stored credential:
response = client.proxy.request(
credential="my-api-key",
method="GET",
path="/users",
query_params={"page": "1"},
)
print(response.status_code) # 200
print(response.body) # parsed JSON body
print(response.response_time_ms)
POST with body and headers:
response = client.proxy.request(
credential="my-api-key",
method="POST",
path="/messages",
body={"content": "Hello"},
headers={"X-Custom-Header": "value"},
timeout=60,
)
SSH Commands
Execute commands on remote servers:
result = client.ssh.exec(
credential="my-server",
command="df -h",
timeout=30,
)
print(result.stdout)
print(result.stderr)
print(result.exit_code)
print(result.execution_time_ms)
Database Queries
Run SQL queries through stored database credentials:
result = client.db.query(
credential="my-database",
sql="SELECT * FROM users WHERE active = %s",
params=[True],
timeout=30,
)
print(result.columns) # ["id", "name", "email"]
print(result.rows) # [[1, "Alice", "alice@example.com"], ...]
print(result.row_count) # 42
Credentials Management
List credentials:
credentials = client.credentials.list()
credentials = client.credentials.list(type="api_key", environment="production")
credentials = client.credentials.list(search="github")
Get a credential:
cred = client.credentials.get("credential-uuid")
Create a credential:
cred = client.credentials.create(
name="my-new-api",
type="api_key",
data={"api_key": "secret-value"},
environment="production",
tags=["external", "payments"],
base_url="https://api.example.com",
description="Payment provider API key",
)
Update a credential:
cred = client.credentials.update(
"credential-uuid",
description="Updated description",
tags=["external"],
)
Delete a credential:
client.credentials.delete("credential-uuid")
Error Handling
from safenode import (
SafeNode,
SafeNodeError,
AuthError,
VaultLockedError,
RateLimitError,
NotFoundError,
ProxyError,
TimeoutError,
)
import time
client = SafeNode(token="kvt_your_token")
try:
response = client.proxy.request("my-api", "GET", "/data")
except VaultLockedError:
print("Vault is locked — re-authentication required")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
time.sleep(e.retry_after)
except NotFoundError:
print("Credential not found")
except ProxyError as e:
print(f"Upstream error: {e}")
except TimeoutError as e:
print(f"Request timed out: {e}")
except AuthError as e:
print(f"Authentication failed: {e}")
except SafeNodeError as e:
print(f"SafeNode error {e.status_code}: {e}")
Context Manager
with SafeNode(token="kvt_your_token") as client:
result = client.db.query("my-db", "SELECT 1")
Environment Variables
| Variable | Description |
|---|---|
SAFENODE_TOKEN |
MCP token (kvt_xxx) for auth |
Requirements
- Python 3.9+
httpx >= 0.27
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file safenode-0.1.0.tar.gz.
File metadata
- Download URL: safenode-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aacbfe4bbe683750df4b2014f459dd0c9505972a4cff5e753b80fe1cf585ab1
|
|
| MD5 |
743c12d01719dba2ad622c076bf00e3e
|
|
| BLAKE2b-256 |
14e6540aeb2ea59b255063eaebb5366b1d9aeddf416ee6a64cbe835c683a14f4
|
File details
Details for the file safenode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: safenode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faca8774e1db304ec29f76a18c211d835432371d53816e21704b57d8688f8b1f
|
|
| MD5 |
c1af3518492ca1c9c20919e671d2c6a3
|
|
| BLAKE2b-256 |
b0c7a1f21d96192ea803f77c28c0f1564ed6e45b312000ca53a01ffffdd3e09b
|