Claude
Give a Claude agent Pictograph's tools: definitions for the Anthropic Messages API, or ready-made tools for the Claude Agent SDK, from one registry.
On this page
Using Claude Code? Install the plugin instead. Guardrails for your own agent: Agents.
Source: agents/claude.py
Anthropic Messages API
Tool definitions for messages.create, with no extra dependencies; you run the loop.
import anthropic
from pictograph.agents import create_toolkit, for_anthropic_messages
toolkit = create_toolkit()
tools = for_anthropic_messages(toolkit)
client = anthropic.Anthropic()
messages = [
{
"role": "user",
"content": "Upload ./photos to a dataset called 'demo', then draft labels for cars and people.",
},
]
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=4096,
tools=tools,
messages=messages,
)
while response.stop_reason == "tool_use":
tool_results = [
{
"type": "tool_result",
"tool_use_id": block.id,
"content": str(toolkit.dispatch(name=block.name, args=block.input)),
}
for block in response.content
if block.type == "tool_use"
]
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": tool_results})
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=4096,
tools=tools,
messages=messages,
)
print(response.content)
dispatch validates args against the tool’s schema (ValidationError) and returns a
JSON-serializable result.
Claude Agent SDK
The Agent SDK runs the loop for you. It needs the agents extra:
pip install 'pictograph[agents]'
The tools register as an in-process MCP server, each allowed as mcp__pictograph__<tool>:
import asyncio
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, create_sdk_mcp_server
from pictograph.agents import create_toolkit, for_claude_agent_sdk
toolkit = create_toolkit()
agent_tools = for_claude_agent_sdk(toolkit)
server = create_sdk_mcp_server(name="pictograph", tools=agent_tools)
options = ClaudeAgentOptions(
system_prompt="You drive Pictograph for the user. Confirm destructive operations.",
mcp_servers={"pictograph": server},
allowed_tools=[f"mcp__pictograph__{t.name}" for t in agent_tools],
)
async def main() -> None:
async with ClaudeSDKClient(options=options) as agent:
await agent.query(
"Export 'road-signs' and train a YOLOX model on the export, 50 epochs.",
)
async for message in agent.receive_response():
print(message)
asyncio.run(main())