Logseq MCP Tools
A Model Context Protocol server that enables AI agents to interact with a local Logseq instance, allowing operations like creating pages, managing blocks, and searching across a knowledge graph.
Tools
get_all_pages
Gets all pages from the Logseq graph. Journal pages can be identified by the "journal?" attribute set to true and will include a "journalDay" attribute in the format YYYYMMDD. Returns: list: A list of all pages in the Logseq graph.
get_page
Gets a specific page from the Logseq graph by name. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Note that journal pages are automatically created in Logseq with this date format. Journal pages have specific attributes: - "journal?": true - Indicates this is a journal page - "journalDay": YYYYMMDD - The date in numeric format (e.g., 20250404 for April 4, 2025) Args: name (str): The name of the page to retrieve. Returns: dict: Information about the requested page.
create_page
Creates a new page in the Logseq graph. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Journal pages are specially formatted in Logseq with automatic dating. When you create a journal page, Logseq automatically: - Sets "journal?": true - Sets "journalDay": YYYYMMDD (e.g., 20250404 for April 4, 2025) - Formats the page as a journal entry Args: name (str): The name of the new page. properties (dict, optional): Properties to set on the new page. Returns: dict: Information about the created page.
delete_page
Deletes a page from the Logseq graph. This operation removes the specified page and all its blocks. This action cannot be undone. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Args: name (str): The name of the page to delete. Returns: dict: Result of the deletion operation.
get_page_linked_references
Gets all linked references to a specific page in the Logseq graph. This returns blocks that contain links to the specified page using the Logseq double bracket notation: [[Page Name]]. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Args: page_name (str): The name of the page to find references to. Returns: list: A list of blocks that reference the specified page.
get_page_blocks
Gets all blocks from a specific page in the Logseq graph. For journal pages, use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025"). Returned blocks contain information about their hierarchical structure: - parent: The parent block's ID - level: The indentation level (1 for top-level, 2+ for indented blocks) - left: The block to the left (typically the parent for indented blocks) Blocks from journal pages will have: - "journal?": true - "journalDay": YYYYMMDD - The date in numeric format (e.g., 20250404) Args: page_name (str): The name of the page to retrieve blocks from. Returns: list: A list of blocks from the specified page.
get_block
Gets a specific block from the Logseq graph by its ID. The returned block contains information about its hierarchical structure: - parent: The parent block's ID - level: The indentation level (1 for top-level, 2+ for indented blocks) - left: The block to the left (typically the parent for indented blocks) If the block is from a journal page, it will include: - "journal?": true - "journalDay": YYYYMMDD - Date in numeric format Args: block_id (str): The ID of the block to retrieve. Returns: dict: Information about the requested block.
create_block
Creates a new block on a page in the Logseq graph. IMPORTANT NOTES: 1. All blocks are automatically formatted as bullet points in Logseq UI 2. To create links to other pages, use double brackets: [[Page Name]] When creating blocks on journal pages: - The block will inherit the "journal?" and "journalDay" attributes from the page - "journalDay" will be in YYYYMMDD format (e.g., 20250404 for April 4, 2025) Args: page_name (str): The name of the page to create the block on. content (str): The content of the new block. properties (dict, optional): Properties to set on the new block. Returns: dict: Information about the created block.
insert_block
Inserts a new block as a child of the specified parent block. This allows for creating hierarchical content by adding children to existing blocks. IMPORTANT NOTES: 1. All blocks are automatically formatted as bullet points in Logseq UI 2. To create links to other pages, use double brackets: [[Page Name]] 3. The new block will be inserted at the beginning or end of the parent's children depending on the 'before' parameter When inserting blocks into journal pages: - The block will inherit the "journal?" and "journalDay" attributes - "journalDay" will be in YYYYMMDD format (e.g., 20250404 for April 4, 2025) Args: parent_block_id (str): The ID of the parent block to insert under. content (str): The content of the new block. properties (dict, optional): Properties to set on the new block. before (bool, optional): Whether to insert at the beginning of children. Default is False (append at the end). Returns: dict: Information about the created block.
update_block
Updates an existing block in the Logseq graph. IMPORTANT NOTES: 1. All blocks are automatically formatted as bullet points in Logseq UI 2. To create links to other pages, use double brackets: [[Page Name]] When updating blocks on journal pages: - The "journal?" and "journalDay" attributes will be preserved - "journalDay" will remain in YYYYMMDD format (e.g., 20250404) Args: block_id (str): The ID of the block to update. content (str): The new content for the block. properties (dict, optional): Properties to update on the block. Returns: dict: Information about the updated block.
move_block
Moves a block to a new location in the graph. This allows for reorganizing the structure of blocks in the graph by moving a block (and all its children) to a different location. IMPORTANT NOTES: 1. The block will maintain its children when moved 2. The hierarchical position depends on the 'as_child' parameter: - If as_child=True: The block becomes a child of the target block - If as_child=False: The block becomes a sibling after the target block Args: block_id (str): The ID of the block to move. target_block_id (str): The ID of the target block to move to. as_child (bool, optional): Whether to make the block a child of the target. Default is False (insert as sibling). Returns: dict: Result of the move operation.
remove_block
Removes a block from the Logseq graph. This operation permanently removes the specified block and all its children. This action cannot be undone. To remove a block, you need its block ID, which can be obtained from: - get_page_blocks() function - get_block() function - search_blocks() function Args: block_id (str): The ID of the block to remove. Returns: dict: Result of the removal operation.
search_blocks
Searches for blocks matching a query in the Logseq graph. Examples of useful queries: - page:"Page Name" - find all blocks on a specific page - "search term" - find blocks containing the term - page:"Apr 4th, 2025" - find all blocks in a journal - [[Page Name]] - find references to a specific page Returned blocks from journal pages will include: - "journal?": true - "journalDay": YYYYMMDD - The date in numeric format Args: query (str): The search query. Returns: list: A list of blocks matching the search query.
README
<p align="center"><em>Hosted by Modl, any commits or changes made by the Modl team is to ensure compatibility</em></p>
Logseq MCP Tools
This project provides a set of Model Context Protocol (MCP) tools that enable AI agents to interact with your local Logseq instance.
Installation
- Ensure you have Python 3.11+ installed
- Clone this repository
- Install dependencies:
pip install -e .
Setup
-
Make sure your Logseq has the API enabled.
- In Logseq, go to Settings > Advanced > Developer mode > Enable Developer mode
- Then, go to Plugins > Turn on Logseq Developer Plugin
- Also set an API token in the Advanced settings
- Restart Logseq
-
Configure the MCP server in your Cursor MCP configuration file (typically at
~/.cursor/mcp.json):{ "mcpServers": { "logseq": { "command": "/opt/homebrew/bin/uvx", "args": ["logseq-mcp"], "env": { "LOGSEQ_API_URL": "http://localhost:12315", "LOGSEQ_TOKEN": "your-token-here" } } } }
OR
- Configure Claude Code to use the MCP server with:
claude mcp add
- Select scope
- Select Stdio
LOGSEQ_API_URL=http://localhost:12315 LOGSEQ_TOKEN=your-token-here /opt/homebrew/bin/uvx logseq-mcp
Using with Cursor and Claude
Adding to Cursor's MCP Tools
-
Configure the MCP server as shown above in the Setup section
-
Open Cursor and go to the MCP panel (sidebar)
-
The Logseq tool should appear in your list of available tools
Using with Claude
When using Claude in Cursor, you'll need to inform it that you have Logseq tools available with a prompt similar to:
"You have access to Logseq tools that can help you interact with my Logseq graph. You can use functions like logseq.get_all_pages(), logseq.get_page(name), logseq.create_page(name), etc."
Available Tools
All tools are available under the logseq namespace:
Pages
logseq.get_all_pages: Get a list of all pages in the Logseq graphlogseq.get_page: Get a specific page by namelogseq.create_page: Create a new pagelogseq.delete_page: Delete a page and all its blocks
Blocks
logseq.get_page_blocks: Get all blocks from a specific pagelogseq.get_block: Get a specific block by IDlogseq.create_block: Create a new block on a pagelogseq.insert_block: Insert a block as a child of another blocklogseq.update_block: Update an existing blocklogseq.move_block: Move a block to a different locationlogseq.remove_block: Remove a block and all its childrenlogseq.search_blocks: Search for blocks matching a query
Working with Logseq
Journal Pages
Journal pages in Logseq have a specific format and attributes:
- Use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025") when creating or accessing journal pages
- Journal pages are automatically formatted by Logseq with proper dating
- Journal pages have special attributes that are automatically set by Logseq:
journal?: true - Indicates this is a journal pagejournalDay: YYYYMMDD - The date in numeric format (e.g., 20250404 for April 4, 2025)
- Example:
await logseq.create_page("Apr 4th, 2025")
Important: You do not need to manually set the journal? or journalDay attributes. Simply creating a page with the proper date format (e.g., "Apr 4th, 2025") will automatically configure it as a journal page with the appropriate attributes.
Block Structure and Formatting
Blocks in Logseq have some important characteristics to understand:
-
Automatic Bullets: All blocks are automatically rendered as bullet points in the Logseq UI
-
Page Links: Create links using double brackets:
[[Page Name]] -
Hierarchical Blocks:
- Block structure data contains hierarchical information:
parent: The parent block's IDlevel: The indentation level (1 for top-level, 2+ for indented blocks)left: The block to the left (typically the parent for indented blocks)
- Block structure data contains hierarchical information:
-
Block Content: When creating blocks, you can include text formatting:
- Basic Markdown is supported (bold, italic, etc.)
- Bullet points within a block may have limited support
- Multi-line content is supported but may be subject to Logseq's parsing rules
-
Journal Blocks: Blocks created in journal pages inherit special attributes:
journal?: truejournalDay: YYYYMMDD - Same as the journal page
Note: Like journal pages, these block attributes are automatically handled by Logseq. You don't need to manually set the journal? or journalDay attributes when creating blocks on journal pages.
Example Usage for Common Tasks
Working with the Cursor agent: When you have Logseq MCP tools configured in Cursor, you can give the agent prompts like:
- "Create a new page called 'Meeting Notes' with bullet points for today's agenda"
- "Add today's tasks to my journal page with a 'Tasks' section"
- "Update today's journal entry with [[Project Plan]], set its child element to 'Completed milestone 1'"
- "Search my graph for blocks about 'python projects' and organize them on a new page"
The agent will use the appropriate Logseq tools to carry out these operations on your graph.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。