Metadata-Version: 2.4
Name: scp-python
Version: 0.1.0b2
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: pytest>=8.0 ; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24 ; extra == 'dev'
Requires-Dist: ruff>=0.8 ; extra == 'dev'
Requires-Dist: mypy>=1.13 ; extra == 'dev'
Requires-Dist: langchain-core>=0.1.0 ; extra == 'langchain'
Requires-Dist: mcp>=1.0.0 ; extra == 'mcp'
Provides-Extra: dev
Provides-Extra: langchain
Provides-Extra: mcp
Summary: SCP (Shared Context Protocol) Python SDK — cryptographic identity, governed contexts, and trust for AI agents
Keywords: scp,protocol,agents,identity,did,ucan,mls,context
License: MIT OR Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://scp.dev/docs
Project-URL: Repository, https://github.com/limn-scp/scp-protocol-core

# 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

```bash
pip install scp-python
```

## Quick Start

```python
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:

```bash
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.

```bash
mypy your_code.py  # type stubs resolve automatically
```

## Examples

See [`examples/`](./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:

```python
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`

