统一管理LLM函数调用工具,减少60%-80%集成代码
ToolRegistry: A Protocol-Agnostic Tool Management Library for Function-Calling LLMs
- 用统一工具对象抽象不同协议的RPC调用,实现跨平台兼容
- 实测集成代码减少60%-80%,并发模式选择可提升3.1倍吞吐
- 支持多模型接口、权限控制和零依赖核心,适合生产级应用
每个LLM工具调用本质上都是RPC——函数名、JSON参数和序列化结果。但现有协议(原生Python、MCP、OpenAPI、LangChain)需逐个重新集成。本文提出ToolRegistry,显式表达其RPC特性:单一Tool对象作为通用桩,注册表则作为RPC客户端运行时,负责分发、模式生成与执行。系统由三个包组成:核心注册表、支持MCP和OpenAPI的服务器端,以及生产就绪的工具库枢纽,并通过可插拔的线程或进程后端调用工具。现支持基于标签的权限策略、BM25F驱动的渐进式工具发现(适用于大规模注册表)、思考增强型函数调用、多提供商模式支持(OpenAI、Anthropic、Gemini)、声明式JSONC/YAML配置,以及仅依赖标准库的近零依赖核心。基准测试显示,该库将集成代码量减少60%-80%;在特定工作负载下,选择合适的并发模式(线程或进程)可使吞吐量提升达3.1倍。ToolRegistry已在GitHub开源(https://github.com/Oaklight/ToolRegistry),文档见https://toolregistry.readthedocs.io/。
原文摘要 · Abstract (English)
Every LLM tool call is structurally an RPC -- a function name, JSON arguments, and a serialized result -- yet each protocol (native Python, MCP, OpenAPI, LangChain) is integrated from scratch. We present ToolRegistry, a system that makes this RPC nature explicit: a single Tool object acts as a universal stub regardless of transport, while the registry serves as the RPC client runtime for dispatch, schema generation, and execution. The system ships as three packages -- a core registry, a server exposing tools over MCP and OpenAPI, and a hub of production-ready implementations -- and invokes tools through pluggable thread or process backends. The system now also provides tag-based permission policies, BM25F-powered progressive tool disclosure for large registries, think-augmented function calling, multi-provider schema support (OpenAI, Anthropic, Gemini), declarative JSONC/YAML configuration, and a near-zero-dependency core built on stdlib-only vendored modules. In our benchmarks the library cuts integration code by 60-80%, and choosing the right concurrency mode (thread vs. process) yields up to 3.1x throughput over the alternative for a given workload. ToolRegistry is open-source at https://github.com/Oaklight/ToolRegistry; documentation lives at https://toolregistry.readthedocs.io/.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。