diff options
| author | N. Taylor Mullen <[email protected]> | 2025-06-02 23:37:02 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-03 06:37:02 +0000 |
| commit | 5f6f6a95a2de30373665aae5472e2a5bb2bc25fb (patch) | |
| tree | 26a2d14777ce3c95dddef6ad1c3db47403b268dc /packages/core/src/config/config.ts | |
| parent | 8ab74ef1bb4bd1c475596088d9d3b52e0a9c5ca7 (diff) | |
Refactor: Make MCP server discovery non-blocking (#716)
Diffstat (limited to 'packages/core/src/config/config.ts')
| -rw-r--r-- | packages/core/src/config/config.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 46e5123c..7b0be08d 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -254,7 +254,7 @@ export function createServerConfig(params: ConfigParameters): Config { }); } -export function createToolRegistry(config: Config): Promise<ToolRegistry> { +function createToolRegistry(config: Config): Promise<ToolRegistry> { const registry = new ToolRegistry(config); const targetDir = config.getTargetDir(); const tools = config.getCoreTools() @@ -281,8 +281,12 @@ export function createToolRegistry(config: Config): Promise<ToolRegistry> { registerCoreTool(ShellTool, config); registerCoreTool(MemoryTool); registerCoreTool(WebSearchTool, config); - return (async () => { - await registry.discoverTools(); - return registry; - })(); + + // This is async, but we can't wait for it to finish because when we register + // discovered tools, we need to see if existing tools already exist in order to + // avoid duplicates. + registry.discoverTools(); + + // Maintain an async registry return so it's easy in the future to add async behavior to this instantiation. + return Promise.resolve(registry); } |
