mcs-hooks
Tool-call lifecycle hooks decorator for the Model Context Standard (MCS).
HooksDecorator wraps a ToolDriver and emits observability events around
execute_tool:
pre-- before execution:handler(tool_name, arguments)post-- after success:handler(tool_name, arguments, result)on_failure-- after an exception (then re-raised):handler(tool_name, arguments, exc)
Hooks are observers (return values ignored). To gate a call (confirm/deny)
use mcs-permission; for auth challenges use mcs-auth. All three stack freely:
Hooks(Permission(Auth(RealToolDriver))).
Installation
pip install mcs-hooks
Usage
from mcs.hooks.decorator import HooksDecorator
def audit(name, args):
log.info("tool %s args=%s", name, args)
hooks = HooksDecorator(MyToolDriver(...), pre=[audit])
hooks.add_post_hook(lambda n, a, r: metrics.observe(n)) # multiple observers
orchestrator.add_driver(hooks, label="mail")
Multiple handlers per phase (observer pattern): pass lists at construction and/or
add_*_hook / remove_*_hook at runtime. Advertises the "hooks" capability;
reachable via DriverMeta.resolve_capability(driver, SupportsHooks).
License
Apache-2.0
Metadata
Release files for mcs-hooks 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcs_hooks-0.1.0.tar.gz | 8.4 kB | Without provenance | Details for mcs_hooks-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcs_hooks-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcs_hooks-0.1.0-py3-none-any.whl |
Total release size: 16.3 kB
Release files / mcs_hooks-0.1.0.tar.gz
| Download URL | mcs_hooks-0.1.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb032a42f0ca31b1f7163acef8bd9551fa88bc29fd0809855db06678d3aa379e
|
|
BLAKE2b-256 checksum How to use checksums |
654efc9574a890795a20b6c617e4283c0ad71ecab98926882d8303dfbb7d0827
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / mcs_hooks-0.1.0-py3-none-any.whl
| Download URL | mcs_hooks-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e4db134df3a2134cb5e8091e9877da30cddbc7d65f27200af3e6ae9ddc8f83f
|
|
BLAKE2b-256 checksum How to use checksums |
8555c245cf5524447cb05a3ad392c8e3751bb25d5846d6ec68502be115805e6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for mcs-hooks 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.