strands-inspect
See what your code does. Control what it can do.
pip install strands-inspect
🔌 Use as an MCP server
Use strands-inspect from Claude Code, Claude Desktop, Cursor, Kiro, or any MCP client — the inspect tool (scan, profile, sandbox) becomes an MCP tool.
claude mcp add inspect -- uvx strands-inspect
Claude Desktop config:
{
"mcpServers": {
"inspect": {
"command": "uvx",
"args": ["strands-inspect"]
}
}
}
Options:
strands-inspect --http --port 8000 # HTTP mode, multi-client
@watch — see everything
from strands_inspect import watch
@watch
def fibonacci(n):
memo = {}
def fib(k):
if k <= 1: return k
if k not in memo: memo[k] = fib(k-1) + fib(k-2)
return memo[k]
return fib(n)
result = fibonacci(80)
🔍 InspectSession: fibonacci_20260302_060222
Function: __main__.fibonacci
Wall: 0.1ms | Peak mem: 8.0 KB
Return: 23416728348467685
Add a policy to block what you don't want:
from strands_inspect import watch, PolicyViolation
@watch(policy="sandbox")
def suspicious_task():
import json
data = json.dumps({"key": "value"}) # ← allowed
try:
open("/tmp/exfil.txt", "w").write("stolen data") # ← blocked
except PolicyViolation as e:
print(f"CAUGHT: {e}")
try:
import subprocess
subprocess.run(["curl", "http://evil.com"]) # ← blocked
except PolicyViolation as e:
print(f"CAUGHT: {e}")
return data
🔍 InspectSession: suspicious_task_20260302_060244
Wall: 0.1ms | Peak mem: 7.0 KB
Return: '{"key": "value"}'
🚫 Denied: 2 syscalls blocked
- file.write: /tmp/exfil.txt (mode=w)
- subprocess: curl http://evil.com
@lock — nothing escapes
Kernel-level. macOS Seatbelt / Linux seccomp-bpf. Even ctypes calling libc can't get through.
from strands_inspect import lock
@lock
def try_network():
import urllib.request
urllib.request.urlopen("http://example.com")
return "should not reach here"
try:
result = try_network()
except RuntimeError as e:
print(f"Blocked: {e}")
❌ KernelSandbox (seatbelt)
Wall: 25.7ms
Exception: URLError: <urlopen error [Errno 8] nodename nor servname provided>
Granular policies
@watch(policy={
"file.read": {"action": "allow", "paths": ["/tmp/**"]},
"file.write": "deny",
"network": {"action": "allow", "hosts": ["*.openai.com"]},
"subprocess": "deny",
"import": "log",
})
def guarded():
...
| Preset | Does |
|---|---|
"allow_all" |
Log everything, block nothing |
"deny_network" |
Block all network |
"deny_write" |
Block file writes and deletes |
"sandbox" |
Block writes, network, subprocess, exec |
"strict" |
Block almost everything |
"deny_all" |
Block everything |
20 categories: file.read · file.write · file.delete · file.move · file.chmod · file.link · file.mkdir · file.fd_io · file.special · network · net.socket · subprocess · os.system · os.exec · process.fork · process.kill · process.mp · import · meta.ctypes · meta.code
Agent tool
from strands import Agent
from strands_inspect import inspect_tool
agent = Agent(tools=[inspect_tool])
agent("scan the requests library and find how to POST json")
📦 requests — Version: 2.32.3
📊 12 modules, 184 callables
- post(url, data=None, json=None, **kwargs) — Sends a POST request
- get(url, params=None, **kwargs) — Sends a GET request
...
16 actions: scan · call · inspect · search · generate · exec · create · list · source · install · profile · graph · connections · hotspots · unused · deps
Replay
Every @watch'd call saves a .dill file:
from strands_inspect import replay
session = replay("fibonacci_20260302_060222.dill")
session.re_run() # same args
session.re_run(100) # different args
Viewer
Export JSON. Drop into the web viewer. Memory timeline, CPU flamegraph, syscall log.
session.to_json("profile.json")
# Open docs/index.html → viewer tab
Three layers
| Layer | What | Escapes |
|---|---|---|
@watch |
55+ Python hooks | C extensions |
@watch(policy=...) |
hooks + allow/deny | C extensions |
@lock |
Kernel sandbox (forked subprocess) | Nothing |
Install
pip install strands-inspect
Python 3.10+. One dependency: strands-agents. Everything else is stdlib.
MIT License.
Metadata
Release files for strands-inspect 0.4.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 | |
|---|---|---|---|---|
| strands_inspect-0.4.0.tar.gz | 88.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| strands_inspect-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 144.1 kB
Release files / strands_inspect-0.4.0.tar.gz
| Download URL | strands_inspect-0.4.0.tar.gz |
|---|---|
| Size | 88.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fabc3e1cfb89b9a593d73043abe5d46e343d463798a0e4f11420b29cad6a5a9f
|
|
BLAKE2b-256 checksum How to use checksums |
87ae74132cf7fbaf7431db6429741e41dd5dc0232874b89c59063fd45d06564b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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 Jul 23, 2026.
Transparency logRelease files / strands_inspect-0.4.0-py3-none-any.whl
| Download URL | strands_inspect-0.4.0-py3-none-any.whl |
|---|---|
| Size | 55.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28ed1a07c9745b7ed64aa476bb8879ce3b627e8d8b6d28a0e30c218a3231e5c0
|
|
BLAKE2b-256 checksum How to use checksums |
bf3d3b1f6f1d89536adb78f1446ce88fb95d6b7c08615b684de5353e9952851d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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 Jul 23, 2026.
Transparency logSecurity for strands-inspect 0.4.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for strands_inspect-0.4.0.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 Jul 23, 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.