Skip to main content

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.

pip install tool-call-contracts-py
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

Metadata

Release files for tool-call-contracts-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tool-call-contracts-py 0.1.0
File Size Uploaded Provenance Actions
tool_call_contracts_py-0.1.0.tar.gz 3.6 kB Without provenance Details for tool_call_contracts_py-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tool-call-contracts-py 0.1.0
File Interpreter ABI Platform Actions
tool_call_contracts_py-0.1.0-py3-none-any.whl Python 3 none any Details for tool_call_contracts_py-0.1.0-py3-none-any.whl

Total release size: 7.5 kB

Release files / tool_call_contracts_py-0.1.0.tar.gz

Download URL tool_call_contracts_py-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bae2e9b0d28abcc38f052c8a68b5a72f78b2a6837095dbbd87620a87281cf5e9
BLAKE2b-256 checksum
How to use checksums
0c34bbc5c794a7dbeb0bf79dc72ed608c4e8ac5a88cb291acba9b139a7d53632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / tool_call_contracts_py-0.1.0-py3-none-any.whl

Download URL tool_call_contracts_py-0.1.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43b8eec4de260ff09ade3bb770a7a9d457755d1dfd28e81ee49ccf340ac1629a
BLAKE2b-256 checksum
How to use checksums
74ab7de9c086ca25fb54fdf6d082ade9eb08b94765b4c6961bc2a256309fce32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for tool-call-contracts-py 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page