Function: autoDiscover()
ts
function autoDiscover(
registry,
dir,
options?): Promise<string[]>;Defined in: packages/core/src/server/autoDiscover.ts:182
Scan a directory and auto-register all discovered tool builders.
Eliminates the need for a central index.ts that manually imports and registers every tool. New tools are automatically picked up when they are dropped into the scanned directory.
Parameters
| Parameter | Type | Description |
|---|---|---|
registry | ToolRegistryLike | A ToolRegistry instance to register discovered tools |
dir | string | Path to the tools directory (absolute or relative to CWD) |
options | AutoDiscoverOptions | Discovery options (pattern, recursive, loader, resolve) |
Returns
Promise<string[]>
Array of discovered file paths (for logging/debugging)
Throws
If the directory does not exist or is not readable
Example
typescript
const registry = new ToolRegistry<AppContext>();
const files = await autoDiscover(registry, './src/tools');
console.log(`Discovered ${files.length} tool files`);