Metadata-Version: 2.4
Name: ai2web
Version: 0.2.1
Summary: AI2Web (ai2w) Python SDK - capability model, manifest builder, validator, negotiation, server handler.
Project-URL: Homepage, https://ai2web.dev
Project-URL: Repository, https://github.com/ai2web-foundation/ai2web-python
Author: AI2Web Foundation
License: MIT
License-File: LICENSE
Keywords: agents,ai,ai2w,ai2web,mcp,protocol
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
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: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# AI2Web Python SDK (`ai2web`)

[![CI](https://github.com/ai2web-foundation/ai2web-python/actions/workflows/ci.yml/badge.svg)](https://github.com/ai2web-foundation/ai2web-python/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/ai2web)](https://pypi.org/project/ai2web/)
[![Python versions](https://img.shields.io/pypi/pyversions/ai2web)](https://pypi.org/project/ai2web/)

The Python reference implementation of the [AI2Web protocol](https://github.com/ai2web-foundation/ai2web-spec) - for Django, Flask, FastAPI, or plain Python. Mirrors `@ai2web/core`.

```bash
pip install ai2web
```

```python
from ai2web import ai2web, validate, handle

manifest = (
    ai2web({"name": "Example Store", "url": "https://example.com", "type": "ecommerce"})
    .capability("content")
    .capability("commerce", {"endpoint": "/ai2w/products", "checkout": True})
    .transports({"mcp": {"enabled": True, "endpoint": "/ai2w/mcp"}, "rest": {"enabled": True}})
    .auth({"methods": ["none", "oauth2"], "oauth2": {"pkce": True, "scopes": ["checkout"]}})
    .consent({"requires_user_approval_for": ["purchase"]})
    .contact({"support": "help@example.com"})
    .build()
)

result = validate(manifest)          # {'score': 90+, 'tier': 'Standard', ...}

# Serve every AI2Web route from one call (framework-agnostic):
res = handle({"manifest": manifest}, method, path, body, origin)
```

## Modules
- `ai2web.manifest` - fluent capability-model builder (`ai2web(...)`, `Manifest`).
- `ai2web.validator` - `validate()` + AI Readiness scoring (spec §9/§11).
- `ai2web.negotiator` - `negotiate()` capability negotiation (spec §5).
- `ai2web.server` - `handle()` framework-agnostic route handler.
- `ai2web.safety` - `is_safe_public_url()` / `assert_safe_public_url()` SSRF guard.

## Test
```bash
python tests/run.py     # dependency-free; includes the shared conformance contract
```

Requires **Python 3.9+**. Zero runtime dependencies.

## Licence
MIT.
