Token导航 LogoToken导航TokenDH.com
Logseq AI logo
文档知识未说明官方级别未说明来源级核验

Logseq AI

MCP Server

提供与Logseq知识图谱的AI交互功能,包括外部工具接口和内置插件,支持任务管理、内容创建和查询操作。

工具数

34

提示词数

0

GitHub Stars

0

资源数

0
知识管理TypeScriptClaude开发工具Claude DesktopClaudeWindsurf

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

HarrisonTotty

提供方

HarrisonTotty

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Logseq AI

通过两个接口与Logseq进行AI驱动的交互:

  1. MCP服务器 -允许外部AI工具(Windsurf、Claude Desktop)与您的Logseq图进行交互
  2. 玲音 -Logseq UI中的嵌入式AI助手插件
“无论你去哪里,每个人都是相互联系的。”-莱恩系列实验

先决条件

  • Node.js 18+
  • 启用了HTTP API服务器的Logseq桌面应用程序(设置→ 特性→ HTTP API服务器)

设置

# Install dependencies
pnpm install

# Build all packages
pnpm build

快速开始

使用核心库

import { LogseqClient, LogseqOperations } from "@logseq-ai/core";

// Create client and operations
const client = new LogseqClient({
  baseUrl: "http://localhost:12315",
  token: "your-api-token" // optional
});
const ops = new LogseqOperations(client);

// Search for pages
const results = await ops.search("meeting notes");

// Get page content as text
const content = await ops.getPageContent("My Notes");

// Create a new block
const block = await ops.createBlock({
  pageName: "My Notes",
  content: "New idea from AI!"
});

// Create multiple blocks with hierarchy (more efficient for structured content)
const result = await ops.createBlocks("My Notes", [
  {
    content: "## Project Overview",
    children: [
      { content: "Goal: Build a new feature" },
      { content: "Timeline: Q1 2025" },
    ]
  },
  {
    content: "## Tasks",
    children: [
      { content: "Design the API" },
      { content: "Implement backend" },
      { content: "Write tests" },
    ]
  }
]);
console.log(`Created ${result.created} blocks`);

// Run a Datalog query to find TODOs
const todos = await ops.query(`
  [:find (pull ?b [*])
   :where [?b :block/marker "TODO"]]
`);

任务管理

import { LogseqClient, LogseqOperations } from "@logseq-ai/core";

const client = new LogseqClient();
const ops = new LogseqOperations(client);

// Get all active tasks
const tasks = await ops.getTasks();

// Get tasks from a specific page
const projectTasks = await ops.getTasks({ pageName: "Project A" });

// Create a new task with priority and deadline
const task = await ops.createTask({
  pageName: "Project A",
  content: "Review pull request",
  priority: "A",
  deadline: "2024-12-15"
});

// Mark task as in progress
await ops.markTask(task.uuid, "DOING");

// Complete the task
await ops.markTask(task.uuid, "DONE");

// Set/change priority
await ops.setTaskPriority(task.uuid, "B");

// Set scheduled date
await ops.setTaskScheduled({ uuid: task.uuid, date: "2024-12-10" });

// Remove deadline
await ops.setTaskDeadline({ uuid: task.uuid, date: null });

任务分析

// Get overdue tasks
const overdue = await ops.getOverdueTasks();
console.log(`You have ${overdue.length} overdue tasks`);

// Get tasks due in the next 7 days
const dueSoon = await ops.getTasksDueSoon({ days: 7 });

// Get task statistics
const stats = await ops.getTaskStats();
console.log(`Total: ${stats.total}, Overdue: ${stats.overdue}`);
console.log(`By status:`, stats.byMarker);

// Search tasks by keyword
const reviewTasks = await ops.searchTasks({ query: "review", markers: ["TODO"] });

日志操作

// Get or create today's journal
const today = await ops.getToday();
console.log(`Today's journal: ${today.page.name}`);

// Quick capture to today's journal
await ops.appendToToday("Meeting notes: discussed Q1 roadmap");

// Get recent journal entries
const journals = await ops.getRecentJournals({ days: 7, includeContent: true });
journals.forEach(j => console.log(`${j.date}: ${j.content.substring(0, 50)}...`));

页面链接和反向链接

// Find pages related to a topic
const links = await ops.findRelatedPages("Project A");
console.log("Pages linking to Project A:", links.backlinks);
console.log("Pages Project A links to:", links.forwardLinks);

// Find blocks referencing a specific block
const backlinks = await ops.getBlockBacklinks("block-uuid-123");
console.log(`Found ${backlinks.backlinks.length} references`);

错误处理

import { 
  LogseqOperations, 
  LogseqApiError, 
  LogseqNotFoundError,
  isLogseqError 
} from "@logseq-ai/core";

