adachsoft/http-tool
Composer 安装命令:
composer require adachsoft/http-tool
包简介
AI Tool for making HTTP requests with strict URL policies and response limits.
README 文档
README
adachsoft/http-tool is a PHP library that provides an SPI implementation for adachsoft/ai-tool-call. It exposes an http_tool that allows AI agents to perform controlled HTTP requests (GET, POST, PUT, DELETE) with strict security policies and response size limits.
Features
- Strict URL Policy: Whitelist and blacklist URL prefixes to control where the agent can send requests.
- Response Limiting: Automatically truncates large response bodies to prevent context overflow.
- Error Handling: Returns structured error information (e.g.,
url_not_allowed,response_too_large,transport_error) instead of throwing exceptions, allowing the agent to react. - Guzzle Integration: Uses Guzzle for robust HTTP communication.
Installation
composer require adachsoft/http-tool
Configuration
The tool is configured via a ConfigMap passed to the HttpToolFactory.
Configuration Keys
| Key | Type | Required | Description |
|---|---|---|---|
max_body_size | int | Yes | Maximum response body size in bytes. Larger bodies are truncated. |
blocked_url_prefixes | string[] | No | List of URL prefixes that are strictly forbidden. |
allowed_url_prefixes | string[] | null | No | List of allowed URL prefixes. If null (or omitted), all URLs are allowed (except blocked ones). |
default_headers | map<string, string> | No | Default HTTP headers added to every request (can be overridden by the agent). |
Example
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\HttpTool\Tool\HttpToolFactory;
$config = new ConfigMap([
'max_body_size' => 4096, // Limit responses to 4KB
'blocked_url_prefixes' => ['http://localhost', 'http://127.0.0.1'], // Block local access
'allowed_url_prefixes' => ['https://api.example.com', 'https://public-api.com'], // Whitelist
'default_headers' => [
'User-Agent' => 'MyAIApp/1.0',
],
]);
$factory = new HttpToolFactory();
$tool = $factory->create($config);
// Register $tool with your ToolRegistry...
Tool Usage (AI Agent)
The agent invokes the tool http_tool with the following parameters:
method(string, required):GET,POST,PUT, orDELETE.url(string, required): Full URL.headers(map, optional): Custom headers.query(map, optional): Query parameters.body(string, optional): Request body.
Response Structure
The tool returns a structured result:
{
"status_code": 200,
"reason_phrase": "OK",
"headers": { ... },
"body": "{ ... }",
"body_truncated": false,
"error_type": null,
"error_message": null,
"request_method": "GET",
"request_url": "https://api.example.com/data"
}
License
MIT
adachsoft/http-tool 适用场景与选型建议
adachsoft/http-tool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「Guzzle」 「tool」 「Agent」 「ai」 「llm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adachsoft/http-tool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adachsoft/http-tool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adachsoft/http-tool 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Backend Google Sign On for Magento 2
An app setting manager tool for laravel nova
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
Convert doctrine dbal query result to dto
A model factory package for Laravel 4 with expressive API for creating custom tailored dummy objects
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-04