Skip to main content

strands-inspect logo

strands-inspect

Awesome Strands Agents

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_inspect-0.4.0.tar.gz (88.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_inspect-0.4.0-py3-none-any.whl (55.8 kB view details)

Uploaded Python 3

File details

Details for the file strands_inspect-0.4.0.tar.gz.

File metadata

  • Download URL: strands_inspect-0.4.0.tar.gz
  • Upload date:
  • Size: 88.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for strands_inspect-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fabc3e1cfb89b9a593d73043abe5d46e343d463798a0e4f11420b29cad6a5a9f
MD5 9b50b591763b67449862791172010e2c
BLAKE2b-256 87ae74132cf7fbaf7431db6429741e41dd5dc0232874b89c59063fd45d06564b

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_inspect-0.4.0.tar.gz:

Publisher: auto-release.yml on cagataycali/strands-inspect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file strands_inspect-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: strands_inspect-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 55.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for strands_inspect-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28ed1a07c9745b7ed64aa476bb8879ce3b627e8d8b6d28a0e30c218a3231e5c0
MD5 ad076e33bacc88cf703c25c1284cab43
BLAKE2b-256 bf3d3b1f6f1d89536adb78f1446ce88fb95d6b7c08615b684de5353e9952851d

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_inspect-0.4.0-py3-none-any.whl:

Publisher: auto-release.yml on cagataycali/strands-inspect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page