agentize-bridge
让运行中的 Python 应用,成为 AI 代理可以调用的工具。
一个装饰器注册命令,同时获得 HTTP、CLI、MCP 三个入口,并支持在宿主程序的主线程中执行命令。
桌面 GUI、DCC 软件等程序的状态只能在主线程中读写,无法直接接入 Web 框架,AI 代理因而无法调用它们。
使用 agentize-bridge 时,只需注册命令,参数校验、线程调度与对外暴露由框架负责。
命令也可以用 BinaryResult 返回文件或程序生成的二进制数据。HTTP 和 CLI 可以保存原始字节,MCP 也可将 PNG 和 JPEG 作为图像工具结果返回。 返回二进制数据
CLI 和 MCP 都通过 HTTP 调用宿主程序里注册的命令。宿主程序可以在线程池中执行命令,也可以在主循环中调用 run_pending(),在主线程执行队列里的命令。 架构图
快速开始
git clone https://github.com/ewoaoo/agentize-bridge.git
cd agentize-bridge
uv sync # 或:pip install -e .
import time
from agentize_bridge import AgentizeServer, command
@command()
def add(a: int, b: int = 2) -> int:
"""把两个数字相加。"""
return a + b
if __name__ == "__main__":
server = AgentizeServer("My App")
server.start_http(host="127.0.0.1", port=8765)
try:
while True:
server.run_pending() # 在主线程中执行 thread="main" 的命令
time.sleep(0.01)
except KeyboardInterrupt:
server.close()
curl -X POST http://127.0.0.1:8765/command/add \
-H 'Content-Type: application/json' -d '{"a": 2, "b": 3}' # 5
azb call add -a '{"a": 2, "b": 3}' # 5
控制台默认只显示失败请求的访问记录。设置 AgentizeServer("My App", log_mode="full") 可查看成功请求。文件输出配置见访问日志。
文档
完整文档 → 位于仓库的 docs/ 目录,下面是常用入口:
| 说明 | |
|---|---|
| 定义命令 | 参数、类型校验与二进制返回值 |
| 线程模型 | worker 与 main,接入主循环 |
| 实例方法 | 暴露已有对象的方法 |
| HTTP API · CLI · MCP | 三种调用方式 |
| 安全与限制 | 默认防护与已知缺口 |
| 开发 | 测试、构建与代码结构 |
License
Metadata
Release files for agentize-bridge 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentize_bridge-0.2.0.tar.gz | 32.7 kB | Without provenance | Details for agentize_bridge-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentize_bridge-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for agentize_bridge-0.2.0-py3-none-any.whl |
Total release size: 69.0 kB
Release files / agentize_bridge-0.2.0.tar.gz
| Download URL | agentize_bridge-0.2.0.tar.gz |
|---|---|
| Size | 32.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42abdc37c4048cd370efd7f0595c8a89e2b1938e7a95d6f5d11e49d58e026dd1
|
|
BLAKE2b-256 checksum How to use checksums |
c83ef1394dea4caa227909ada297002dbcf83503d1673bbebd38672271a5ea34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / agentize_bridge-0.2.0-py3-none-any.whl
| Download URL | agentize_bridge-0.2.0-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b4bb9c0bcc2337dec53a260e8d31bcf478343d551e9cf7197e1503d9a015a51
|
|
BLAKE2b-256 checksum How to use checksums |
bee9db652f85b658edd6ba50849d5b723588c34716528336716e34abc38d19d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for agentize-bridge 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.