Agent skill

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.

Stars 3
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/C0ntr0lledCha0s/claude-code-plugin-automations/tree/main/logseq-expert/skills/connecting-to-logseq

SKILL.md

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

Backend Requires Logseq Running Read Write Best For
HTTP API Yes Full Full Real-time, interactive
CLI No Full Limited Offline, batch, CI/CD
MCP Server Yes (via HTTP) Full Full Claude-native tools

Quick Start

1. Enable Logseq HTTP API

In Logseq:

  1. SettingsAdvancedDeveloper mode: ON
  2. SettingsAdvancedHTTP APIs server: ON
  3. SettingsAdvancedAuthorization tokens → Create token

2. Set Environment Variable

bash
export LOGSEQ_API_TOKEN="your-token-here"

3. Initialize Plugin

Run the setup wizard:

bash
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:

json
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:

bash
npm install -g @logseq/cli

Usage:

bash
# 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:

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

Configuration File

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

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:
    bash
    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

Script Purpose
init-environment.py Interactive setup wizard
detect-backend.py Auto-detect available backends
test-connection.py Test connectivity
preflight-checks.sh Validate environment

Run scripts from plugin root:

bash
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

Expand your agent's capabilities with these related and highly-rated skills.

C0ntr0lledCha0s/claude-code-plugin-automations

analyzing-docs

Expert at analyzing documentation quality, coverage, and completeness. Auto-invokes when evaluating documentation health, checking documentation coverage, auditing existing docs, assessing documentation quality metrics, or analyzing how well code is documented. Provides frameworks for measuring documentation effectiveness.

3 0
Explore
C0ntr0lledCha0s/claude-code-plugin-automations

writing-docs

Expert at writing high-quality documentation for code, APIs, and projects. Auto-invokes when generating docstrings, creating README files, writing API documentation, adding code comments, or producing any technical documentation. Provides language-specific templates and best practices for effective documentation writing.

3 0
Explore
C0ntr0lledCha0s/claude-code-plugin-automations

managing-docs

Expert at organizing and managing documentation structure across projects. Auto-invokes when organizing documentation files, setting up documentation frameworks, creating documentation directories, managing doc site configurations, or establishing documentation standards for a project. Provides guidance on documentation architecture and tooling.

3 0
Explore
C0ntr0lledCha0s/claude-code-plugin-automations

Hook Development

This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.

3 0
Explore
C0ntr0lledCha0s/claude-code-plugin-automations

MCP Integration

This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.

3 0
Explore
C0ntr0lledCha0s/claude-code-plugin-automations

Agent Development

This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.

3 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results