Metadata-Version: 2.4
Name: tool-call-contracts-py
Version: 0.1.0
Summary: Validate LLM tool-call payloads with small JSON-like contracts. Python port of @mukundakatta/tool-call-contracts.
Project-URL: Homepage, https://github.com/MukundaKatta/tool-call-contracts-py
Project-URL: Issues, https://github.com/MukundaKatta/tool-call-contracts-py/issues
Project-URL: Source, https://github.com/MukundaKatta/tool-call-contracts-py
Project-URL: JS sibling, https://www.npmjs.com/package/@mukundakatta/tool-call-contracts
Author-email: Mukunda Katta <mukunda.vjcs6@gmail.com>
License: MIT
License-File: LICENSE
Keywords: agent,llm,schema,tool-calls,validation
Classifier: Development Status :: 3 - Alpha
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# tool-call-contracts-py

Validate LLM tool-call payloads with small JSON-like contracts. Pure Python, zero deps. Python port of [`@mukundakatta/tool-call-contracts`](https://www.npmjs.com/package/@mukundakatta/tool-call-contracts).

```bash
pip install tool-call-contracts-py
```

```python
from tool_call_contracts import validate_tool_call, assert_tool_call, ContractError

contract = {
    "name": "search",
    "arguments": {
        "query": {"type": "string", "required": True},
        "limit": {"type": "int", "enum": [10, 25, 50]},
    },
}

res = validate_tool_call({"name": "search", "arguments": {"query": "python"}}, contract)
# ValidationResult(valid=True, errors=[])

assert_tool_call({"name": "fetch", "arguments": {}}, contract)
# raises ContractError: expected tool search, got fetch; query is required
```

Supported rule fields per argument: `type` (`string`/`int`/`float`/`bool`/`list`/`dict`), `required`, `enum`, `pattern` (regex for strings).

## License

MIT
