Logseq MCP server

Enables AI interaction with Logseq knowledge graphs for capturing notes, organizing information, and retrieving knowledge from personal databases
Back to servers
Provider
apw124
Release date
Apr 08, 2025
Language
Python
Package
Stats
1.1K downloads
7 stars

Logseq MCP Tools provides a set of Model Context Protocol (MCP) tools that enable AI agents to interact with your local Logseq instance. These tools allow you to programmatically access and manipulate your Logseq graph, including creating and managing pages, blocks, and journal entries.

Installation Requirements

To get started with Logseq MCP Tools, you'll need:

  • Python 3.11 or newer
  • A working Logseq installation with API access enabled

Installation Steps

  1. Clone the repository to your local machine
  2. Install the package using pip:
pip install -e .

Setting Up Logseq API Access

Before using the MCP tools, you must enable API access in Logseq:

  1. Open Logseq and navigate to Settings > Advanced
  2. Enable Developer mode
  3. Go to Plugins and turn on the Logseq Developer Plugin
  4. Set an API token in the Advanced settings
  5. Restart Logseq

Configuring the MCP Server

Option 1: Configure with Cursor MCP

Add the following to 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"
      }
    }
  }
}

Option 2: Configure with Claude Code

Use the following command to set up the MCP server with Claude Code:

claude mcp add

When prompted:

  • Select the appropriate scope
  • Select Stdio
  • Enter: LOGSEQ_API_URL=http://localhost:12315 LOGSEQ_TOKEN=your-token-here /opt/homebrew/bin/uvx logseq-mcp

Using with AI Tools

Using with Cursor

  1. After configuring the MCP server as shown above
  2. Open Cursor and go to the MCP panel in the sidebar
  3. The Logseq tool should appear in your list of available tools

Using with Claude

When using Claude in Cursor, inform it about the available Logseq tools with a prompt like:

"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 Reference

All tools are accessible under the logseq namespace:

Page Management

  • logseq.get_all_pages: Retrieve a list of all pages in the Logseq graph
  • logseq.get_page: Get a specific page by name
  • logseq.create_page: Create a new page
  • logseq.delete_page: Delete a page and all its blocks

Block Operations

  • logseq.get_page_blocks: Get all blocks from a specific page
  • logseq.get_block: Retrieve a specific block by ID
  • logseq.create_block: Create a new block on a page
  • logseq.insert_block: Insert a block as a child of another block
  • logseq.update_block: Update content of an existing block
  • logseq.move_block: Move a block to a different location
  • logseq.remove_block: Remove a block and all its children
  • logseq.search_blocks: Search for blocks matching a query

Working with Journal Pages

Journal pages in Logseq have special formatting:

  • Use the format "mmm dth, yyyy" (e.g., "Apr 4th, 2025") when creating or accessing them
  • Journal pages are automatically configured by Logseq with proper dating
  • Example usage: await logseq.create_page("Apr 4th, 2025")

Block Structure and Formatting

When working with blocks, keep in mind:

  • All blocks are automatically rendered as bullet points in the Logseq UI
  • Create page links using double brackets: [[Page Name]]
  • Blocks support basic Markdown formatting (bold, italic, etc.)
  • Blocks have hierarchical relationships including parent, level, and left properties

Example Usage Scenarios

With 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.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later