logseq-mcp 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +221 -0
  2. package/dist/index.js +8112 -0
  3. package/package.json +42 -0
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # Logseq Agent
2
+
3
+ A powerful Model Context Protocol (MCP) agent for interacting with Logseq, allowing AI assistants like Claude to access and manipulate your Logseq graph with fine-grained control.
4
+
5
+ ## Installation
6
+
7
+ You can install the Logseq Agent via npm:
8
+
9
+ ```bash
10
+ npx logseq-mcp
11
+ ```
12
+
13
+ Or install it globally:
14
+
15
+ ```bash
16
+ npm install -g logseq-mcp
17
+ ```
18
+
19
+ ## Quick Setup
20
+
21
+ 1. **Prerequisites:**
22
+ - Logseq with HTTP API enabled
23
+ - A valid Logseq API token
24
+
25
+ 2. **Configure your environment:**
26
+ Create a `.env` file with:
27
+ ```
28
+ LOGSEQ_PORT=12315
29
+ LOGSEQ_HOST=127.0.0.1
30
+ LOGSEQ_TOKEN=your_logseq_token
31
+ ```
32
+
33
+ 3. **Start the agent:**
34
+ ```bash
35
+ logseq-mcp
36
+ ```
37
+
38
+ ## Setup with Claude Desktop
39
+
40
+ To use the Logseq Agent with Claude Desktop:
41
+
42
+ 1. Open Claude Desktop settings
43
+ 2. Navigate to MCP Servers
44
+ 3. Add a new server with the following configuration:
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "logseq": {
49
+ "command": "npx",
50
+ "args": [
51
+ "logseq-mcp"
52
+ ],
53
+ "env": {
54
+ "LOGSEQ_TOKEN": "your_logseq_token"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+ 4. Save and restart Claude Desktop
61
+ 5. You can now ask Claude to interact with your Logseq graph
62
+
63
+ ## Features
64
+
65
+ ### Block Management
66
+
67
+ - **Get Block**: Retrieve a block by UUID
68
+ - **Create Block**: Create a new block in a page
69
+ - **Update Block**: Update an existing block
70
+ - **Remove Block**: Remove a block by UUID
71
+ - **Get/Set Block Properties**: Manage block properties
72
+ - **Create Nested Blocks**: Create hierarchical block structures
73
+ - **Edit/Select Blocks**: Manipulate blocks in the UI
74
+
75
+ ### Block Navigation & Organization
76
+
77
+ - **Navigate Siblings**: Move between sibling blocks
78
+ - **Move Block**: Reposition blocks within your graph
79
+ - **Collapse/Expand**: Control block visibility
80
+ - **Scroll to Block**: Navigate to specific blocks
81
+ - **Right Sidebar**: Open blocks in the sidebar
82
+
83
+ ### Page Management
84
+
85
+ - **Create Page**: Add new pages to your graph
86
+ - **Get Page**: Retrieve page content by name
87
+ - **Get Current Page**: Access the active page
88
+ - **Get All Pages**: List all pages in your graph
89
+ - **Get Page Blocks**: Access all blocks in a page
90
+ - **Get Linked References**: See all references to a page
91
+
92
+ ### Search & Query
93
+
94
+ - **Query Logseq**: Run powerful Datalog queries
95
+ - **Search Blocks**: Find blocks matching criteria
96
+ - **Get Tasks**: Retrieve and filter task blocks
97
+
98
+ ## Built-in Prompts
99
+
100
+ The agent includes several pre-configured prompt templates:
101
+
102
+ ### Task Management
103
+ - **query-tasks**: Find tasks with specific status (TODO, DOING, etc.)
104
+ - **extract-tasks**: Extract and organize tasks from notes
105
+
106
+ ### Content Creation & Organization
107
+ - **create-daily-note**: Generate a daily note with customizable sections
108
+ - **create-nested-content**: Create structured hierarchical content
109
+ - **summarize-page**: Generate concise summaries of pages
110
+
111
+ ### Knowledge Management
112
+ - **search-knowledge**: Search your knowledge base
113
+ - **organize-blocks**: Organize blocks by specified criteria
114
+ - **organize-blocks-as-nested**: Restructure content hierarchically
115
+ - **convert-flat-to-nested**: Transform flat pages into nested structures
116
+
117
+ ## Usage Examples
118
+
119
+ Here are some examples of how to use the Logseq Agent with Claude:
120
+
121
+ 1. **Create a daily note:**
122
+ ```
123
+ Please create a daily note for today with sections for Tasks, Notes, and Journal.
124
+ ```
125
+
126
+ 2. **Find and organize tasks:**
127
+ ```
128
+ Find all my TODO tasks and organize them by project.
129
+ ```
130
+
131
+ 3. **Search my knowledge base:**
132
+ ```
133
+ Search my notes for information about "machine learning".
134
+ ```
135
+
136
+ 4. **Summarize a page:**
137
+ ```
138
+ Can you summarize my "Project Ideas" page?
139
+ ```
140
+
141
+ 5. **Organize content:**
142
+ ```
143
+ Take my "Research Notes" page and organize it into a proper nested structure.
144
+ ```
145
+
146
+ ## Troubleshooting
147
+
148
+ If you encounter connection issues:
149
+
150
+ 1. **Enable the Logseq HTTP API:**
151
+ - Open Logseq
152
+ - Go to Settings
153
+ - Navigate to 'Advanced'
154
+ - Enable 'Developer mode'
155
+ - Restart Logseq
156
+ - Go to Settings again
157
+ - Find and enable 'HTTP API server'
158
+
159
+ 2. **Check your configuration:**
160
+ - Ensure Logseq is running before starting the agent
161
+ - Verify your LOGSEQ_TOKEN in the .env file
162
+ - Make sure the port isn't blocked by your firewall
163
+
164
+ 3. **Debug mode:**
165
+ Add `DEBUG=true` to your .env file for more detailed logs:
166
+ ```
167
+ DEBUG=true
168
+ LOGSEQ_PORT=12315
169
+ LOGSEQ_HOST=127.0.0.1
170
+ LOGSEQ_TOKEN=your_logseq_token
171
+ ```
172
+
173
+ ## Development
174
+
175
+ ### Running from source
176
+
177
+ 1. Clone the repository:
178
+ ```bash
179
+ git clone https://github.com/yourusername/logseq-mcp.git
180
+ cd logseq-mcp
181
+ ```
182
+
183
+ 2. Install dependencies:
184
+ ```bash
185
+ npm install
186
+ ```
187
+
188
+ 3. Run the agent:
189
+ ```bash
190
+ npm start
191
+ ```
192
+
193
+ ### Testing
194
+
195
+ Run the integration tests with:
196
+ ```bash
197
+ npm test
198
+ ```
199
+
200
+ ## For Developers
201
+
202
+ ### Releasing New Versions
203
+
204
+ To release a new version to npm:
205
+
206
+ 1. Update your code and make sure all tests pass with `bun test`
207
+ 2. Create a new GitHub release with a semantic version tag (e.g., `v1.0.1`)
208
+ 3. The GitHub Action will automatically:
209
+ - Build the package
210
+ - Update the version number from the tag
211
+ - Publish to npm
212
+
213
+ Note: Make sure you have set the `NPM_TOKEN` secret in your GitHub repository settings.
214
+
215
+ ## License
216
+
217
+ MIT
218
+
219
+ ## Contributing
220
+
221
+ Contributions are welcome! Please feel free to submit a Pull Request.