Skip to main content

MCP server to work with LogSeq via the local HTTP server

Project description

MCP server for LogSeq

MCP server to interact with LogSeq via its API. Enables Claude to read, create, and manage LogSeq pages through a comprehensive set of tools.

Prerequisites

LogSeq Setup

  1. Install LogSeq if not already installed
  2. Enable HTTP APIs server in LogSeq:
    • Go to Settings → Features
    • Check "Enable HTTP APIs server"
  3. Start the API server:
    • Look for the API button (🔌) in the main LogSeq interface
    • Click it to open the API control panel
    • Click "Start server" to start the HTTP API server at http://localhost:12315
  4. Generate API token:
    • In the API control panel, click "Authorization tokens"
    • Create a new token (e.g., name it "logseq" or "claude")
    • Copy the generated token for use in configuration

System Requirements

  • Python 3.11 or higher
  • LogSeq running with HTTP API enabled
  • An MCP client (instructions provided for Claude Code and Claude Desktop)

Installation

This MCP server works with any MCP-compatible client. Below are setup instructions for the most common clients:

Claude Code

# Install the package
pip install mcp-logseq

# Add to Claude Code
claude mcp add mcp-logseq \
  --env LOGSEQ_API_TOKEN=your_token_here \
  --env LOGSEQ_API_URL=http://localhost:12315 \
  -- mcp-logseq

Claude Desktop

  1. Install the package:
pip install mcp-logseq
  1. Open Claude Desktop configuration:

    • macOS: Claude Desktop → Settings → Developer → "Edit Config"
    • Windows: Navigate to %APPDATA%\Claude\claude_desktop_config.json
  2. Add server configuration:

{
  "mcpServers": {
    "mcp-logseq": {
      "command": "mcp-logseq",
      "env": {
        "LOGSEQ_API_TOKEN": "your_token_here",
        "LOGSEQ_API_URL": "http://localhost:12315"
      }
    }
  }
}
  1. Restart Claude Desktop for changes to take effect

Other MCP Clients

For other MCP clients, use the server command mcp-logseq with these environment variables:

  • LOGSEQ_API_TOKEN: Your LogSeq API token
  • LOGSEQ_API_URL: LogSeq server URL (default: http://localhost:12315)

Installation Verification

Test LogSeq API connectivity

python -c "
from mcp_logseq.logseq import LogSeq
api = LogSeq(api_key='your_token')
result = api.list_pages()
print(f'Connected! Found {len(result)} pages')
"

Verify MCP server registration

# For Claude Code
claude mcp list

# Should show mcp-logseq in the list

Test with MCP Inspector (for debugging)

npx @modelcontextprotocol/inspector mcp-logseq

Tools

The server implements 6 tools to interact with LogSeq:

  • create_page: Create a new page with content
  • list_pages: List all pages in the current graph (with journal filtering)
  • get_page_content: Retrieve content of a specific page (text or JSON format)
  • delete_page: Remove a page from the graph
  • update_page: Update existing page content and/or properties
  • search: Search for content across pages, blocks, and files

Example prompts

It's good to first instruct Claude to use LogSeq. Then it will always call the tool.

Example prompts:

  • Get the contents of my latest meeting notes and summarize them
  • Search for all pages where Project X is mentioned and explain the context
  • Create a new page with today's meeting notes
  • Update the project status page with the latest updates

Configuration

Environment Variables

  • LOGSEQ_API_TOKEN (required): Bearer token from LogSeq API control panel → Authorization tokens
  • LOGSEQ_API_URL (optional): LogSeq server URL (default: http://localhost:12315)

Alternative Configuration Methods

Using .env file

Create a .env file in the project directory:

LOGSEQ_API_TOKEN=your_token_here
LOGSEQ_API_URL=http://localhost:12315

Using system environment variables

export LOGSEQ_API_TOKEN=your_token_here
export LOGSEQ_API_URL=http://localhost:12315

Troubleshooting

Common Issues

"LOGSEQ_API_TOKEN environment variable required"

  • Ensure LogSeq HTTP API is enabled in Settings → Features
  • Start the API server using the API button (🔌) in LogSeq's main interface
  • Generate and copy the API token from "Authorization tokens" in the API control panel
  • Verify token is correctly set in your configuration

Connection errors to LogSeq

  • Confirm LogSeq is running
  • Check that HTTP API server is enabled in Settings → Features
  • Important: Make sure the API server is actually started (click "Start server" in the API control panel)
  • Verify the server is running on port 12315
  • Test connectivity with the verification command above

MCP server not found in Claude Code

  • Run claude mcp list to check if server is registered
  • Verify the command and arguments in your configuration
  • Check that uv and Python dependencies are properly installed

Empty or missing page content

  • Some LogSeq versions may not support all API methods
  • Check LogSeq logs for API errors
  • Verify page names match exactly (case-sensitive)

Development

For local development, testing, and contributing to this project, see DEVELOPMENT.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_logseq-1.0.0.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_logseq-1.0.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_logseq-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_logseq-1.0.0.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for mcp_logseq-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2c31b89b3bbab878a97f325f6688fa80734c3246c03e667f9c25d22cd6b0b59e
MD5 203b1fee8205b1e8f217e99a3ea8076d
BLAKE2b-256 9f6e01c264b51cb4a188cceaa2a1d67625c14514b15e5ec6419fcec0625bc228

See more details on using hashes here.

File details

Details for the file mcp_logseq-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_logseq-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for mcp_logseq-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 571d0e0c9e1780ccf62bc0b57706fc044ca8160be9fa6f10b5042dba17868e24
MD5 de251357e7e3b96eb87180c1df9b6a2a
BLAKE2b-256 253c7af8c0e034bf941a0ce2602392007ab22ccbb7bff201333b43fda5161f47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page