Two registries, two jobs. The factory registry (this page) builds instances from config. The name-keyed registry stores tools by name — use
register_tool for “I already have my tool” (see Custom Tools). Reach for registerToolFactory for “here’s how to build this tool from user config”.Quick Start
1
Register a Factory
2
Build an Instance
Migration from the Old Root Exports
Before PR #4902,register_tool / get_tool / validate_tool at the package root pointed at the factory registry by accident. They now point at the name-keyed registry. If you actually wanted the factory registry, switch names:
Building Instances
Two builders, differing only in how they report a missing id.
See Tool Errors for the try/catch pattern that tells “missing” apart from “broken”.
Pre-flight Checks
validateToolInstall(id) reports whether a registered tool’s npm dependency and required environment variables are in place — ideal for CLIs and setup scripts.
Registry API
Access the singleton for advanced use cases.Best Practices
Use the factory registry only for config-built tools
Use the factory registry only for config-built tools
If you already hold a tool instance or function,
register_tool on the name-keyed registry is simpler. The factory registry earns its keep when a tool is built from user config or a lazy-loaded dependency.Prefer tryCreateToolInstance when a tool is optional
Prefer tryCreateToolInstance when a tool is optional
Return
null for a missing id instead of catching an exception — but still let ToolConstructionError surface, so a broken tool never looks identical to a missing one.Run validateToolInstall in setup scripts
Run validateToolInstall in setup scripts
Call it before first use in a CLI or bootstrap step so users get a clear “run npm install …” or “set SEARCH_API_KEY” message instead of a runtime failure.
Migrate off the deprecated subpath aliases
Migrate off the deprecated subpath aliases
Replace
praisonai/tools/registry snake_case imports with registerToolFactory / createToolInstance / tryCreateToolInstance / validateToolInstall.Related
Custom Tools
Name-keyed registry & FunctionTool
Tool Errors
Missing vs broken tools
Tools Registry
Built-in AI SDK tools
Tool System
Tools overview