try {
  await ops.getPageContent("Nonexistent Page");
} catch (error) {
  if (error instanceof LogseqNotFoundError) {
    console.log(`Page not found: ${error.identifier}`);
  } else if (isLogseqError(error)) {
    console.log(`Logseq error: ${error.toDetailedString()}`);
  }
}

包裹

@logseq-ai/core

用于Logseq API交互的共享库。MCP服务器和插件都使用。

主要出口:

  • LogseqClient -Logseq API的低级HTTP客户端
  • LogseqOperations -具有错误处理功能的高级操作
  • 错误类别: LogseqError, LogseqApiError, LogseqConnectionError, LogseqNotFoundError, LogseqValidationError
  • 类型定义: Page, Block, SearchResult等等。

@logseq ai/mcp服务器

MCP服务器,将Logseq操作作为AI客户端的工具公开。

特征:

  • 34个用于全面Logseq交互的工具
  • 带有清晰错误消息的输入验证(由Zod提供支持)
  • Logseq API错误的正确错误处理
# Build
pnpm --filter @logseq-ai/mcp-server build

# Run
LOGSEQ_API_TOKEN=your-token pnpm --filter @logseq-ai/mcp-server start

# Test
pnpm --filter @logseq-ai/mcp-server test

在Windsurf/Claude桌面中配置

添加到MCP配置中:

{
  "mcpServers": {
    "logseq": {
      "command": "node",
      "args": ["/path/to/logseq-ai/packages/mcp-server/dist/index.js"],
      "env": {
        "LOGSEQ_API_URL": "http://localhost:12315",
        "LOGSEQ_API_TOKEN": "your-token"
      }
    }
  }
}

可用工具

页面和块操作

工具说明
search_logseq搜索页面和块
get_page以纯文本形式获取页面内容
get_pages批量获取多个页面(更高效)
get_page_with_context获取带有反向链接和正向链接的页面
list_pages列出图表中的所有页面
create_page创建新页面(可选带块)
delete_page删除页面
create_block创建单个块
create_blocks创建具有层次结构的多个块
update_block更新块的内容
delete_block删除块
query_logseq运行数据日志查询
update_page_properties更新现有页面上的属性

图形发现

工具说明
get_current_graph获取当前图形信息
get_graph_stats获取图表统计信息(按类型、孤立项等分类的页面)
find_missing_pages查找不存在的引用页面
find_orphan_pages查找没有传入链接的页面
find_pages_by_properties按属性值查找页面
find_related_pages查找反向链接和正向链接
get_block_backlinks查找引用块的块

日志操作

工具说明
get_today获取今天的日志页面
append_to_today为今天的日记添加内容
get_recent_journals获取最近的日记条目

任务管理

工具说明
get_tasks获取待办/正在执行的任务
create_task创建新任务
mark_task更改任务状态
mark_tasks更改多个任务的状态(批处理)
search_tasks按关键字搜索任务
get_overdue_tasks获取超过截止日期的任务
get_tasks_due_soon获得N天内到期的任务
get_task_stats获取任务统计信息
set_task_priority设置任务优先级(A/B/C)
set_task_deadline设置任务截止日期
set_task_scheduled设置任务计划日期

示例:创建结构化内容

创建包含多个部分的页面时,请使用 create_blocks 为了提高效率:

User: Create a page about Python with sections for Overview, Features, and Links

AI uses:
1. create_page("Python", "type:: #Technology\ntags:: #Programming")
2. create_blocks("Python", [
     {
       content: "## Overview",
       children: [
         { content: "Python is a high-level programming language." }
       ]
     },
     {
       content: "## Features", 
       children: [
         { content: "Dynamic typing" },
         { content: "Garbage collection" },
         { content: "Large standard library" }
       ]
     },
     {
       content: "## Links",
       children: " }
       ]
     }
   ])

logseq-行

Lain-Logseq的AI助手插件。

# Build
pnpm --filter logseq-lain build

# Development (watch mode)
pnpm dev:plugin

在Logseq中安装

  1. 在Logseq中启用开发人员模式(设置→ 高级→ 开发者模式)
  2. 转到插件→ 加载解压缩的插件
  3. 选择 packages/logseq-plugin 目录
  4. 使用 /lain ask, /lain summarize, /lain expand 斜线命令

建筑

doc/architecture.md 获取详细的架构文档。

发展

# Build everything
pnpm build

# Run all tests (188 tests)
pnpm test

# Type check all packages
pnpm typecheck

# Lint
pnpm lint

许可证

麻省理工学院

目录标签

目录标签

知识管理TypeScriptClaude开发工具本地部署任务自动化AI辅助笔记工具

支持客户端

Claude DesktopClaudeWindsurf

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

34

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP