Metadata-Version: 2.4
Name: bitcoin-stratigraphy-enterprise
Version: 0.2.0
Summary: The official L402 / NIP-98 transport adapter for the Bitcoin Stratigraphy Autonomous Data Engine.
License-Expression: AGPL-3.0-only OR LicenseRef-Commercial
Project-URL: Homepage, https://bitcoinstratigraphy.com
Project-URL: Documentation, https://bitcoinstratigraphy.com/docs
Project-URL: Repository, https://github.com/CharlesStrogish/bitcoin-stratigraphy-mcp
Project-URL: Source, https://github.com/CharlesStrogish/bitcoin-stratigraphy-mcp/tree/main/sdk/python
Keywords: mcp,crewai,langchain,l402,lightning-network,nip98,ai-agents,multi-party-compute
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: rfc8785<0.2,>=0.1.4
Requires-Dist: cryptography<51,>=50.0.2
Requires-Dist: opentimestamps==0.4.5
Requires-Dist: opentimestamps-client<0.8,>=0.7.2
Dynamic: license-file

# Bitcoin Stratigraphy: MCP Client SDK

## Verified, digest-only notarization in five lines

The existing `bitcoin-stratigraphy-enterprise` distribution includes this client;
this strike does not create or publish another Python runtime/package. Install
its declared `cryptography` and `rfc8785` dependencies. With your existing
`pay_invoice`, durable `persist_preimage`, and independently trusted issuer SPKI
PEM `issuer_pin`:

```py
from bitcoin_stratigraphy_enterprise import BitcoinStratigraphyClient
client = BitcoinStratigraphyClient(pay_invoice=pay_invoice, persist_preimage=persist_preimage, expected_issuer_public_key=issuer_pin)
client.verify_handshake()
receipt = client.notarize({"event": "agent-checkpoint"}, label="local-only")
print(receipt["payloadSha256"])
```

Legacy `sdk.python.client` imports retain canonical module identity. Existing
positional constructor arguments and one-argument `wallet(invoice)` callbacks
remain supported. New keyword-only options include `enforce_handshake=True`,
`min_yield_bps`, `expected_issuer_public_key`, `expected_manifest_sha256`,
`expected_tool_schema_hashes`, `l402_token`, and `pay_invoice(invoice, next_action)`.
Only the explicit legacy opt-out `enforce_handshake=False` disables verification;
there is no silent fallback when discovery fails. Crypto imports remain lazy
so opting out does not require loading cryptographic dependencies.

**Exact trust coverage:** signatures authenticate tool **description SHA-256
bytes only**, and the **full covenant** through detached JCS/EdDSA. The yield
floor cannot be relaxed below **2100 bps**. They do not authenticate manifest
names, timestamps or input schemas. Optional `expected_manifest_sha256` pins raw
HTTP bytes (including whitespace/startup timestamp); optional
`expected_tool_schema_hashes` pins JCS(inputSchema) hashes from live unpaid
`tools/list`. These checks fail closed with `IntegrityViolationError`; covenant
failures raise `CovenantViolationError`. Results explicitly report
`signatureCoverage="description_sha256_bytes_only"`, `wholeManifestPinned`,
`inputSchemasPinned`, and `independentlyPinnedIssuer`. Fetching JWKS alone is
not independent issuer pinning. A boot check does not prevent later redeployment.

`notarize` sends only a locally computed canonical UTF-8 SHA-256 `{hash}`; raw
payload and label never leave the process. Guessable payload hashes are not
guaranteed anonymous. OTS calendar acceptance is not Bitcoin confirmation.
The existing `proof.notarize` tool creates the receipt; the SDK fabricates no proof.
`persist_preimage` (alias `on_preimage`) is invoked after verifying the challenged
payment hash and **before one authorized retry**. A failed hook blocks retry;
wallet uncertainty or retry rejection does not trigger another payment for the
same invoice within this client's lifetime. A preconfigured token's rejection
never silently enables wallet payment. Without a durable hook, proof retention
is in-memory only; the caller owns recovery after process loss. Never log proofs.

## Existing MCP usage and examples

**The Central Bank for the Autonomous AI Machine Economy.**

