Apply MCP extra libdirs to apropos

ober

4e50391f47bb2560e07e93a672670453e4f477bd

diff --git a/mcp/server.ss b/mcp/server.ss
index 92041b6..b19e994 100644
--- a/mcp/server.ss
+++ b/mcp/server.ss
@@ -2076,6 +2076,7 @@
       (let* ([module-path (hash-get* args "module_path" "(jerboa prelude)")]
              [normalized (normalize-import module-path)]
              [home (hash-get* args "jerboa_home" #f)]
+             [extra-libdirs (tool-extra-libdirs args #f home)]
              [script (string-append
                       "(import (rnrs))\n(import (jerboa prelude))\n"
                       "(let ([syms (environment-symbols (environment '" normalized "))])\n"
@@ -2084,7 +2085,7 @@
                       "                (when (string-contains name \"" (scheme-escape pattern) "\")\n"
                       "                  (display name) (newline))))\n"
                       "            (list-sort (lambda (a b) (string<? (symbol->string a) (symbol->string b))) syms)))\n")]
-             [out (string-trim (run-jerboa-script script home))])
+             [out (string-trim (run-jerboa-script script home extra-libdirs))])
         (if (> (string-length out) 0)
             (text-result out)
             (text-result (string-append "No symbols matching " pattern "."))))))
diff --git a/mcp/test/external-lib-test.ss b/mcp/test/external-lib-test.ss
index 1908397..d51e0ee 100644
--- a/mcp/test/external-lib-test.ss
+++ b/mcp/test/external-lib-test.ss
@@ -140,10 +140,20 @@
                   (list (cons "protocolVersion" "2024-11-05")
                         (cons "capabilities" (make-hash-table))
                         (cons "clientInfo" (alist->hash-table '())))))
-        (call-tool 9 "jerboa_function_signature"
+        (call-tool 9 "jerboa_module_exists"
+                   (alist->hash-table
+                    (list (cons "module_path" "(demo api)"))))
+        (call-tool 10 "jerboa_module_exports"
+                   (alist->hash-table
+                    (list (cons "module_path" "(demo api)"))))
+        (call-tool 11 "jerboa_function_signature"
                    (alist->hash-table
                     (list (cons "symbol" "with-demo")
-                          (cons "imports" (list "(demo api)"))))))))
+                          (cons "imports" (list "(demo api)")))))
+        (call-tool 12 "jerboa_apropos"
+                   (alist->hash-table
+                    (list (cons "module_path" "(demo api)")
+                          (cons "pattern" "with-")))))))
     (lambda ()
       (putenv "JERBOA_MCP_EXTRA_LIBDIRS" (or old-extra-libdirs "")))))
 
@@ -153,7 +163,10 @@
 (def fixed-text (content-text (result (list-ref responses 4))))
 (def macro-text (content-text (result (list-ref responses 5))))
 (def qt-bundle-text (content-text (result (list-ref responses 6))))
-(def env-macro-text (content-text (result (list-ref env-responses 1))))
+(def env-exists-text (content-text (result (list-ref env-responses 1))))
+(def env-exports-text (content-text (result (list-ref env-responses 2))))
+(def env-macro-text (content-text (result (list-ref env-responses 3))))
+(def env-apropos-text (content-text (result (list-ref env-responses 4))))
 (def cookbook-text (read-file-string (path-join repo-root "data" "cookbooks.sexp")))
 
 (check "module_exists honors relative extra_libdirs"
@@ -181,6 +194,10 @@
 (check "function_signature honors JERBOA_MCP_EXTRA_LIBDIRS defaults"
        (and (string-contains env-macro-text "Kind: syntax")
             (string-contains env-macro-text "Usage: (with-demo ctx body ...)")))
+(check "module lookup tools honor JERBOA_MCP_EXTRA_LIBDIRS defaults"
+       (and (string-contains env-exists-text "exists: true")
+            (string-contains env-exports-text "with-demo")
+            (string-contains env-apropos-text "with-demo")))
 (check "qt dependency context is compact and current"
        (and (< (string-length qt-bundle-text) 4096)
             (string-contains qt-bundle-text "Qt dependency context bundle")