Commit 0db66ad

mo khan <mo@mokhan.ca>
2026-01-27 21:16:35
feat: improve startup speed by loading MCP tools async
1 parent d2c254f
Changed files (1)
lib
elelem
plugins
lib/elelem/plugins/mcp.rb
@@ -3,12 +3,18 @@
 Elelem::Plugins.register(:mcp) do |agent|
   mcp = Elelem::MCP.new
   at_exit { mcp.close }
-  mcp.tools.each do |name, tool|
-    agent.toolbox.add(name,
-      description: tool[:description],
-      params: tool[:params],
-      required: tool[:required],
-      &tool[:fn]
-    )
+
+  Thread.new do
+    mcp.tools.each do |name, tool|
+      agent.toolbox.add(
+        name,
+        description: tool[:description],
+        params: tool[:params],
+        required: tool[:required],
+        &tool[:fn]
+      )
+    end
+  rescue => e
+    warn "MCP failed: #{e.message}"
   end
 end