Bitcoin Stratigraphy is a production-ready, zero-latency data engine designed
exclusively for autonomous AI swarms. This official Python SDK provides a
frictionless, plug-and-play **L402 / NIP-98 Transport Adapter**, allowing
multi-agent orchestration frameworks (CrewAI, LangChain) to natively interact with
the Stratigraphy vault.

## The Mathematical Advantage (Why Orchestrators Route Through Us)

You are building autonomous agents. Do not waste engineering cycles building
cryptographic data pipelines.

By routing your AI swarms through the Bitcoin Stratigraphy infrastructure, you
instantly upgrade your fleet with:

1. **Zero-Trust Security:** NIP-98 Schnorr signature authentication and SHA-256
   Hashcash DDoS shielding natively handled by this SDK.
2. **Enterprise Compliance:** Compliant with EU AI Act Article 12 (Multi-Party
   Compute & Split-Key architecture).
3. **The 21% Algorithmic Yield:** Syndicate Orchestrators who route their users
   through our VIP Lightning tabs earn a programmatic 21% yield on all L402
   micro-transactions. We pay you to use our infrastructure.

## ⚡ Frictionless Swarm Integration

We have completely abstracted the cryptographic friction. Connect your agents in
4 lines of code.

### Installation

```bash
pip install "bitcoin-stratigraphy-mcp-client[crewai,langchain]" langchain
```

The transport package is defined in `sdk/python/mcp-client/pyproject.toml`.
To install directly from this repository instead, run from the repository root:

```bash
pip install "./sdk/python/mcp-client[crewai,langchain]" langchain
```

Supply `private_key` from your secret manager and an async `wallet_handler` that
approves and pays an L402 invoice and returns its payment preimage as a hex string.
Configure your framework's model provider separately.

### CrewAI Integration (Multi-Agent Fleets)

Provide your agent's `role`, `goal`, `story` (backstory), and configured `llm`.

```python
from crewai import Agent
from bitcoin_stratigraphy_mcp_client.crewai import CrewAISwarmTools
# The SDK automatically negotiates the L402 Lightning Macaroon and NIP-98 Headers
with CrewAISwarmTools(private_key, wallet_handler) as tools:
    agent = Agent(role=role, goal=goal, backstory=story, tools=tools, llm=llm)
```

Keep `Crew(...).kickoff()` or `await Crew(...).kickoff_async()` inside the
`with` block so the MCP session remains open while agents execute their tools.

### LangChain Integration

Use a configured LangChain `model`. `L402` is a short local alias for the exported
`L402Nip98Transport` class, not a separate transport.

```python
from bitcoin_stratigraphy_mcp_client import L402Nip98Transport as L402
from langchain.agents import create_agent
# Discover the enabled MCP catalog (19-tool capacity; clearing is host-enabled)
async with L402(private_key, wallet_handler).langchain_tools() as tools:
    agent = create_agent(model, tools=tools)
```

Run `await agent.ainvoke(...)` inside the `async with` block to keep the transport
and MCP session open for tool execution.

## Enterprise Commercial Exemptions

The core engine is licensed strictly under **AGPLv3**. Fortune 500 risk teams and
Proprietary swarms that cannot meet AGPLv3 Section 13 obligations can buy a self-serve AGPLv3 Commercial Copyright Waiver at
https://bitcoinstratigraphy.com/#enterprise-licensing (swarm_monthly $2,500/30 days,
swarm_annual $25,000/365 days, global_monthly $25,000/30 days, global_annual
$250,000/365 days, quoted in BTC at spot).

All prepaid MCP Macro-Macaroons, Scanner Packs, and AGPLv3 Commercial Copyright Waivers are 100% self-serve and provided STRICTLY AS-IS, WITH ALL FAULTS. Zero SLAs, zero uptime warranties, zero indemnity, zero custom MSAs, zero vendor questionnaires, and zero support obligations. Full source code is publicly inspectable under AGPLv3 for independent self-hosting. Payment for a Commercial Copyright Waiver strictly grants a time-locked, non-negotiable waiver from AGPLv3 Section 13 network source-disclosure requirements for the specified term, anchored cryptographically to your confirmed Bitcoin transaction.
