agent-framework-botsrated
Install in 3 steps
- Install the published package:
pip install agent-framework-botsrated(PyPI 0.1.2). That release is the middleware and the check tool. It does not includeattach_payment_guard. - Name the payment tools. Installing does not attach an x402 guard:
from agent_framework_botsrated import BotsRatedPaymentMiddleware
middleware = [BotsRatedPaymentMiddleware(["pay_x402"])]
- With no preset, an unobserved payTo is blocked, and so is an invalid payTo. PyPI 0.1.2 has no
fail_modeargument.attach_payment_guardis not in that release.
attach_payment_guard in this checkout is not on PyPI (prepared as 0.1.3). From a checkout, in a clean virtualenv: pip install -e integrations/microsoft-agent-framework (needs botsrated>=0.3.0,<0.4). Installing that checkout does not attach a guard either:
from agent_framework_botsrated import attach_payment_guard
guard = attach_payment_guard(x402_client)
Omit preset for advice only (carefulBuyer / strict stop an unobserved payTo when you pass them). Omit fail_mode to stay open. "closed" stops the payment when BotsRated or your policy cannot answer. A missing decision is never a pass. A remote pass never clears a local block.
BOTSRATED_TOKEN is optional. Omit token and the guard reads BOTSRATED_TOKEN. On botsrated 0.3.0 and later it is sent only as remote_policy={"token", "fail_mode"}, never as a bare string. A configured token on a core without parse_remote_policy raises and is not dropped. The policy decision is not signed. Get a token in Desk.
Omit fail_mode and the guard stays open. "closed" stops the payment when BotsRated or your policy cannot answer. A missing decision is never a pass. A remote pass never clears a local block. Nothing defaults you to closed.
Default install
Pairs with Microsoft Agent Framework. Payment-client wrap, and the existing function middleware for an opaque payment tool. Not an agent or workflow runtime. PyPI 0.1.2 is the middleware and the check tool. The attach_payment_guard path in this checkout is not on PyPI.
from agent_framework_botsrated import attach_payment_guard
guard = attach_payment_guard(x402_client)
Omit preset for advice only (warn). carefulBuyer and strict block an unobserved payTo only when you select them. Omit fail_mode to stay open. Free preflight is https://botsrated.com only. No custody and no payment signing.
What it checks
Function middleware and a payment-client hook for Microsoft Agent Framework that check an
x402 payment with BotsRated before pay. BotsRated probes x402 sellers on
Base and records which payTo wallet each one actually quoted. The check asks BotsRated's free preflight
(no API key, no wallet) whether the payTo your agent is about to pay was observed for that seller.
Maintained by BotsRated, not by Microsoft. Issues: https://github.com/botsrated/botsrated/issues/new
Install
pip install agent-framework-botsrated
# with the hosted MCP server example:
pip install "agent-framework-botsrated[mcp]"
PyPI 0.1.2 requires Python 3.10+, agent-framework-core>=1.22,<2, and botsrated >=0.1.5,<0.2. The guard in this checkout (prepared as 0.1.3, not on PyPI) requires botsrated>=0.3.0,<0.4.
Tested with agent-framework-core 1.22.0 (with mcp 1.30) and 1.23.0 (with mcp 2.3). agent-framework-core 1.22 can't
initialize MCP sessions with mcp 2.x, so pin mcp<2 there if you use the hosted MCP server.
Middleware and token
attach_payment_guard is the hook in this checkout. Keep your Agent. When the x402 client sits inside a payment tool, pass that same guard to the existing middleware. BOTSRATED_TOKEN is optional. Omit token and the guard reads BOTSRATED_TOKEN. On botsrated 0.3.0 and later it is sent only as remote_policy={"token", "fail_mode"}, never as a bare string. A configured token on a core without parse_remote_policy raises and is not dropped. The policy decision is not signed. Get a token in Desk.
import os
from agent_framework import Agent
from agent_framework_botsrated import BotsRatedPaymentMiddleware, attach_payment_guard
guard = attach_payment_guard(
x402_client,
preset="carefulBuyer",
fail_mode="open",
token=os.getenv("BOTSRATED_TOKEN"),
)
agent = Agent(
client=chat_client,
tools=[paid_tool],
middleware=[BotsRatedPaymentMiddleware(["paid_tool"], guard=guard)],
)
BotsRatedPaymentMiddleware(["paid_tool"], preset="carefulBuyer", fail_mode="open", token=...) builds that same guard when you do not already have one. It does not register x402 hooks. Only the named payment tools are checked. On a block, on_block="raise" raises BotsRatedPaymentBlocked. The default returns the blocked reason and does not run the tool. botsrated_check_payment_tool() is the free preflight and does not attach a guard.
BotsRatedPaymentMiddleware(["paid_tool"]) with no guard, preset, fail_mode, or token keeps the existing free-preflight guard: an unobserved payTo is blocked, and an invalid payTo is blocked. Setting fail_mode or token without a preset keeps both of those blocks (pay_to_mismatch="block" and pay_to_invalid="block"). It does not switch the default to advice-only, and it does not change fail_mode (omit it to stay open). preset="warn" is advice only when selected.
Middleware: check payments before they run
from agent_framework import Agent
from agent_framework_botsrated import BotsRatedPaymentMiddleware
def pay_x402(url: str, pay_to: str, amount: str, network: str = "eip155:8453") -> str:
"""Pay an x402 seller."""
... # your payment code
agent = Agent(
client=chat_client,
tools=[pay_x402],
middleware=[BotsRatedPaymentMiddleware(["pay_x402"])],
)
- Only the functions you name are checked. Every other function call passes through untouched.
- The quote is read from the call's arguments:
url,pay_to(orpayTo),amount(atomic units) and optionalnetwork(CAIP-2, defaulteip155:8453). For other argument names pass an extractor:BotsRatedPaymentMiddleware({"buy": lambda a: PaymentQuote(url=a["endpoint"], pay_to=a["recipient"], amount=str(a["atomic"]))}). - A blocked call never reaches
call_next. The reason (with a link to the BotsRated probe receipt) becomes the call's result, so the model reads it. Withon_block="raise"the run ends withBotsRatedPaymentBlocked(aMiddlewareFailure). - The
botsrated.Decisionis stored incontext.metadata["botsrated_decision"];guard.on_decisionis also called.
Default policy (from botsrated.GuardPolicy, configurable through guard=PrePaymentGuard(policy=...)):
| Situation | Result |
|---|---|
payTo never observed by BotsRated for that host (same network) |
blocked (payto_not_observed; payto_mismatch with botsrated 0.1.x). The default guard passes GuardPolicy(pay_to_mismatch="block"), so this holds with botsrated 0.2, whose own default is advice-only |
payTo is not a 20-byte hex address |
blocked. The historical guard uses pay_to_mismatch. A PaymentGuard built with fail_mode or token and no preset sets pay_to_invalid="block" as well |
| Quote can't be read from the arguments | blocked (quote_unreadable) |
| Price above the last observed price on the same route | allowed with a warning |
| Host not covered, or data older than 24 h | allowed (info) |
| BotsRated unreachable | allowed (fail_open=True); set PrePaymentGuard(fail_open=False) to block |
The middleware checks what the payment tool was asked to pay. If your tool fetches the 402 itself and signs it, wrap
that client with attach_payment_guard so the check runs on the quote being signed. Call guard.request(url) or
guard.wrap_get(...) around the paying request so the guard sees the host actually being paid, rather than only the
seller-supplied 402 resource.url.
Tool: let the model check a payment option
from agent_framework_botsrated import botsrated_check_payment_tool
agent = Agent(client=chat_client, tools=[botsrated_check_payment_tool(), pay_x402])
botsrated_check_payment(url, pay_to, amount, network) returns JSON with action (allow/block), reasons and
receipt_url. It uses the free preflight only. It does not attach a guard.
Hosted MCP server (no package needed)
BotsRated also runs a remote MCP server (streamable HTTP, no auth). Its free tools are preflight, coverage,
sample and history:
from agent_framework import MCPStreamableHTTPTool
botsrated_mcp = MCPStreamableHTTPTool(
name="botsrated",
url="https://botsrated.com/mcp",
allowed_tools=["preflight", "coverage", "sample", "history"],
)
async with botsrated_mcp:
result = await Agent(client=chat_client, tools=[botsrated_mcp]).run("Is blockrun.ai a known x402 seller?")
The paid lookups (check $0.001, report $0.002, best $0.01 USDC on Base; the first 25 checks and 3 reports per
client IP per UTC day are free) are not used by this package unless you pass a paid-enabled BotsRatedClient to the guard.
Run the example and tests
pip install -e ".[mcp]" pytest pytest-asyncio respx
python examples/quickstart.py # scripted model, real free preflight, stub payment
pytest -m "not live" # offline; no network and no provider call
pytest -m live # real free BotsRated preflight + hosted MCP server; nothing is paid
examples/quickstart.py uses a scripted chat client instead of a model, so it runs without an API key. One payment
call uses an unknown payTo and is blocked; the other uses the payTo BotsRated observed for blockrun.ai and runs.
BotsRated results are measurements, not endorsements. MIT licensed.
Metadata
Release files for agent-framework-botsrated 0.1.3
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 |
|---|---|---|---|---|
| agent_framework_botsrated-0.1.3.tar.gz | 21.6 kB | With provenance | Details for agent_framework_botsrated-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_framework_botsrated-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for agent_framework_botsrated-0.1.3-py3-none-any.whl |
Total release size: 35.0 kB
Release files / agent_framework_botsrated-0.1.3.tar.gz
| Download URL | agent_framework_botsrated-0.1.3.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7447e33ed2691bb20debf8e669ea17712f6ee39bc227c8c3319a72e2e032de15
|
|
BLAKE2b-256 checksum How to use checksums |
a306ec161868837982752512817141acee9638a30eacf615a31f78a5f230c4d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / agent_framework_botsrated-0.1.3-py3-none-any.whl
| Download URL | agent_framework_botsrated-0.1.3-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fb1544b68c51a46d82e7ab3ee482557052dac2b9cb1487ba30feaf0b14d72be
|
|
BLAKE2b-256 checksum How to use checksums |
fc414063a98168d82e075cfdc75e95e5a208e417c1bfe02858fc4aeac2046bc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for agent-framework-botsrated 0.1.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agent_framework_botsrated-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA 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.