Python MCP server for Logseq.
ya-logseq-mcp exposes Logseq read/write tools over MCP stdio so MCP clients can automate page and block workflows.
ya-logseq-mcp is a Python MCP server that exposes Logseq read and write operations as MCP tools, targeting Claude Desktop and any compatible MCP stdio client. It deduplicates blocks by UUID at read time and returns lean responses by default.
| Tool | Description |
|---|---|
health |
Ping Logseq and return graph name and page count |
get_page |
Return a page entity and deduplicated block tree by page name |
get_block |
Get a single block by UUID |
list_pages |
List pages with optional namespace filter |
get_references |
Get backlinks to a page (pages that reference this page) |
page_create |
Create a new page with optional properties and initial blocks |
block_append |
Append blocks to a page; accepts flat strings or nested objects with content, properties, and children |
block_update |
Update block content by UUID |
block_delete |
Delete a block by UUID |
delete_page |
Delete a page by name |
rename_page |
Rename a page from old_name to new_name |
move_block |
Move a block before, after, or as a child of a target block |
journal_today |
Get or create today's journal page and return its block tree |
journal_append |
Append blocks to a journal page for a given date |
journal_range |
Return journal entries for all existing pages between start_date and end_date |
Complete this checklist before install:
- Python 3.12+ is installed:
python3 --version -
uvis installed:uv --version - Logseq Desktop is running with API enabled:
Settings -> Features -> Enable developer mode -> Enable API server -
LOGSEQ_API_TOKENis available from Logseq:Settings -> Features -> API server -> API token
Clone or copy the repo, then run from the repo root:
set -euo pipefail
cd /path/to/ya-logseq-mcp
python3 --version
uv --version
uv syncScript-first launch:
LOGSEQ_API_TOKEN=<token> uv run ya-logseq-mcpModule fallback for troubleshooting only:
LOGSEQ_API_TOKEN=<token> uv run python -m logseq_mcpexpected first-run result:
- Process starts without Python traceback.
- MCP server stays attached to stdio while the client is connected.
healthrequests return{"status":"ok",...}from your MCP client.
Primary example for Claude Desktop (copy/paste-ready):
{
"mcpServers": {
"ya-logseq-mcp": {
"command": "uv",
"args": [
"run",
"--project",
"/path/to/ya-logseq-mcp",
"ya-logseq-mcp"
],
"cwd": "/path/to/ya-logseq-mcp",
"env": {
"LOGSEQ_API_URL": "http://127.0.0.1:12315",
"LOGSEQ_API_TOKEN": "<token>"
}
}
}
}Replace /path/to/ya-logseq-mcp with the absolute path to your cloned repo.
equivalent MCP clients (Cursor, VS Code MCP, custom launchers) should use the same
command, args, cwd, and env shape.
startup semantics: command + args must launch the ya-logseq-mcp entrypoint.
parse validation for this JSON block is included in the verification commands for this plan.
Run checks in this order:
- Unit smoke:
uv run pytest tests/test_server.py -q- MCP stdio integration smoke:
export LOGSEQ_API_TOKEN=<token>
uv run pytest tests/integration/test_mcp_stdio.py -x -q -m integrationPass/fail interpretation:
- PASS: pytest exits
0and reports passing tests. - FAIL: pytest exits non-zero or reports failures/errors.
If smoke fails:
- Re-check token and API availability (
LOGSEQ_API_TOKEN, Logseq API enabled). - Re-run locally with
uv run ya-logseq-mcp --help. - Follow troubleshooting and maintainer checks in
RUNBOOK.md.
Use this when validating docs from a clean environment:
env -i HOME="$HOME" PATH="$PATH" bash -lc '
set -euo pipefail
cd /path/to/ya-logseq-mcp
python3 --version
uv --version
uv sync
test -n "${LOGSEQ_API_TOKEN:-}" || echo "LOGSEQ_API_TOKEN not set in fresh shell"
uv run ya-logseq-mcp --help >/tmp/ya-logseq-mcp-help.txt
'DOCS-01 success markers:
- prereqs visible in output (
python --version,uv --version) - install command succeeds (
uv sync) - startup command reaches ready/no-traceback state (
ya-logseq-mcp --helpexits cleanly)
For maintainers, onboarding accuracy checks live in RUNBOOK.md.