SCP (Shared Context Protocol) Python SDK — cryptographic identity, governed contexts, and trust for AI agents
Project description
SCP Python SDK
scp-python-- Shared Context Protocol for Python
Cryptographic identity, encrypted contexts, capability-based auth, and tool invocation for AI agents. Built on Rust via PyO3.
Install
pip install scp-python
Quick Start
import asyncio
from scp_sdk import Identity, Context
async def main():
# Create a cryptographic identity (DID)
identity = await Identity.create(custody="platform")
print(f"DID: {identity.did}")
# Create an encrypted context
ctx = await Context.create(
identity=identity,
params={"ceiling": ["msg:send", "msg:receive"], "ttl": 3600},
)
# Send a message (MLS-encrypted, signed, provenance-tagged)
await ctx.send(b"Hello from SCP")
# Receive messages
async for msg in ctx.receive():
print(f"{msg.sender_did}: {msg.content}")
break
await ctx.close()
asyncio.run(main())
Requirements
- Python >= 3.12
- Rust toolchain (build only -- wheels are pre-built for Linux, macOS, Windows)
API Reference
Generated from source via pydoc. Build locally:
cd bindings/python
python -m pydoc scp_sdk
Published API docs are generated on every release by CI.
Type Checking
PEP 561 compliant. The package ships py.typed marker and _scp_core.pyi stubs for full IDE autocompletion and mypy/pyright support.
mypy your_code.py # type stubs resolve automatically
Examples
See examples/ for runnable scripts:
| File | Description |
|---|---|
basic_messaging.py |
Create identity, context, send/receive messages |
tool_invocation.py |
Register and invoke a tool with test vectors |
mcp_integration.py |
Expose SCP tools via MCP JSON-RPC server |
multi_agent.py |
Coordinate multiple agents in a shared context |
Error Handling
All errors inherit from ScpError with a machine-readable code field:
from scp_sdk import ScpError, ContextError
try:
await ctx.send(b"data")
except ContextError as e:
print(f"[{e.code}] {e}")
Source
- Scaffold:
.docs/scaffold/python.md - Standards:
.docs/standards/python.md - API sketch:
.docs/sketch.md
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 Distributions
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 scp_python-0.1.0b2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: scp_python-0.1.0b2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 20.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f53e951c498116619453de61718736445d771ddb6cbd1ea5b710dbb2c1f4d62
|
|
| MD5 |
26412d5138e8b3ceff8e9a79c6ba25ac
|
|
| BLAKE2b-256 |
37a4476dec549aaadeb91540603f8e82cb0bce060eb86eddc5454aabaa41b5ce
|