MolTrust trust verification middleware for CrewAI
Project description
moltrust-crewai
Add trust verification to CrewAI in one line.
moltrust-crewai checks the calling agent's MolTrust trust score before
every tool call in a CrewAI crew. Agents
below your minimum score are blocked (or warned/logged). It hooks into CrewAI's
native hook system — no changes to your agents or tasks.
Install
pip install moltrust-crewai
Usage (one line)
from moltrust_crewai import MolTrustGuardrail
# register the guardrail globally, then run your crew as usual
MolTrustGuardrail(min_score=60).install()
from crewai import Crew
crew = Crew(agents=[...], tasks=[...])
crew.kickoff()
That's it — the guardrail fires automatically on every tool call via
crewai.hooks. No API key required to get started (see tiers below).
Usage Tiers
Tier 1 — No account required
pip install moltrust-crewai
guard = MolTrustGuardrail(min_score=60)
guard.install()
# Reads trust scores without an API key. Rate-limited.
Tier 2 — Free account
guard = MolTrustGuardrail(min_score=60, api_key="mt_...")
# Higher rate limits + interaction feedback (score improvement over time)
The API key (arg or MOLTRUST_API_KEY env) is sent as the X-API-Key header
only when present.
Note on the API: CrewAI 1.x wires middleware through its hook system (
crewai.hooks), not aCrew(callbacks=[...])argument.install()registers thebefore_tool_call/before_llm_callhooks for you. Callguard.uninstall()(or use it as a context manager) to remove them.
Options
MolTrustGuardrail(
min_score=60, # min trust score, 0-100 scale (see below)
action="block", # "block" | "warn" | "log" | "raise"
agent_did_map={ # map a CrewAI agent role → its MolTrust DID
"Researcher": "did:moltrust:0123456789abcdef",
},
did_key="did", # or read the DID from tool_input["did"]
pass_without_did=True, # allow calls with no resolvable DID
)
What it does
Before every tool call, MolTrustGuardrail resolves the calling agent's
MolTrust DID (via agent_did_map or a did in the tool input) and reads its
trust score from GET /skill/trust-score/{did}. min_score is on the
MolTrust trust score scale (0–100, behavioral trust) — not the 0–5
reputation/rating scale. The CrewAI hook contract is simple: the hook returns
False to block the tool call, or None/True to allow it.
Trust scores are recomputable — you never have to take MolTrust's word for a number. Verify the on-chain solvency component of any agent independently:
https://api.moltrust.ch/credits/solvency/{did}
Difference from Microsoft AGT
Microsoft's Agent Governance Toolkit enforces policies — what an agent may do (scope, sandboxing, zero-trust identity). MolTrust verifies behavioral trust — is this agent trustworthy, based on verifiable history. They are complementary, not competing: use AGT to bound authority, use MolTrust to decide who has earned it.
Honest limitations (0.1.0)
- CrewAI agents have no MolTrust DID by default — you map them explicitly via
agent_did_map, or carry adidin the tool input. There is no magic auto-binding yet. min_scoreis on the 0–100 MolTrust trust score (trust_scorefrom/skill/trust-score/{did}), the phase-2 behavioral score — not the 0–5 reputation/rating average.- A withheld score (registered agent with too few endorsements → API
returns
trust_score: null, withheld: true) is treated like an unregistered agent: fail-closed inblock, fail-open inwarn/log. - On a registry/transport error the guardrail fails open (allows the call, logs a warning) so a MolTrust hiccup never breaks your crew.
before_llm_callis a no-op placeholder (a hook point for injecting trust context into prompts); extend it as needed.
License
MIT © CryptoKRI GmbH — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moltrust_crewai-0.1.2.tar.gz.
File metadata
- Download URL: moltrust_crewai-0.1.2.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9309c86e7e9b80dfb6896ca9efc8a682ac428a19ed957baf9de9a45d80f90598
|
|
| MD5 |
5173228a509cdd0b9b0b7bc3a8d9d6e0
|
|
| BLAKE2b-256 |
d5fb2a5d08c9f0b50f9fb757b9c21b2df04907420a65fe570bfb378d3212816e
|
File details
Details for the file moltrust_crewai-0.1.2-py3-none-any.whl.
File metadata
- Download URL: moltrust_crewai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c917b5a77d288597c51df6ba568c9c1a99fb74882058b22a2492776978ddf5b5
|
|
| MD5 |
b895edd392da5b5445c7cb994ecf9a0c
|
|
| BLAKE2b-256 |
1422fedc0894bcaa1471ea5d6a6eea54c7455d7c174197199b7092d87c5e95a5
|