Skip to content
connecting-to-logseq logo

Connecting to Logseq

connecting-to-logseq

Manages connections to Logseq graphs via HTTP API, CLI, or MCP Server. Auto-invokes when users mention connecting to Logseq, API tokens, graph paths, connection issues, or backend configuration. Handles backend detection, environment setup, and connectivity troubleshooting.

SKILL.md

Full skill instructions

Connecting to Logseq

When to Use This Skill

This skill auto-invokes when:

  • User wants to connect Claude to their Logseq graph
  • Setting up Logseq integration or API tokens
  • Troubleshooting connection issues
  • Configuring graph paths or backends
  • User mentions "connect to logseq", "logseq api", "logseq token"
  • Questions about HTTP API, CLI, or MCP server setup

Setup Scripts: See {baseDir}/​scripts/ for initialization utilities.

Available Backends

BackendRequires Logseq RunningReadWriteBest For
HTTP APIYesFullFullReal-time, interactive
CLINoFullLimitedOffline, batch, CI/​CD
MCP ServerYes (via HTTP)FullFullClaude-native tools

Quick Start

1. Enable Logseq HTTP API

In Logseq:

  1. Settings → Advanced → Developer mode: ON
  2. Settings → Advanced → HTTP APIs server: ON
  3. Settings → Advanced → Authorization tokens → Create token

2. Set Environment Variable

export LOGSEQ_API_TOKEN="your-token-here"

3. Initialize Plugin

Run the setup wizard:

python {baseDir}/​scripts/​init-environment.py

Or use the command: /​logseq:init

Backend Details

HTTP API (Primary)

URL: http://127.0.0.1:12315/​api

Request Format:

POST /​api
Content-Type: application/​json
Authorization: Bearer YOUR_TOKEN

{
  "method": "logseq.Editor.getPage",
  "args": ["PageName"]
}

Common Methods:

  • logseq.App.getCurrentGraph - Get current graph info
  • logseq.Editor.getPage - Get page by name
  • logseq.Editor.getBlock - Get block by UUID
  • logseq.DB.datascriptQuery - Execute Datalog query
  • logseq.Editor.insertBlock - Create new block

CLI (@logseq/​cli)

Installation:

npm install -g @logseq/​cli

Usage:

# Query local graph
logseq query "[:find ?title :where [?p :block/​title ?title]]" --graph ~/​logseq/​my-graph

# With running Logseq (in-app mode)
logseq query "..." --in-app -a YOUR_TOKEN

MCP Server

The plugin includes a custom MCP server that exposes Logseq operations as Claude tools.

Location: servers/​logseq-mcp/

Build:

cd servers/​logseq-mcp
npm install
npm run build

Configuration File

Location: .claude/​logseq-expert/​env.json

{
  "backend": "auto",
  "http": {
    "url": "http://127.0.0.1:12315",
    "token": "${LOGSEQ_API_TOKEN}"
  },
  "cli": {
    "graphPath": "/​path/​to/​graph",
    "inApp": false
  },
  "mcp": {
    "enabled": true
  },
  "preferences": {
    "defaultGraph": null,
    "confirmWrites": false,
    "backupBeforeWrite": false
  }
}

Troubleshooting

"Cannot connect to Logseq"

  1. Check Logseq is running with HTTP API enabled
  2. Verify port: Default is 12315, check Settings → Advanced
  3. Check firewall: Ensure localhost:12315 is accessible
  4. Test manually:
    curl -X POST http://127.0.0.1:12315/​api \
      -H "Content-Type: application/​json" \
      -H "Authorization: Bearer YOUR_TOKEN" \
      -d '{"method":"logseq.App.getCurrentGraph"}'
    

"Authentication failed"

  1. Verify token: Check it matches what's in Logseq settings
  2. Token format: Ensure no extra whitespace
  3. Environment variable: Check echo $LOGSEQ_API_TOKEN

"CLI not found"

  1. Install globally: npm install -g @logseq/​cli
  2. Or use npx: npx @logseq/​cli --help
  3. Check PATH: Ensure npm global bin is in PATH

"MCP server not working"

  1. Build server: cd servers/​logseq-mcp && npm run build
  2. Check Node.js: Requires Node 18+
  3. Verify HTTP API: MCP server uses HTTP API internally

Scripts Reference

ScriptPurpose
init-environment.pyInteractive setup wizard
detect-backend.pyAuto-detect available backends
test-connection.pyTest connectivity
preflight-checks.shValidate environment

Run scripts from plugin root:

python logseq-expert/​scripts/​init-environment.py

Security Notes

  • Never commit tokens to version control
  • Use environment variables for sensitive data
  • Token in config supports ${VAR} syntax for env vars
  • HTTP API only listens on localhost by default

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View