5-minute quick start
1.Install
pip install venzx mcp2.Set your key
Create a VENZX key in your dashboard.
export VENZX_API_KEY="pai-..."3.Save server.py
Save this as server.py. """MCP + VENZX: an MCP server that checks every tool call before running it. An MCP server cannot see or trust the agent that calls it, so the check belongs in the server. ``FastMCP.call_tool`` is the one method every tool call passes through; this subclass asks VENZX there, before the tool runs: allow -> the tool runs block -> the tool does not run; the client gets an error result needs_review -> the tool does not run; the error says it is held for a person (or, with APPROVAL_WAIT_SECONDS set, wait for them and then run) That one place covers every tool on the server, including ones added later. Tested with mcp 1.30.0. Run it (stdio, the transport Claude Desktop and most clients use): pip install venzx mcp export VENZX_API_KEY="pai-..." python server.py """ from __future__ import annotations import os from typing import Any import anyio from mcp.server.fastmcp import FastMCP from mcp.server.fastmcp.exceptions import ToolError from venzx import ApprovalRequired, Blocked, Guard, Policy, Venzx # What a client of this server may do. Sent with every check, so it applies # even if the account's own policy is empty. POLICY = ( Policy() .allow_tools("lookup_order", "refund") # anything else is blocked .require_approval("refund") # a person must say yes ) # Stand-in for your systems, so you can see what actually ran. ACTIONS: list = [] # ── the VENZX check (identical in every framework example) ─────────────── # Seconds to wait for a person when an action is held. 0 (the default) does # not wait: the model is told the action is held and carries on. APPROVAL_WAIT_SECONDS = float(os.environ.get("APPROVAL_WAIT_SECONDS", "0")) def venzx_refusal(guard: Guard, name: str, args: dict, wait_seconds: float = APPROVAL_WAIT_SECONDS) -> str | None: """Ask VENZX about one tool call, before it runs. Returns None if the tool may run. Otherwise returns the sentence to give the model in place of the tool's result. Never raises: anything that goes wrong is a refusal, so a tool cannot run unchecked.""" try: guard.tool_call(name, args) return None # allowed except ApprovalRequired as e: approval_id = e.result.approval_id # held for a person except Blocked as e: return f"BLOCKED: {e.result.reason}. It has NOT run." except Exception as e: # noqa: BLE001 return f"BLOCKED: the action could not be checked ({e}). It has NOT run." status = "pending" if wait_seconds > 0: try: status = guard.client.wait_for_approval( approval_id, timeout=wait_seconds).get("status", "pending") # Reading "approved" is not permission. Claiming it is, and the # claim names this exact call, so it cannot be spent on another. guard.client.consume_approval( approval_id, action={"name": name, "args": dict(args)}) return None # a person said yes except Exception: # noqa: BLE001 pass # rejected, expired or still pending if status == "rejected": return f"REJECTED: a person declined '{name}'. It has NOT run." return (f"HELD: '{name}' needs a person to approve it " f"(approval id {approval_id}). It has NOT run.") # ── end of the VENZX check ─────────────────────────────────────────────── class GuardedMCP(FastMCP): """A FastMCP server whose tool calls are checked by VENZX first.""" def __init__(self, *args: Any, guard: Guard, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self._venzx = guard async def call_tool(self, name: str, arguments: dict[str, Any]): # The venzx client is synchronous; keep it off the event loop. refusal = await anyio.to_thread.run_sync(venzx_refusal, self._venzx, name, arguments) if refusal is not None: raise ToolError(refusal) # the client gets an error result return await super().call_tool(name, arguments) def build_server(guard: Guard | None = None) -> FastMCP: mcp = GuardedMCP("orders", guard=guard or Guard(Venzx(), policy=POLICY)) @mcp.tool() def lookup_order(order_id: str) -> str: """Look up the status of an order.""" ACTIONS.append(("lookup_order", order_id)) return f"Order {order_id}: delivered, total $40.00" @mcp.tool() def refund(order_id: str, amount: float) -> str: """Refund an order.""" ACTIONS.append(("refund", order_id, amount)) return f"Refunded ${amount:.2f} on order {order_id}" @mcp.tool() def delete_customer(customer_id: str) -> str: """Delete a customer and all their data.""" ACTIONS.append(("delete_customer", customer_id)) return f"Deleted customer {customer_id}" return mcp if __name__ == "__main__": build_server().run() # stdio by default4.Save try_it.py
This small client is step 4 of the quick start. It uses the MCP SDK’s own stdio client, so it exercises the server exactly as a real client would.
Save this as try_it.py, next to server.py. """Call the example server the way an MCP client does, and print what VENZX let through. This launches server.py over stdio (exactly what Claude Desktop or any other MCP client does), lists its tools, and calls all three. Run it (from this folder, next to server.py): export VENZX_API_KEY="pai-..." python try_it.py """ from __future__ import annotations import os import pathlib import sys import anyio from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client SERVER = pathlib.Path(__file__).with_name("server.py") CALLS = [ ("lookup_order", {"order_id": "A-1001"}), ("refund", {"order_id": "A-1001", "amount": 40.0}), ("delete_customer", {"customer_id": "C-77"}), ] async def run() -> list: """[(tool, is_error, text)] for each call.""" server = StdioServerParameters(command=sys.executable, args=[str(SERVER)], env=dict(os.environ)) results = [] async with stdio_client(server) as (read, write): async with ClientSession(read, write) as session: await session.initialize() tools = await session.list_tools() print("tools:", ", ".join(t.name for t in tools.tools)) for name, args in CALLS: r = await session.call_tool(name, args) text = " ".join(c.text for c in r.content if getattr(c, "text", None)) results.append((name, bool(r.isError), text)) print(f"{name:16} {'REFUSED' if r.isError else 'ran '} {text}") return results if __name__ == "__main__": anyio.run(run)5.Run it
python try_it.pyThe example is a support agent with three tools. Its policy lets lookup_order run, holds refund for a person, and has no entry for delete_customer.
try_it.py launches server.py over stdio, the way a desktop client does, lists its tools and calls all three. You should see one call run and two refused:
tools: lookup_order, refund, delete_customer lookup_order ran Order A-1001: delivered, total $40.00 refund REFUSED HELD: 'refund' needs a person to approve it (approval id apr_...). It has NOT run. delete_customer REFUSED BLOCKED: Tool 'delete_customer' is not on the allowlist. It has NOT run.6.Approve the refund
Open the approval email and press Approve. By default the example does not wait for you: it tells the model the refund is held and moves on. To have the tool call wait for your decision and then run, set a wait before you start it:
APPROVAL_WAIT_SECONDS=600 python try_it.py
How it plugs in
The integration point is FastMCP.call_tool, which MCP provides for exactly this.
Every tool call a FastMCP server receives goes through its call_tool method. The example subclasses FastMCP and overrides that one method: it asks VENZX about the tool name and arguments, and only then hands over to the original.
Because the check is on the server and not on each tool, a tool added later is covered without anyone remembering to wrap it.
When a call is refused. The method raises ToolError, which FastMCP turns into a tool result with isError set and the reason as its text. The client’s model reads that as the outcome of the call.
The check itself
venzx_refusal in the file above is the same in every framework example. It returns nothing when the tool may run, and otherwise the sentence to give the model:
- Allowed: the tool runs.
- Blocked: the tool does not run, and the model is told why.
- Held for a person: the tool does not run. With
APPROVAL_WAIT_SECONDSset, it waits for the decision and then claims the approval for that exact tool and those exact arguments before running. An approval cannot be spent on a different call. - Anything goes wrong, including VENZX being unreachable: the tool does not run.
The policy at the top of the file travels with every check. Change it there, or delete it to use the policy saved on your account. See Policy and the human-approval gate.
Connect a real client
Any MCP client that launches a stdio server can use it. For Claude Desktop, add the server to claude_desktop_config.json with the full path to server.py and your key:
{
"mcpServers": {
"orders": {
"command": "python",
"args": ["/full/path/to/server.py"],
"env": { "VENZX_API_KEY": "pai-..." }
}
}
}Use the Python that has venzx and mcp installed (the full path to it, if it is in a virtual environment).
What this does not cover
- Only tool calls are checked. Resources and prompts the server exposes are not.
- Most MCP clients give up on a tool call after a short wait. Leave APPROVAL_WAIT_SECONDS at 0 unless you know your client waits that long: the call is refused as held, the person approves by email, and the client asks again.
- This covers a server you run. It does nothing about other MCP servers the same client is connected to.
VENZX answers before your tool runs and never sees it execute. The general limits are in What VENZX does NOT do.
Other frameworks
LangGraph · CrewAI · OpenAI Agents SDK · SDK docs
The example, its pinned requirements.txt and its test are in examples/mcp/ of the SDK repository.