aidputils.agents.tools.http_tool¶
HTTP Tool for executing HTTPS requests to external APIs.
This tool provides a standardized interface for agents to make HTTP requests with template variable substitution, SSRF protection, and MCP-compliant output formatting.
- aidputils.agents.tools.http_tool.validate_headers(headers: Dict[str, str]) None[source]¶
Validate headers for size limits and sensitive header protection.
- Parameters:
headers – Dictionary of header name -> value
- Raises:
SecurityError – If headers violate security constraints
- class aidputils.agents.tools.http_tool.HttpTool[source]¶
Bases:
BaseToolHTTP Tool for executing HTTPS requests to external APIs.
Supports GET, POST, PUT, DELETE, PATCH methods with: - {{variable}} template substitution in URL, headers, params, and body - SSRF protection (blocks private IPs, cloud metadata endpoints) - Header size limits and sensitive header protection - JSON body serialization - MCP-compliant output formatting
- Configuration:
name: Tool name for agent discovery description: Tool description for LLM tool selection method: HTTP method (GET, POST, PUT, DELETE, PATCH) url: Target URL with optional {{variable}} templates headers: Optional custom headers (dict) params: Optional query parameters (dict) body: Optional request body (dict or JSON-serializable) timeout: Optional timeout in seconds (default: 30) auth: Optional auth configuration object:
{“authType”: “NO_AUTH”|”BEARER_TOKEN”|”OAUTH”, …}
retry: Optional retry configuration {“max_attempts”: 1-5} (default: 3)
Example
- conf = {
“name”: “get_user”, “description”: “Get user details by ID”, “method”: “GET”, “url”: “https://api.example.com/users/{{user_id}}”, “headers”: {“X-Custom-Header”: “{{custom_value}}”}, “auth”: {“authType”: “NO_AUTH”}
} runtime_params = {“user_id”: “123”, “custom_value”: “test”} result = HttpTool.invoke(conf, runtime_params)