remove logseq tool

This commit is contained in:
Ollie Agent 2026-08-16 10:42:05 +02:00
parent 36649367eb
commit e5eab98699
2 changed files with 0 additions and 117 deletions

View File

@ -1,80 +0,0 @@
#!/usr/bin/env python3
"""Logseq tool — queries and modifies Logseq DB graph via the REST API."""
import json
import os
import subprocess
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _lib.args import parse_args
LOGSEQ_URL = os.environ.get("LOGSEQ_MCP_URL", "http://127.0.0.1:12315")
TOKEN = os.environ.get("OLLIE_LOGSEQ_TOKEN", "")
# Map tool commands to REST API methods and argument shapes.
COMMANDS = {
"listPages": ("logseq.cli.listPages", lambda a: [{"expand": a.get("expand", False)}]),
"getPage": ("logseq.cli.getPageData", lambda a: [a["pageName"]]),
"searchBlocks": ("logseq.app.search", lambda a: [a["searchTerm"], {"enable-snippet?": False}]),
"listTags": ("logseq.cli.listTags", lambda a: [{"expand": a.get("expand", False)}]),
"listProperties": ("logseq.cli.listProperties", lambda a: [{"expand": a.get("expand", False)}]),
"upsertNodes": ("logseq.cli.upsertNodes", lambda a: [a["operations"], {"dry-run": a.get("dry-run", False)}]),
"getCurrentGraph":("logseq.app.getCurrentGraph", lambda a: []),
}
def main():
if not TOKEN:
print("Error: OLLIE_LOGSEQ_TOKEN not set", file=sys.stderr)
sys.exit(1)
args = parse_args()
raw = args.raw()
command = args.require("command")
if command not in COMMANDS:
print(f"Error: unknown command '{command}'. Available: {', '.join(sorted(COMMANDS.keys()))}", file=sys.stderr)
sys.exit(1)
method, build_args = COMMANDS[command]
# Remove 'command' from raw args before passing to builder.
params = {k: v for k, v in raw.items() if k != "command"}
try:
api_args = build_args(params)
except KeyError as e:
print(f"Error: missing required argument {e}", file=sys.stderr)
sys.exit(1)
# Build the REST API request.
payload = {"method": method}
if api_args:
payload["args"] = api_args
result = subprocess.run(
["curl", "-s", "-X", "POST",
f"{LOGSEQ_URL}/api",
"-H", f"Authorization: Bearer {TOKEN}",
"-H", "Content-Type: application/json",
"-d", json.dumps(payload)],
capture_output=True, text=True, timeout=30
)
if result.returncode != 0:
print(f"Error: curl failed: {result.stderr}", file=sys.stderr)
sys.exit(1)
# Output the result.
output = result.stdout.strip()
if output:
# Pretty-print JSON if possible.
try:
data = json.loads(output)
print(json.dumps(data, indent=2, ensure_ascii=False))
except json.JSONDecodeError:
print(output)
if __name__ == "__main__":
main()

View File

@ -1,37 +0,0 @@
{
"description": "Query and modify your Logseq knowledge graph via the built-in REST API.",
"prompt": "## logseq\n\nQuery and modify your Logseq DB graph via the built-in REST API.\nRequires `OLLIE_LOGSEQ_TOKEN` env var and Logseq running with API server enabled.\n\n**Args**: `command` (required), plus command-specific parameters.\n\n### Commands\n\n| Command | Args | Description |\n|---------|------|-------------|\n| `getCurrentGraph` | (none) | Get current graph name and path |\n| `listPages` | `expand` (bool, optional) | List all pages; expand=true for detail |\n| `getPage` | `pageName` (required) | Get page content + blocks by name or UUID |\n| `searchBlocks` | `searchTerm` (required) | Full-text search across all blocks |\n| `listTags` | `expand` (bool, optional) | List all tags; expand=true for parents/properties |\n| `listProperties` | `expand` (bool, optional) | List all properties; expand=true for type/cardinality |\n| `upsertNodes` | `operations` (required), `dry-run` (bool, optional) | Batch create/edit pages, blocks, tags, properties |\n\n### Examples\n\n```\nlogseq(command=\"getCurrentGraph\")\nlogseq(command=\"listPages\")\nlogseq(command=\"listPages\", expand=true)\nlogseq(command=\"getPage\", pageName=\"My Page\")\nlogseq(command=\"getPage\", pageName=\"6a6c93e1-xxxx-xxxx-xxxx-xxxxxxxxxxxx\")\nlogseq(command=\"searchBlocks\", searchTerm=\"keyword\")\nlogseq(command=\"listTags\", expand=true)\nlogseq(command=\"listProperties\", expand=true)\nlogseq(command=\"upsertNodes\", operations=[...], dry-run=true)\n```\n\n### upsertNodes operations\n\nEach operation object:\n- `operation`: `\"add\"` or `\"edit\"`\n- `entityType`: `\"block\"`, `\"page\"`, `\"tag\"`, or `\"property\"`\n- `id`: UUID string (required for edit); temp string for add if referenced later\n- `data` object fields:\n - `title`: page/tag/property name or block content\n - `page-id`: page UUID (required when adding a block)\n - `tags`: list of tag UUIDs\n - `property-type`: property type (for property entities)\n - `property-cardinality`: `:one` or `:many`\n - `property-classes`: allowed tags for a property\n - `class-extends`: parent tags\n - `class-properties`: tag's properties\n\nExample — add a block to a page:\n```\nlogseq(command=\"upsertNodes\", operations=[{\"operation\":\"add\",\"entityType\":\"block\",\"id\":null,\"data\":{\"page-id\":\"<page-uuid>\",\"title\":\"New block text\"}}])\n```\n\nExample — create a page and add a block to it:\n```\nlogseq(command=\"upsertNodes\", operations=[{\"operation\":\"add\",\"entityType\":\"page\",\"id\":\"temp-inbox\",\"data\":{\"title\":\"Inbox\"}},{\"operation\":\"add\",\"entityType\":\"block\",\"id\":null,\"data\":{\"page-id\":\"temp-inbox\",\"title\":\"First item\"}}])\n```\n\n- Use `dry-run=true` to validate without committing.\n- Before creating a page/tag/property, check if it exists with `getPage`.\n- Call upsertNodes at most once per request.",
"args": {
"type": "object",
"required": ["command"],
"properties": {
"command": {
"type": "string",
"description": "Logseq API command: getCurrentGraph, listPages, getPage, searchBlocks, listTags, listProperties, upsertNodes"
},
"pageName": {
"type": "string",
"description": "Page name or UUID (for getPage)"
},
"searchTerm": {
"type": "string",
"description": "Search query (for searchBlocks)"
},
"expand": {
"type": "boolean",
"description": "Include additional detail (for listPages, listTags, listProperties)"
},
"operations": {
"type": "array",
"description": "Batch operations array (for upsertNodes)"
},
"dry-run": {
"type": "boolean",
"description": "Validate without committing (for upsertNodes)"
}
},
"additionalProperties": false
},
"tier": "hot",
"scope": "global"
}