Provides comprehensive tools for interacting with Logseq graphs, enabling AI agents to search for and manage pages and blocks, execute Datalog queries, track tasks and deadlines, and manage journal entries through the Logseq HTTP API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Logseq AIList all my overdue tasks"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Logseq AI
AI-powered interactions with Logseq through two interfaces:
MCP Server - Enables external AI tools (Windsurf, Claude Desktop) to interact with your Logseq graph
Lain - Embedded AI assistant plugin within the Logseq UI
"No matter where you go, everyone's connected." - Serial Experiments Lain
Prerequisites
Node.js 18+
Logseq desktop app with HTTP API server enabled (Settings → Features → HTTP APIs server)
Setup
Quick Start
Using the Core Library
Task Management
Task Analytics
Journal Operations
Page Links & Backlinks
Error Handling
Packages
@logseq-ai/core
Shared library for Logseq API interactions. Used by both the MCP server and plugin.
Key exports:
LogseqClient- Low-level HTTP client for Logseq APILogseqOperations- High-level operations with error handlingError classes:
LogseqError,LogseqApiError,LogseqConnectionError,LogseqNotFoundError,LogseqValidationErrorType definitions:
Page,Block,SearchResult, etc.
@logseq-ai/mcp-server
MCP server that exposes Logseq operations as tools for AI clients.
Features:
34 tools for comprehensive Logseq interaction
Input validation with clear error messages (powered by Zod)
Proper error handling for Logseq API errors
Configure in Windsurf/Claude Desktop
Add to your MCP configuration:
Available Tools
Page & Block Operations
Tool | Description |
| Search for pages and blocks |
| Get page content as plain text |
| Get multiple pages in a batch (more efficient) |
| Get page with backlinks and forward links |
| List all pages in the graph |
| Create a new page (optionally with blocks) |
| Delete a page |
| Create a single block |
| Create multiple blocks with hierarchy |
| Update a block's content |
| Delete a block |
| Run Datalog queries |
| Update properties on an existing page |
Graph Discovery
Tool | Description |
| Get current graph info |
| Get graph statistics (pages by type, orphans, etc.) |
| Find referenced pages that don't exist |
| Find pages with no incoming links |
| Find pages by property values |
| Find backlinks and forward links |
| Find blocks referencing a block |
Journal Operations
Tool | Description |
| Get today's journal page |
| Add content to today's journal |
| Get recent journal entries |
Task Management
Tool | Description |
| Get TODO/DOING tasks |
| Create a new task |
| Change task status |
| Change multiple tasks' status (batch) |
| Search tasks by keyword |
| Get tasks past deadline |
| Get tasks due within N days |
| Get task statistics |
| Set task priority (A/B/C) |
| Set task deadline |
| Set task scheduled date |
Example: Creating Structured Content
When creating pages with multiple sections, use create_blocks for efficiency:
logseq-lain
Lain - AI assistant plugin for Logseq.
Install in Logseq
Enable Developer Mode in Logseq (Settings → Advanced → Developer mode)
Go to Plugins → Load unpacked plugin
Select the
packages/logseq-plugindirectoryUse
/lain ask,/lain summarize,/lain expandslash commands
Architecture
See doc/architecture.md for detailed architecture documentation.
Development
License
MIT