Logseq MCP Tools

Logseq MCP 工具
该项目提供了一组模型上下文协议 (MCP) 工具,使 AI 代理能够与您的本地 Logseq 实例进行交互。
安装
确保已安装 Python 3.11+
克隆此存储库
安装依赖项:
pip install -e .
Related MCP server: Logseq MCP Tools
设置
确保您的 Logseq 已启用 API。
在 Logseq 中,转到“设置”>“高级”>“开发者模式”>“启用开发者模式”
然后,转到插件> 打开 Logseq 开发人员插件
还可以在高级设置中设置 API 令牌
重启 Logseq
在您的 Cursor MCP 配置文件中配置 MCP 服务器(通常位于
~/.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" } } } }
或者
配置 Claude Code 以使用 MCP 服务器:
claude mcp add选择范围
选择 Stdio
LOGSEQ_API_URL=http://localhost:12315 LOGSEQ_TOKEN=your-token-here /opt/homebrew/bin/uvx logseq-mcp
与 Cursor 和 Claude 一起使用
添加 Cursor 的 MCP 工具
按照上面的设置部分所示配置 MCP 服务器
打开 Cursor 并转到 MCP 面板(侧边栏)
Logseq 工具应该出现在可用工具列表中
与 Claude 一起使用
在 Cursor 中使用 Claude 时,您需要告知它您有可用的 Logseq 工具,提示类似于:
您可以使用 Logseq 工具来与我的 Logseq 图表进行交互。您可以使用 logseq.get_all_pages()、logseq.get_page(name)、logseq.create_page(name) 等函数。
可用工具
所有工具均可在logseq命名空间下使用:
页面
logseq.get_all_pages:获取 Logseq 图中所有页面的列表logseq.get_page:按名称获取特定页面logseq.create_page:创建新页面logseq.delete_page:删除页面及其所有块
区块
logseq.get_page_blocks:获取特定页面的所有块logseq.get_block:通过 ID 获取特定块logseq.create_block:在页面上创建一个新块logseq.insert_block:将一个块作为另一个块的子块插入logseq.update_block:更新现有块logseq.move_block:将块移动到其他位置logseq.remove_block:删除一个块及其所有子块logseq.search_blocks:搜索与查询匹配的块
使用 Logseq
期刊页面
Logseq 中的日志页面具有特定的格式和属性:
创建或访问日记页面时,请使用“mmm dth, yyyy”格式(例如“2025 年 4 月 4 日”)
期刊页面由 Logseq 自动格式化,并注明正确的日期
日志页面具有由 Logseq 自动设置的特殊属性:
journal?:true - 表示这是日志页面journalDay:YYYYMMDD - 数字格式的日期(例如,20250404 表示 2025 年 4 月 4 日)
例如:
await logseq.create_page("Apr 4th, 2025")
**重要提示:**您无需手动设置journal?或journalDay属性。只需创建一个具有正确日期格式(例如“2025 年 4 月 4 日”)的页面,即可自动将其配置为具有相应属性的日记页面。
块结构和格式
Logseq 中的块具有一些需要理解的重要特征:
自动项目符号:所有块都会在 Logseq UI 中自动呈现为项目符号
页面链接:使用双括号创建链接:
[[Page Name]]层次块:
区块结构数据包含层次信息:
parent:父块的 IDlevel:缩进级别(1 为顶层,2+ 为缩进块)left:左侧的块(通常是缩进块的父块)
块内容:创建块时,您可以包含文本格式:
支持基本 Markdown(粗体、斜体等)
区块内的要点可能支持有限
支持多行内容,但可能需要遵守 Logseq 的解析规则
日记块:在日记页面中创建的块继承了特殊属性:
journal?:是的journalDay:YYYYMMDD - 与日记页面相同
**注意:**与日记页面一样,这些区块属性由 Logseq 自动处理。在日记页面上创建区块时,您无需手动设置journal?或journalDay属性。
常见任务的示例用法
**使用 Cursor 代理:**当您在 Cursor 中配置了 Logseq MCP 工具时,您可以向代理发出如下提示:
“创建一个名为‘会议记录’的新页面,其中包含今日议程的要点”
“将今天的任务添加到我的日记页面的‘任务’部分”
“使用[[项目计划]]更新今天的日记条目,并将其子元素设置为‘已完成里程碑 1’”
“在我的图表中搜索关于‘python 项目’的块,并将它们组织到新页面上”
代理将使用适当的 Logseq 工具在您的图表上执行这些操作。
Available Tools
13 toolscreate_blockA
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.
Inputs: page_name (required), content (required), properties.
create_pageA
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.
Inputs: name (required), properties.
delete_pageA
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.
Inputs: name (required).
get_all_pagesA
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.
Inputs: no named parameters.
get_blockA
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.
Inputs: block_id (required).
get_pageA
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.
Inputs: name (required).
get_page_blocksA
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.
Inputs: page_name (required).
get_page_linked_referencesA
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.
Inputs: page_name (required).
insert_blockA
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.
Inputs: parent_block_id (required), content (required), properties, before.
move_blockA
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.
Inputs: block_id (required), target_block_id (required), as_child.
remove_blockA
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.
Inputs: block_id (required).
search_blocksA
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.
Inputs: query (required).
update_blockA
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.
Inputs: block_id (required), content (required), properties.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool has a clearly distinct purpose with no overlap. For example, create_block and insert_block serve different functions (creating a block on a page vs. inserting a block as a child), and get_page_blocks and search_blocks target different retrieval methods. The descriptions reinforce these distinctions, making misselection unlikely.
All tool names follow a consistent verb_noun pattern with snake_case, such as create_block, get_page, and update_block. This uniformity makes the tool set predictable and easy to navigate, with no deviations in naming conventions.
With 13 tools, the set is well-scoped for managing a Logseq graph, covering essential operations like CRUD for pages and blocks, hierarchical manipulation, and search. Each tool serves a clear purpose without redundancy, making the count appropriate for the domain.
The tool set provides comprehensive coverage for Logseq graph management, including full CRUD for pages and blocks, hierarchical operations (move_block, insert_block), retrieval methods (get_all_pages, search_blocks), and advanced features like linked references. There are no obvious gaps that would hinder agent workflows.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- AlicenseBqualityBmaintenanceA server that enables LLMs to programmatically interact with Logseq knowledge graphs, allowing creation and management of pages and blocks.1050 PyPI47MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides AI assistants with structured access to your Logseq knowledge graph, enabling retrieval, searching, analysis, and creation of content within your personal knowledge base.70MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that enables AI agents to interact with local Logseq knowledge graphs, supporting operations like creating/editing pages and blocks, searching content, and managing journal entries.1315MIT
- AlicenseNot gradedqualityBmaintenanceA Model Context Protocol (MCP) server implementation that enables AI assistants to interact with Anytype's API through natural language, allowing users to manage their knowledge base through conversation.71,433 npm544MIT