Metadata-Version: 2.4
Name: medigami
Version: 0.1.0
Summary: Python SDK for the Medigami MCP — outcome-labeled healthcare claim intelligence as simple method calls, with Ed25519-attested responses.
Author: Medigami
License: Apache-2.0
Project-URL: Homepage, https://medigami.com/attested-grounding
Project-URL: Documentation, https://medigami.com/specs/attested-response-v1
Project-URL: Source, https://github.com/maximusrufus/HealthShield/tree/main/packages/medigami-sdk-python
Project-URL: Open Spec, https://medigami.com/specs/attested-response-v1
Keywords: mcp,medigami,medical-billing,insurance-appeal,healthcare,attestation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
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: Topic :: Office/Business :: Financial
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Provides-Extra: verify
Requires-Dist: cryptography>=42; extra == "verify"

# medigami — Python SDK

Call the Medigami MCP as plain Python methods. Every response is
wrapped in an `AttestedResponse` with easy access to the attestation
envelope + verifier.

```
pip install medigami
```

## Quick start

```python
from medigami import Medigami

# Public SKU — free, no auth, PHI-free
m = Medigami()
r = m.scan_bill_for_errors(bill_text=open("bill.txt").read())
print(r.payload["total_recovery_estimate"])
print(r.citation_url)  # → https://medigami.com/v/evt_abc123

# Intel SKU — Bearer-auth, per-call billed
m = Medigami(token="mk_intel_...")
r = m.score_denial_appeal_dynamics(
    insurer="Aetna",
    denial_reason="medical_necessity",
    cpt_code="99213",
    amount=1200.00,
)
print(r.payload["probability_appeal_wins"])
print(r.tracking_id)
```

## Verifying a signed response offline

```
pip install "medigami[verify]"
```

```python
# Fetch the pinned Medigami public key out-of-band, e.g. from
# https://medigami.com/.well-known/mcp-pubkey.pem
with open("mcp-pubkey.pem") as f:
    pem = f.read()

r = m.estimate_appeal_success(
    insurer="UnitedHealthcare", denial_reason="prior_auth",
    cpt_code="72148", state="CA", amount=2100.00,
)
verdict = r.verify(pem)
assert verdict["valid"], verdict["reason"]
```

## What's in the SDK

Every MCP tool on the Medigami server has a mirror Python method:

### Tier 1 atomic
- `scan_bill_for_errors`

### Tier 3 moat (some IP-gated server-side)
- `estimate_appeal_success`
- `benchmark_payer_rate`

### Tier 4 composites
- `resolve_denial`
- `negotiate_bill_script`
- `maximize_recovery`

### Intel SKU (Bearer-auth required)
- `prevent_denial_before_submit`
- `score_denial_appeal_dynamics`
- `preflight_claim`

### Commodity lookups (all attested)
- `lookup_icd10`, `lookup_cpt`, `lookup_npi`
- `verify_dea_authorization`, `lookup_provider_taxonomy`

### Citation helper
- `format_citation(envelope)` — returns the citation-string,
  citation-URL, and how-to-verify copy an LLM can paste into its
  response so end-users can independently verify.

## Attestation

Medigami signs every Tier-3+ response with Ed25519 per the spec at
<https://medigami.com/specs/attested-response-v1>. The
`AttestedResponse` wrapper exposes:

- `.payload` — original tool result
- `.envelope` — full signed envelope, or `None` for un-attested tools
- `.tracking_id` — short opaque token for closing the outcome loop
- `.citation_url` — a public URL your users can open to verify
- `.verify(pubkey_pem)` — local offline verification

## Configuration

```python
Medigami(
    token=None,                           # Intel-SKU bearer
    base_url="https://api.medigami.com",  # override for dev/staging
    timeout_seconds=30.0,
)
```

Or via env vars:

- `MEDIGAMI_API_BASE` — default API base URL
- `MEDIGAMI_CITATION_BASE` — default citation URL base (medigami.com)

## License

Apache-2.0.
