jimsynz/logseq-mcp-server
If you are the rightful owner of logseq-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The LogSeq MCP Server is a Model Context Protocol server that integrates with LogSeq's HTTP API, allowing AI assistants to interact with your LogSeq knowledge graph.
๐๏ธ LogSeq MCP Server
A Model Context Protocol (MCP) server that provides comprehensive access to LogSeq's HTTP API, enabling AI assistants like Claude to interact with your LogSeq knowledge graph. โจ
๐ Overview
This server bridges LogSeq and MCP clients by exposing LogSeq's HTTP API as MCP tools. It allows AI assistants to:
- ๐ Read and create pages and blocks
- ๐ Search your knowledge graph
- ๐๏ธ Execute powerful Datascript queries
- โ๏ธ Access graph metadata and configuration
The server communicates with LogSeq's built-in HTTP API server, which runs locally alongside your LogSeq application. ๐ฅ๏ธ
๐ฆ Installation
Install directly from the Git repository using Cargo:
cargo install --locked --git https://harton.dev/james/logseq-mcp-server.git logseq-mcp-server
๐ ๏ธ Setup
1. ๐ง Enable LogSeq HTTP API
Step-by-Step Instructions:
-
Open LogSeq Settings ๐ฑ
- Launch LogSeq on your computer
- Click the Settings icon (usually in the top-right corner)
-
Navigate to Features ๐๏ธ
- In the Settings menu, find and click on Features
- This opens the features configuration panel
-
Enable HTTP APIs Server ๐
- Look for "HTTP APIs Server" in the features list
- Toggle the switch to enable the HTTP APIs Server
- The server will start automatically once enabled
-
Configure Authorization Token ๐
- After enabling the API server, you need to set up authentication
- Look for "Authorization tokens" section in the API settings
- Click "Add new token"
- Fill in the token details:
- Name:
logseq-mcp-server
(or any descriptive name) - Value: Generate a secure random string (e.g.,
mcp-token-abc123def456
)
- Name:
- Save the token configuration
-
Configure Auto-Start (Recommended) ๐
- In the "Server configurations" section
- Enable "Auto start server with the app launched"
- Click "Save & Apply"
-
Start the Server โถ๏ธ
- If auto-start is not enabled, manually start the server
- Look for "Start Server" button in the API panel
- The server typically runs on
http://localhost:12315
๐ก Pro Tip: Keep your authorization token secure and private. It grants access to your entire LogSeq graph!
2. ๐ Configure Environment Variables
The server requires these environment variables:
export LOGSEQ_API_URL="http://localhost:12315" # Default LogSeq API URL
export LOGSEQ_API_TOKEN="your-api-token-here" # Token from LogSeq settings
3. ๐ค Configure Claude Desktop
Add the server to your claude_desktop_config.json
:
๐ macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
๐ Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"logseq": {
"command": "logseq-mcp-server",
"env": {
"LOGSEQ_API_URL": "http://localhost:12315",
"LOGSEQ_API_TOKEN": "your-api-token-here"
}
}
}
}
4. ๐งช Test Your Connection
Test that the API connection and authentication are working:
logseq-mcp-server --check
If successful, you'll see:
โ Connection successful! Found X pages in LogSeq.
If there are issues, you'll see error messages to help debug the problem.
5. ๐ Restart Claude Desktop
Restart Claude Desktop to load the new server configuration. ๐
๐งฐ Available Tools
The server provides 13 MCP tools organized into these categories:
๐ Page Management
list_pages
๐ - List all pages in your LogSeq graphget_page
๐ - Get specific page information by name or UUIDget_page_content
๐ - Get page content formatted as markdowncreate_page
โ - Create new pages with optional properties (tags, template, alias, etc.)get_current_page
๐๏ธ - Get the currently active page
๐งฑ Block Operations
get_block
๐ฆ - Get specific block by UUIDcreate_block
โ๏ธ - Insert new blocks with positioning optionsupdate_block
๐ - Update the content of an existing blockget_current_block
๐ฏ - Get the currently active block
๐ Search & Query
search
๐ต๏ธ - Search across all pages using LogSeq's built-in searchdatascript_query
๐๏ธ - Execute Datascript queries against the LogSeq database
โ๏ธ Application Info
get_current_graph
๐ - Get information about the current graphget_user_configs
๐ค - Get user configuration settingsget_state_from_store
๐พ - Get application state values (theme, UI settings, etc.)
๐ Example Usage with Claude
Once configured, you can ask Claude to:
"Show me all my pages about machine learning" ๐ค
"Create a new page called 'Project Ideas' with the tag 'brainstorming'" ๐ก
"Search for blocks containing 'TODO' and show me the results" โ
"What's the current theme setting in my LogSeq?" ๐จ
"Execute this Datascript query to find all pages created this week" ๐
๐ฌ Advanced: Datascript Queries
Use the datascript_query
tool for powerful database queries:
# Find all blocks with content
[:find ?e :where [?e :block/content]]
# Find all pages
[:find ?page :where [?page :block/name]]
# Find all TODO/DOING blocks
[:find ?h :where [?h :block/marker]]
# Find blocks referencing a specific page
[:find ?b :where [?b :block/refs ?r] [?r :block/name "Project Ideas"]]
๐ง Troubleshooting
โ ๏ธ Common Issues
- "401 Unauthorized" ๐ซ - Check that your API token is correct
- "Connection refused" ๐ - Ensure LogSeq is running and HTTP API is enabled
- "Method not found" โ - Verify you're using the correct API method names
๐ Logging
The server logs to stderr. To see detailed logs:
RUST_LOG=debug logseq-mcp-server
๐งช Testing with MCP Inspector
You can test the server using the MCP Inspector:
npx @modelcontextprotocol/inspector
Configure it to use logseq-mcp-server
as the command.
๐ Supported LogSeq API Methods
This server exposes the following confirmed working LogSeq HTTP API methods:
- โ
logseq.Editor.getAllPages
- โ
logseq.Editor.getPage
- โ
logseq.Editor.getPageBlocksTree
- โ
logseq.Editor.createPage
- โ
logseq.Editor.getBlock
- โ
logseq.Editor.getCurrentPage
- โ
logseq.Editor.getCurrentBlock
- โ
logseq.Editor.insertBlock
- โ
logseq.Editor.updateBlock
- โ
logseq.DB.datascriptQuery
- โ
logseq.App.getCurrentGraph
- โ
logseq.App.getStateFromStore
- โ
logseq.App.getUserConfigs
๐ค Contributing
This project welcomes contributions! Please feel free to:
- ๐ Report bugs and issues
- ๐ก Suggest new features
- ๐ง Submit pull requests
- ๐ Improve documentation
๐ License
This project is licensed under the MIT License - see the file for details.
๐จโ๐ป Author
James Harton james@harton.nz
๐ Links
- ๐ฆ Repository: https://harton.dev/james/logseq-mcp-server
- ๐๏ธ LogSeq: https://logseq.com/
- ๐ค Model Context Protocol: https://modelcontextprotocol.io/
Github Mirror
This repository is mirrored on Github from it's primary location on my Forgejo instance. Feel free to raise issues and open PRs on Github.