home / mcp / logseq mcp server
Exposes Logseq operations over MCP so external AI tools can read, query, and modify your graph.
Configuration
View docs{
"mcpServers": {
"harrisontotty-logseq-ai": {
"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"
}
}
}
}You can extend Logseq with external AI tools by running an MCP server that exposes Logseq operations to AI clients and provides an embedded assistant interface. This server makes it easy to search, edit, and analyze your Logseq graph from other AI tools while keeping your data local to your environment.
You will run the MCP server locally and connect your MCP clients (for example Windsurf or Claude Desktop) to it. The server presents a set of tools that let you search pages, read and modify blocks, manage tasks, capture journal entries, and analyze your data. Two interfaces are available: the MCP server itself for external AI clients, and Lain, an embedded AI assistant you can use inside Logseq.
Prerequisites are required before you start. You need Node.js version 18 or newer and a Logseq desktop app with the HTTP API server enabled (Settings → Features → HTTP APIs server). Then install dependencies, build, and run the MCP server.
# Install dependencies
pnpm install
# Build all packages
pnpm buildThe MCP server can be started with a token for API access. When using Windsurf or Claude Desktop, you typically provide an API URL and a token to authorize requests. Below is an example configuration you would use in the MCP client integration. Replace YOUR_API_TOKEN with your actual token.
{
"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"
}
}
}
}Build and start the MCP server, then test basic operations such as listing pages, creating blocks, or querying the graph. The server exposes a rich set of tools to perform these actions from your external AI clients.
# Build (if not already built)
pnpm --filter @logseq-ai/mcp-server build
# Run (provide your API token)
LOGSEQ_API_TOKEN=your-token pnpm --filter @logseq-ai/mcp-server startSearch across pages and blocks to find relevant content within your Logseq graph.
Retrieve a page's content as plain text for processing in external tools.
Fetch multiple pages in a single call to improve efficiency when gathering data.
Get a page along with its backlinks and forward links to understand context.
List all pages in the graph for discovery and navigation.
Create a new page, optionally with an initial block structure.
Delete a specified page from the graph.
Create a single block within a page.
Create multiple blocks with hierarchical structure for efficiency.
Update an existing block's content.
Delete a specific block.
Run a Datalog query against the graph to extract structured data.
Update metadata or properties on an existing page.
Retrieve high-level information about the current graph.
Obtain statistics about the graph, such as pages by type and orphaned pages.
Identify pages that are referenced but do not exist.
Find pages with no incoming links.
Find pages that match specific property values.
Discover backlinks and forward links related to a topic.
Find blocks that reference a specific block.
Get today’s journal page or create it if missing.
Append content to today’s journal entry.
Retrieve recent journal entries with optional content.
Retrieve the current TODO/DOING tasks across the graph.
Create a new task with content and optional metadata like priority and deadline.
Change the status of a single task.
Change the status of multiple tasks in a single operation.
Search tasks by keyword and optional markers.
Get tasks that are overdue.
Get tasks due within a given number of days.
Retrieve statistics about tasks, including totals and by status.
Set or change a task's priority.
Set or remove a task deadline.
Set or update the scheduled date for a task.