Tool Registry
A centralized registry for discovering, registering, and resolving AI tools across modules and classes.
The Tool Registry is a singleton that manages AI tools across your entire application. Instead of manually passing tool arrays to every agent, you can register tools once and resolve them by name anywhere.
Why Use the Registry?
Pass tools array to every agent/model call
Register once, reference by name
No cross-module tool sharing
Tools shared across modules
Manual @AITool discovery
Auto-scan classes for annotated methods
Duplicate tool definitions
Single source of truth
Accessing the Registry
// Get the singleton registry
registry = aiToolRegistry()Registering Tools
Using our aiTool() BIF
All tools that you create with aiTool() are automatically registered in the global registry. If you don't want them to be automatically registered, you can set register: false in the options and register manually with aiToolRegistry().register().
// Positional args
myTool = aiTool( "search", "Search the database", ( required query ) => db.search( query ) )
// Named args
myTool = aiTool(
name : "search",
description: "Search the database",
callback : ( required query ) => db.search( query )
)Tool Registry Registration
You can also register any closure or ITool instance directly with the registry, no aiTool() wrapper needed:
With Module Attribution
Use a module name to group tools for easy bulk unregistration later:
Scanning a Class with @AITool
Annotate methods with @AITool and scan the class to register all at once:
Scanning a Package Path
@AITool Options
The @AITool annotation supports the following formats for defining the tool name and description:
Single
@AITool: Thenameis derived from the method name, and thedescriptionis taken from the method hint@AITool( "Description string" ): The method name is used as the tool name, and the provided string is used as the description@AITool( { name: "x", description: "y" } ): Explicitly specify both the tool name and description
Example:
Using Registered Tools
Resolve by Name
Resolve an Array (Mix of Strings and Instances)
resolveTools() lets you pass a heterogeneous array of tool names and/or ITool instances:
Introspect the Registry
Unregistering Tools
Built-in Tools (v3.0+)
The module ships with several built-in tool classes that are auto-registered in the global tool registry at startup. You can opt-in to these tools by name when creating agents.
Core Tools
httpGet@bxai
Fetch the contents of a URL via HTTP GET
log@bxai
Write a message to the ai.log file (info, warning, error, etc.)
now@bxai
Return the current date/time in ISO 8601 format
print@bxai
Print a message to the console (debug/output visibility)
sendEmail@bxai
Send an email using the server's configured mail service
Audio Tools
speak@bxai
Convert text to speech, save to file, return the file path
transcribe@bxai
Transcribe a local file or URL to plain text
translate@bxai
Translate any-language audio to English text
Image Tools (v3.2.0+)
generateImage@bxai
Generate an image from a text prompt, save to file, return the file path
Filesystem Tools
readFile@bxai
Read file contents
readMultipleFiles@bxai
Read multiple files at once
writeFile@bxai
Write content to a file
appendFile@bxai
Append content to a file
editFile@bxai
Edit a file with search/replace
fileMetadata@bxai
Get file metadata
pathExists@bxai
Check if a path exists
deleteFile@bxai
Delete a file
moveFile@bxai
Move a file
copyFile@bxai
Copy a file
searchFiles@bxai
Search for files by pattern
listAllowedDirectories@bxai
List allowed directories
listDirectory@bxai
List directory contents
directoryTree@bxai
Get directory tree structure
createDirectory@bxai
Create a directory
deleteDirectory@bxai
Delete a directory
zipFiles@bxai
Create a zip archive
unzipFile@bxai
Extract a zip archive
checkZipFile@bxai
Validate a zip file
🚨 Filesystem tools are NOT auto-registered. They must be explicitly enabled via
aiToolRegistry().scanClass()so agents never get filesystem access unless explicitly granted. Supports a path-guard constructor (allowedPaths: [...]) that blocks directory-traversal attacks.
Web Search Tools (v3.2.0+)
webSearch@bxai
Searches the web for information and returns an array of results (title, URL, snippet, ...)
💡
provider = ""means "use the configured default provider" (HTTP by default).maxResults = 0means "use provider/module defaults".
Agent Registry (v3.2.0+)
In addition to the Tool Registry, BoxLang AI 3.2.0 introduces the Agent Registry — a singleton for centralized agent management.
Agent Registry API
register( agent, module )
Register an agent with optional module namespace
unregister( key )
Remove agent by key
unregisterByModule( module )
Remove all agents from a module
resolveAgents( array )
Resolve mixed array of string keys and AiAgent instances
listAgents()
Return struct of all registered agents
getAgentInfo( key )
Return { name, description, module } for a key
Agent Registry Events
onAIAgentRegistryRegister
Agent registered
onAIAgentRegistryUnregister
Agent unregistered
Related Pages
Tools & MCP (Agents) — Using the registry with agents
aiToolRegistry() Reference — BIF reference
Tools — Core tool concepts and
aiTool()usageCustom Tools — Building custom tool classes
Last updated