Runtime security SDK for AI agents — guard tool calls in 1 line
Project description
Clampd Python SDK
Runtime security for AI agents. Guard every tool call — OpenAI, Anthropic, LangChain, Google ADK — in 1 line.
Installation
pip install clampd
With framework extras:
pip install clampd[langchain] # LangChain callback handler
pip install clampd[mcp] # MCP server support
pip install clampd[all] # Everything
Quick Start
import clampd
from openai import OpenAI
# Configure once at startup
clampd.init(
agent_id="my-agent",
secret="ags_...", # from dashboard → Agent → Secret
gateway_url="http://localhost:8080",
api_key="ag_live_...",
)
# Wrap your OpenAI client — done
client = clampd.openai(OpenAI())
# Use it exactly like before. Clampd intercepts every tool call.
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Look up active users"}],
tools=[...],
)
# Dangerous tool calls → blocked before execution
# Safe tool calls → proceed normally
Configuration
Three ways to configure (pick one):
# Option 1: Environment variables
# export CLAMPD_GATEWAY_URL=http://localhost:8080
# export CLAMPD_API_KEY=ag_live_...
# export CLAMPD_AGENT_ID=my-agent
# export CLAMPD_AGENT_SECRET=ags_...
# Option 2: Global init (recommended)
clampd.init(agent_id="my-agent", secret="ags_...", gateway_url="...", api_key="...")
# Option 3: Inline per-call
@clampd.guard("db.query", agent_id="my-agent", secret="ags_...", gateway_url="...", api_key="...")
def query(sql): ...
Anthropic / Claude
import clampd
from anthropic import Anthropic
clampd.init(agent_id="my-agent", secret="ags_...")
client = clampd.anthropic(Anthropic())
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "..."}],
tools=[...],
)
LangChain
import clampd
handler = clampd.langchain(agent_id="my-agent", secret="ags_...")
result = executor.invoke(
{"input": "Look up active users"},
config={"callbacks": [handler]},
)
Google ADK
import clampd
from google.adk import Agent
agent = Agent(
tools=[...],
before_tool_callback=clampd.adk(agent_id="my-agent", secret="ags_..."),
)
Direct Guard (any function)
import clampd
clampd.init(agent_id="my-agent", secret="ags_...")
@clampd.guard("database.query")
def run_query(sql: str):
return db.execute(sql)
# With response checking (opt-in)
@clampd.guard("file_read", check_response=True)
def read_file(path: str):
return open(path).read()
run_query("SELECT * FROM users") # allowed
run_query("DROP TABLE users") # raises ClampdBlockedError
Error Handling
from clampd import ClampdBlockedError
try:
run_query("DROP TABLE users")
except ClampdBlockedError as e:
print(f"Blocked: {e}")
# e.risk_score, e.denial_reason, e.request_id
API Reference
| Function | Description |
|---|---|
clampd.init(...) |
Configure global client (once at startup) |
clampd.openai(client) |
Wrap OpenAI client |
clampd.anthropic(client) |
Wrap Anthropic client |
clampd.guard(tool_name) |
Decorator for any function |
clampd.langchain(...) |
LangChain callback handler |
clampd.adk(...) |
Google ADK before_tool_callback |
Requirements
- Python 3.10+
- A running Clampd gateway
License
BUSL-1.1
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
clampd-0.2.0.tar.gz
(17.5 kB
view details)
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
clampd-0.2.0-py3-none-any.whl
(15.2 kB
view details)
File details
Details for the file clampd-0.2.0.tar.gz.
File metadata
- Download URL: clampd-0.2.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e766c54da86dab4609d8a50a895902aed1492affb3dafd3e6f121e2bb9e24257
|
|
| MD5 |
3eb3c59d2cd294688f8dadff293b82d4
|
|
| BLAKE2b-256 |
dee6ed3a027f2f25cf4108c2671b52c6b44c34ba767b485974d1ed8a0e092623
|
File details
Details for the file clampd-0.2.0-py3-none-any.whl.
File metadata
- Download URL: clampd-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69d42148243c416cadc9d585f734f8e189b33e2baa50740f61e2b027756184d0
|
|
| MD5 |
4831c67703b138ed269e7cbac40e5d6b
|
|
| BLAKE2b-256 |
9b33f3802581953fe7e89657ad71903d8267cf17e3f20ab7d83944087934e766
|