Utilizing LogSeq as an MCP Client

I’ve been working on integrating LogSeq with Claude. I’ve made a plugin that will turn a set of child blocks/queries/block references into a conversation with Anthropic’s API, and I’ve developed a Model Context Protocol (MCP) server that let’s Claude Desktop interact with LogSeq through its http server based on joelhooks/logseq-mcp-tools: mcp server for logseq graph’s server.

Both of these options still require additional coding for further integrations. I started wondering if there was a way to convert LogSeq into an MCP client. This would allow it to integrate with any MCP server that comes out making it much easier to integrate with other apps and have all your conversations stored (and editable) within LogSeq.

This isn’t possible to do as a plugin because plugin code is sandboxed for security reasons - meaning they can’t access exterior files or servers on the local machine - though this could potentially be possible with remote servers.

I tried looking into placing all the code required into the custom.js file. This became unruly, and I already have a significant amount of code in it for Edit and run javascript code inside Logseq itself - Customization / Look what I built - Logseq.

I imagine there has to be a way to utilize the kits/modules running JS within LogSeq pages allows to set up MCP client capabilities, but I’m having a hard time wrapping my mind around it - I’m not a software developer.

I’d like to utilize Anthropic’s MCP SDK as well as several other dependencies to make the code simpler to work with. Is it possible to import/compile other libraries utilizing LogSeq’s native api? I don’t imagine this would be able to perform any compile/build functions.

  • In theory all that should be possible, but not easy (not even for a software developer).
    • Should isolate the various challenges and try solving each one individually.
    • For now I’m going to just list some of Kits’ relevant features.
  • Kits is currently the most comprehensive library for modularizing and running client-side code within Logseq.
    • It already performs conditional loading of external libraries, in the cases of Pyodide and WebR.
      • Any other online script could be dynamically imported on demand.
    • It has access to everything Logseq, but not to the operating system.
    • It resides itself in custom.js, but then facilitates running all other code from Logseq pages.
      • Each kit needs only a single Logseq page and most kits are happy with that.
        • Within a page, multiple code-blocks can be utilized.
      • Bigger kits can benefit from breaking their code to multiple Logseq pages.
        • Synthesis is such a kit, as its base libraries reside in multiple pages.
          • Though Synthesis further modularizes code to individual blocks.
1 Like