Преглед изворни кода

enhance: simplify enabling mcp server

Automatically enable http server if it's not started. Also fix typo for
http server and failing integration test
Gabriel Horner пре 4 недеља
родитељ
комит
5b919bd7a7
3 измењених фајлова са 7 додато и 4 уклоњено
  1. 4 1
      src/main/frontend/components/settings.cljs
  2. 1 1
      src/main/logseq/api.cljs
  3. 2 2
      src/resources/dicts/en.edn

+ 4 - 1
src/main/frontend/components/settings.cljs

@@ -682,7 +682,7 @@
 
 (defn http-server-switcher-row []
   (row-with-button-action
-   {:left-label "HTTP APIs server"
+   {:left-label "HTTP API server"
     :action (http-server-enabled-switcher t)}))
 
 (defn flashcards-switcher-row [enable-flashcards?]
@@ -1207,6 +1207,9 @@
     (let [on-toggle (fn []
                       (let [new-val (not checked)]
                         (set-checked! new-val)
+                        ;; Enable HTTP server to simplify starting MCP
+                        (when (and new-val (not (storage/get ::storage-spec/http-server-enabled)))
+                          (storage/set ::storage-spec/http-server-enabled true))
                         (-> (ipc/ipc :server/set-config {:mcp-enabled? new-val})
                             ;; Dont start server if it's not running
                             (p/then #(when (= "running" (state/sub [:electron/server :status]))

+ 1 - 1
src/main/logseq/api.cljs

@@ -1092,7 +1092,7 @@
   (let [current-page? (or (and (nil? content) (nil? opts))
                           (and (nil? opts) (some->> content (instance? js/Object))))
         opts (if current-page? content opts)
-        mcp-options (bean/->clj (aget opts "mcp-options"))
+        mcp-options (some-> opts (aget "mcp-options") bean/->clj)
         content (if current-page? uuid-or-page-name content)
         uuid-or-page-name (if current-page?
                             (or (state/get-current-page) (date/today))

+ 2 - 2
src/resources/dicts/en.edn

@@ -215,8 +215,8 @@
  :context-menu/template-exists-warning "Template already exists!"
  :settings-page/ai "AI"
  :settings-page/tab-ai "AI"
- :settings-page/enable-mcp-server "Enable MCP Server"
- :settings-page/enable-mcp-server-desc "Run MCP Server within HTTP API server to allow local AI applications to connect to current graph."
+ :settings-page/enable-mcp-server "MCP Server"
+ :settings-page/enable-mcp-server-desc "Enable MCP Server to allow commmunication with local AI applications. MCP Server depends on HTTP API server."
  :settings-page/git-tip "If you have Logseq Sync enabled, you can view a page's edit history directly. This section is for tech-savvy only."
  :settings-page/git-desc-1 "To view page's edit history, click the three horizontal dots in the top-right corner and select \"View page history\"."
  :settings-page/git-desc-2 "For professional users, Logseq also supports using "