Skip to main content

agentize-bridge

让运行中的 Python 应用,成为 AI 代理可以调用的工具。

一个装饰器注册命令,同时获得 HTTP、CLI、MCP 三个入口,并支持在宿主程序的主线程中执行命令。

Python License

文档 · 快速开始 · 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

MIT

Metadata

Release files for agentize-bridge 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentize-bridge 0.2.1
File Size Uploaded Provenance Actions
agentize_bridge-0.2.1.tar.gz 32.3 kB Without provenance Details for agentize_bridge-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentize-bridge 0.2.1
File Interpreter ABI Platform Actions
agentize_bridge-0.2.1-py3-none-any.whl Python 3 none any Details for agentize_bridge-0.2.1-py3-none-any.whl

Total release size: 67.9 kB

Release files / agentize_bridge-0.2.1.tar.gz

Download URL agentize_bridge-0.2.1.tar.gz
Size 32.3 kB
Tags Source
SHA-256 checksum
How to use checksums
409990c0135104e66dbb3d83856265e621f5a78f067ec3f86c447ea0fefc61b7
BLAKE2b-256 checksum
How to use checksums
3b5a5910fe2e1c68aa8942e7c6dbadb78535528ef2412060ca85b8dacac3a0db
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.1-py3-none-any.whl

Download URL agentize_bridge-0.2.1-py3-none-any.whl
Size 35.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19f207aac9992094cca6c6134884426013d65cefdf744df874be8d964b27ee1c
BLAKE2b-256 checksum
How to use checksums
bc41deebd97d70f3706391b354fe3394485cff7fa7392caebbfd8f3e90f030ed
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.1

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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page