An extension of fabricatio, which brings up the capability to use tool with native python.
Project description
fabricatio-tool
Tool execution layer for Fabricatio — wraps Python callables as discoverable tools, lets LLMs generate orchestration code, and executes it with safety validation.
Installation
pip install fabricatio[tool]
# or
uv pip install fabricatio[tool]
For all Fabricatio packages:
pip install fabricatio[full]
Overview
fabricatio-tool enables Fabricatio agents to use arbitrary Python functions as tools. Tools are grouped into toolboxes, discovered by an LLM-driven selection process, composed into execution code (also LLM-generated), and run inside a ToolExecutor with import/call safety checks. Results are collected in a ResultCollector for downstream use.
The package also includes built-in filesystem tools, MCP (Model Context Protocol) client integration, and optional user-confirmation guards for destructive operations.
Core concepts
| Concept | Description |
|---|---|
Tool |
A named, described callable with auto-extracted signature and briefing |
ToolBox |
A named collection of related Tool instances |
ToolExecutor |
Runs LLM-generated code that invokes tools; validates imports and calls |
ResultCollector |
Key-value container for tool execution results and errors |
Handle / HandleTask |
Mixin classes that wire tool discovery → code generation → execution |
Key classes and functions
fabricatio_tool.models.tool
Tool(source, name, description)— wraps a callable with metadata.invoke(*args, **kwargs)calls through..signatureand.briefingare auto-generated.ToolBox(name, description)— collects tools.add_tool(func)appends a tool;collect_tool()works as a decorator.get(name)looks up a tool by name..briefingproduces an LLM-friendly description.
fabricatio_tool.models.collector
ResultCollector—submit(key, val),revoke(key),take(key)for typed retrieval,error()for retrieving execution errors.ApplicationError— captures exception type, message, traceback, and the generated source for retry.
fabricatio_tool.models.executor
ToolExecutor(candidates, data)—execute(source)runs tool-usage code asynchronously.inject_tools(cxt),inject_data(cxt),inject_collector(cxt)prepare the execution context.from_recipe(recipe, toolboxes)constructs an executor by selecting tools by name.
fabricatio_tool.capabilities
UseTool— LLM-driven selection:choose_toolboxes(request),choose_tools(request),gather_tools(request),gather_tools_fine_grind(request).Handle—draft_tool_usage_code(request, tools, data)generates Python code via LLM.handle(request, data)andhandle_fine_grind(request, data)run the full pipeline.HandleTask— extendsHandlewithhandle_task(task, data)for FabricatioTaskobjects.
fabricatio_tool.config
ToolConfig— configuration model:check_modules,check_imports,check_calls(whitelist/blacklist),mcp_servers,confirm_on_ops,logging_on_ops.CheckConfigModel(targets, mode)— whitelist or blacklist mode for validation.tool_config— singleton instance loaded from Fabricatio config.
fabricatio_tool.fs
Filesystem utilities callable as tools:
| Function | Description |
|---|---|
dump_text(path, text) |
Write text to a file |
copy_file(src, dst) |
Copy a file |
move_file(src, dst) |
Move/rename a file |
delete_file(path) |
Delete a file |
create_directory(path) |
Create a directory |
delete_directory(path) |
Recursively delete a directory |
absolute_path(path) |
Resolve to absolute POSIX path |
gather_files(directory, ext) |
Glob for files by extension |
safe_text_read(path) |
Read file as UTF-8 text |
safe_json_read(path) |
Read and parse JSON file |
treeview(path, max_depth) |
Render a directory tree (Rust) |
fabricatio_tool.mcp
get_global_mcp_manager(conf)— singleton MCP manager (Rust-backed).mcp_tool_to_function(client_id, tool_name)— converts an MCP tool to an async callable.mcp_to_toolbox(client_id)— converts all tools from an MCP client into aToolBox.
fabricatio_tool.decorators
confirm_to_execute(func)— wraps a function with an interactive confirmation prompt viaquestionary.
fabricatio_tool.toolboxes
fs_toolbox— pre-builtToolBoxcontaining all filesystem tools listed above.
Usage example
from fabricatio_tool.models.tool import Tool, ToolBox
from fabricatio_tool.models.executor import ToolExecutor
# Define a tool
def add(a: int, b: int) -> int:
"""Add two integers."""
return a + b
# Build a toolbox
box = ToolBox(name="math", description="Math operations")
box.add_tool(add, confirm=False, logging=True)
# Execute LLM-generated tool-usage code
executor = ToolExecutor(candidates=box.tools, data={})
source = """
async def execute(collector):
result = await add(3, 4)
collector.submit('sum', result)
"""
await executor.execute(source)
print(executor.collector.take('sum')) # 7
With filesystem toolbox
from fabricatio_tool.toolboxes import fs_toolbox
# Use the built-in filesystem tools
executor = ToolExecutor(candidates=fs_toolbox.tools, data={})
source = """
async def execute(collector):
import pathlib
await dump_text(pathlib.Path('example.txt'), 'Hello, Fabricatio!')
content = await safe_text_read(pathlib.Path('example.txt'))
collector.submit('content', content)
"""
await executor.execute(source)
print(executor.collector.take('content')) # Hello, Fabricatio!
Using capability mixins
from fabricatio_tool.capabilities.handle import Handle
class MyAgent(Handle):
...
agent = MyAgent()
result = await agent.handle(
"Find all Python files and count their total lines",
data={"dir": "src/"},
model="default",
)
if result and not result.error():
print(result.take("output"))
Safety
ToolExecutor validates generated code against configurable whitelists or blacklists for modules, imports, and function calls. By default, only safe builtins (str, int, float, bool, dict, set, list, pathlib.Path, print, len) and math are permitted. Destructive tools can be gated behind confirm_to_execute, which prompts the user interactively.
Dependencies
fabricatio-core— core interfaces and utilitiespydantic>=2.11.7questionary>=2.1.0
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabricatio_tool-0.8.9-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de72c0f7a9ec3a113dcde71d1d959f710e123b6e7b5def90a8402da05324055
|
|
| MD5 |
d83adf8e02f245aa6ff61bdb969a6d94
|
|
| BLAKE2b-256 |
96c64e8dac8db7d0ea43f34d40bf7f9dd18d8c8ed0028e45a9741cb18b5f8845
|
File details
Details for the file fabricatio_tool-0.8.9-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5da337a7432d51277d712e6553286ec365a17afe464e83157bbc1b5b12516c08
|
|
| MD5 |
500491e531c3bcbff639a442b1529d9b
|
|
| BLAKE2b-256 |
8f58fe875e5488e6f268cb3aa8dc1efe7c4469dcc7f797307d9fbde5dbc25717
|
File details
Details for the file fabricatio_tool-0.8.9-cp314-cp314-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp314-cp314-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 8.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cd08f9adee8e26a22ea983c6a820a039206ea1de825f0c7c962fc4b54f74360
|
|
| MD5 |
672f9c797b0613a2c9a0b8c03ea2c8d6
|
|
| BLAKE2b-256 |
a305d5e48d02122f3071214a47f0fb7e804d1c3e540335093e0f7a8fe0039c16
|
File details
Details for the file fabricatio_tool-0.8.9-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.6 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f97c7d79e9954bf46d62710dd9f98ac3da7fc37ab298442fc0f98f04da18ca
|
|
| MD5 |
1c20672a4184a9d9046551f921375580
|
|
| BLAKE2b-256 |
d795ed6c44988f5ade544ae0ab9b17145abba494bc26b56a8e6243d7e0fa988c
|
File details
Details for the file fabricatio_tool-0.8.9-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ddd449a663f8467abcf4aecf1a8abc1075788c7c06fe4e8cd32409bcab2e065
|
|
| MD5 |
fc7bed5f6b396d3cdb16b15c69b82da6
|
|
| BLAKE2b-256 |
d1d7bb8b02eb0e1e7fcc73d0f41cd23a98f2e0817bdc7f4691a29a7061fac50f
|
File details
Details for the file fabricatio_tool-0.8.9-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c99a2ace0b0f020e61e9cf635dbd8d2d142ea856d4daaf3cede9810894397da5
|
|
| MD5 |
6910c3fee8b278c9ff33d082188f2137
|
|
| BLAKE2b-256 |
dffbc5d41aae2086a5d4329e59c1bf0fdd528497c0c3540fb1c1810429942cf7
|
File details
Details for the file fabricatio_tool-0.8.9-cp313-cp313-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp313-cp313-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 8.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6decc0b79f377345b03215a87e3ceecdc89c9518f4972618dddb1329a82b4819
|
|
| MD5 |
e44fe912a701461064b0cb654ff9b56a
|
|
| BLAKE2b-256 |
b8e8bb0432dc6097cefff3a350836adda86285004a0b3d7993da0e9acec57e20
|
File details
Details for the file fabricatio_tool-0.8.9-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.6 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65940fe478f9bcaaacb573e59ab74b58963c004b8d935e49bbcc9e531b52dfcb
|
|
| MD5 |
11e7a708c11aa69206461df8a0c55542
|
|
| BLAKE2b-256 |
f2ac36302cc9e45cbef9969a8d2c816c3410b5f5149e61aa54c3dc5b2dd37c95
|
File details
Details for the file fabricatio_tool-0.8.9-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5c19b16d3eff4ac20faa281b8f55e5338353625f220b8f01dd32e4f5f57aa44
|
|
| MD5 |
9b998ad67d72f044786767f7cd0793b7
|
|
| BLAKE2b-256 |
fa465a0b806588fc8fb8b706f5169a7a5bde21c61f26e97ebdc811283ac30b63
|
File details
Details for the file fabricatio_tool-0.8.9-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c7b4d7c286d89375a08a08f1db7a80ad588bee60a0783fa6c402eb1a24b0405
|
|
| MD5 |
398859f71901a3580d2747f4e6812b4d
|
|
| BLAKE2b-256 |
a48a57925a21fe6d7638f05f1f509f5f703e7e362e83d3938d2b35489877a848
|
File details
Details for the file fabricatio_tool-0.8.9-cp312-cp312-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp312-cp312-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 8.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ec656ed3227412efe73db4eed7a0e23d4d24246f097ea2c604a2b16df3d4a8e
|
|
| MD5 |
4d2c83193e519b0dc0faf748dd164a77
|
|
| BLAKE2b-256 |
ea384b556629813af6e8a4900602c7aecac1d5d073fb827e78cb0f2454173c08
|
File details
Details for the file fabricatio_tool-0.8.9-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_tool-0.8.9-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.6 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a4a9707e198bd10e67e949800a56f348ae63879e0af2bb114e59d09461a61de
|
|
| MD5 |
10e80b5b56466c128f916d3de9204777
|
|
| BLAKE2b-256 |
9832d11f04be256aeb30e6966f74b62e94b6584d56035306c28eb1fa35626e11
|