muckers/mcp-logseq-rust
If you are the rightful owner of mcp-logseq-rust and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Rust implementation of an MCP server for Logseq, enabling AI assistants to interact with Logseq knowledge graphs.
list_graphs
List available Logseq graphs
get_page
Retrieve content of a specific page by name
create_page
Create a new page with optional content
update_block
Update the content of an existing block
append_to_page
Append content to the end of a page
MCP Logseq Server (Rust)
A Rust implementation of an MCP (Model Context Protocol) server for Logseq, enabling AI assistants like Claude to interact with your Logseq knowledge graph through Logseq's Local HTTP API.
Features
Query Operations
- list_graphs: List available Logseq graphs
- list_pages: List all pages in the current graph
- get_page: Retrieve content of a specific page by name
- get_block: Get a specific block by its UUID
- search: Search across all pages in the graph
Write Operations
- create_page: Create a new page with optional content
- update_block: Update the content of an existing block
- insert_block: Insert a new block as child or sibling
- delete_block: Delete a block by its UUID
- append_to_page: Append content to the end of a page
Prerequisites
-
Logseq with HTTP API server enabled:
- Open Logseq
- Go to Settings ā Features
- Toggle on "HTTP APIs server"
- Click the API option in the top menu
- Set up an authorization token
- Enable "Auto start server when Logseq launches"
-
Rust (latest stable version)
Installation
-
Clone this repository:
git clone <repository-url> cd mcp-logseq-rust
-
Copy the example environment file:
cp .env.example .env
-
Edit
.env
and add your Logseq API token:LOGSEQ_API_TOKEN=your-actual-token-here LOGSEQ_API_URL=http://localhost:12315
-
Build the project:
cargo build --release
Usage
Running the Server
cargo run --release
Or use the compiled binary:
./target/release/mcp-logseq-rust
Client Configuration
Claude Desktop
Add the following to your Claude Desktop configuration file:
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"logseq": {
"command": "<PATH-TO>/mcp-logseq-rust",
"args": [],
"env": {
"LOGSEQ_API_TOKEN": "your token here",
"LOGSEQ_API_URL": "http://localhost:12315"
}
}
}
}
AnythingLLM
Add the following to your AnythingLLM MCP servers configuration file:
On macOS: ~/Library/Application Support/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
On Windows: %APPDATA%\anythingllm-desktop\storage\plugins\anythingllm_mcp_servers.json
On Linux: ~/.config/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
{
"mcpServers": {
"logseq": {
"command": "<PATH-TO>/mcp-logseq-rust",
"args": [],
"type": "stdio",
"env": {
"LOGSEQ_API_TOKEN": "your-logseq-api-token-here",
"LOGSEQ_API_URL": "http://localhost:12315"
},
"anythingllm": {
"autoStart": true
}
}
}
}
Replace /path/to/mcp-logseq-rust
with the actual path to your project directory.
Example Usage
Once configured, you can interact with your Logseq graph through Claude Desktop or AnythingLLM:
"Can you show me all pages in my Logseq graph?"
"Search for notes about 'project planning'"
"Create a new page called 'Meeting Notes 2024-01-15'"
"Add a task to my Daily Notes page"
Development
Project Structure
src/
āāā main.rs # Server entry point
āāā config.rs # Configuration handling
āāā logseq_client.rs # HTTP client for Logseq API
āāā models.rs # Data structures
āāā tools/ # MCP tool implementations
āāā mod.rs # Tool definitions
āāā query.rs # Read operations
āāā mutate.rs # Write operations
Debugging
Set the RUST_LOG
environment variable for more detailed logging:
RUST_LOG=debug cargo run
Security Notes
- Keep your Logseq API token secure and never commit it to version control
- The
.env
file is gitignored by default - Consider using environment-specific tokens for different environments
Troubleshooting
"LOGSEQ_API_TOKEN not set" error
Make sure you've created a .env
file with your token or set the environment variable directly.
Connection refused errors
- Ensure Logseq is running
- Verify the HTTP API server is enabled in Logseq settings
- Check that the API URL matches your Logseq configuration (default: http://localhost:12315)
Authentication errors
Double-check that your API token in the .env
file matches the one configured in Logseq.
AnythingLLM Integration Issues
If the MCP server isn't working with AnythingLLM:
-
Check the configuration file location:
- Desktop (Mac):
~/Library/Application Support/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
- Desktop (Windows):
%APPDATA%\anythingllm-desktop\storage\plugins\anythingllm_mcp_servers.json
- Desktop (Linux):
~/.config/anythingllm-desktop/storage/plugins/anythingllm_mcp_servers.json
- Desktop (Mac):
-
Verify the configuration format:
- Ensure
"type": "stdio"
is at the same level as"command"
- Use absolute paths for the command
- See
anythingllm_mcp_servers.example.json
for the correct format
- Ensure
-
Enable debug logging:
- Set
"RUST_LOG": "debug"
in the env section to see detailed logs - Check AnythingLLM's developer console for errors
- Set
-
Common issues:
- Make sure the binary is built in release mode:
cargo build --release
- Ensure the binary has execute permissions:
chmod +x target/release/mcp-logseq-rust
- The server binary must be accessible from AnythingLLM's process
- Make sure the binary is built in release mode:
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.