Claude Agent SDK custom tools are MCP tools created in your Python or TypeScript process and attached as an SDK MCP server. Their names use mcp__server__tool, and they still require permission configuration. Typed schemas improve arguments; annotations describe behavior; neither replaces authorization, tenant scope, timeout, or side-effect controls.
You will create a read-only ticket tool, register it in-process, and auto-approve only its exact MCP name.
custom_tool.py:
In a real application, authenticated tenant context should be captured by the host or gateway, not accepted from model arguments. Confirm the installed SDK’s context/dependency pattern before implementation.
External stdio or HTTP servers run outside the application process and expand the supply chain, network, credential, and lifecycle boundary. Pin versions, filter tools, pass minimal credentials, restrict egress, set connection/tool deadlines, and treat outputs as untrusted.
Test the handler directly, then verify the agent calls only the fully qualified tool. Remove it from allowed_tools and confirm permission handling. Return malicious instruction text and ensure no subsequent proposal bypasses policy.
Failure injection: Mark a mutating tool readOnlyHint=True. Security must not change. Annotations are planning/client hints, not enforcement.
Add a mutating proposal tool and separate commit tool. Implement exact-name permissions, idempotency, approval, and result redaction through a host policy layer.