Skip to content

MCP Server

Lokus ships with a built-in Model Context Protocol (MCP) server that lets AI assistants read, write, search, and manage your entire knowledge base. The server auto-starts with Lokus and provides 67 tools across 12 categories — notes, workspace, databases, canvas, kanban, graph, templates, themes, daily notes, tasks, search, and workspace context.

MCP is an open standard that gives AI assistants structured access to external tools and data. Instead of copying and pasting content into your AI chat, MCP lets the assistant directly interact with your workspace.

Without MCP: You paste note content into the chat manually. The AI has no context about your workspace structure, links, or other files.

With MCP: The AI can search your entire knowledge base, create and edit notes, traverse your knowledge graph, manage kanban boards, and run workspace maintenance — all through natural language.

AI Assistant (Claude, etc.)
|
| MCP Protocol (JSON-RPC)
|
Lokus MCP Server
├── Stdio Transport (desktop clients)
└── HTTP Transport (CLI clients, port 3456)
|
| Tool Router (67 tools)
|
Your Workspace (local Markdown files)

The server supports two transports:

  • Stdio — for desktop AI clients like Claude Desktop. The AI spawns the server as a child process.
  • HTTP — for CLI-based AI clients. Lokus starts an HTTP server on localhost:3456 that accepts MCP requests at /mcp.

Both transports are local-only. No data leaves your machine.

On first launch, Lokus:

  1. Extracts the MCP server to ~/.lokus/mcp-server/.
  2. Writes the Claude Desktop config to the OS-specific location (see table below).
  3. Creates a .mcp.json file in your workspace root for Claude Code.
  4. Runs claude mcp add to register with the Claude CLI (if installed).
  5. Starts the HTTP server on port 3456.
  6. Registers all 67 tools.
OSClaude Desktop config path
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
Linux~/.config/Claude/claude_desktop_config.json

No manual configuration required. Check the status bar at the bottom of Lokus — it shows “MCP: Running” with a green indicator when the server is active.

Terminal window
curl http://localhost:3456/health

Expected response:

{"status":"healthy","service":"lokus-mcp-http"}

The /health endpoint does not require authentication.

Lokus writes this configuration automatically. If you need to set it up manually, add the following to your Claude Desktop config file (see the path table above):

{
"mcpServers": {
"lokus": {
"command": "node",
"args": [
"~/.lokus/mcp-server/index.js"
]
}
}
}

To specify a workspace path:

{
"mcpServers": {
"lokus": {
"command": "node",
"args": ["~/.lokus/mcp-server/index.js"],
"env": {
"LOKUS_WORKSPACE": "/path/to/your/workspace"
}
}
}
}

Lokus automatically creates a .mcp.json file in your workspace root and registers with the Claude CLI via claude mcp add. If you need to configure it manually, add this to your .mcp.json file in your project root or home directory:

{
"mcpServers": {
"lokus": {
"transport": "http",
"url": "http://localhost:3456/mcp"
}
}
}

Any client that supports the MCP specification works. Use stdio transport for desktop apps and HTTP transport for CLI tools. The HTTP endpoint is http://localhost:3456/mcp and accepts standard JSON-RPC 2.0 requests. All HTTP requests (except /health) require a bearer token — see the Authentication section below.

The HTTP server uses bearer token authentication. On startup, the server generates a random 32-byte hex token and writes it to ~/.lokus/mcp-token with file permissions 0600 (owner read/write only).

All HTTP requests except /health must include the token in the Authorization header:

Authorization: Bearer <token>

Requests without a valid token receive a 401 Unauthorized response.

Terminal window
cat ~/.lokus/mcp-token

The token is regenerated each time the HTTP server starts. MCP clients using stdio transport (like Claude Desktop) are not affected by token auth since they communicate through standard I/O, not HTTP.

MethodPathAuth requiredDescription
GET/healthNoHealth check
GET/mcp/infoYesServer info (name, version, transport, tool count)
POST/mcpYesMCP JSON-RPC 2.0 endpoint

Smart workspace detection and context switching. The server auto-detects your active workspace using this priority chain: Lokus app API > last-used config > default location (~/Documents/Lokus Workspace).

ToolDescription
list_all_workspacesList all available Lokus workspaces
set_workspace_contextSet the active workspace for all subsequent operations
get_current_contextCheck which workspace is currently active
match_workspace_by_nameFind a workspace from natural language (e.g., “my work notes”)
clear_workspace_contextReset the active workspace context
detect_workspace_from_textAnalyze text for workspace references

Create, read, update, delete, and analyze notes.

ToolDescription
list_notesList notes with metadata, sorted by name/modified/size
read_noteRead full content of a note
create_noteCreate a note with optional frontmatter
update_noteUpdate existing note content
delete_noteDelete a note
search_notesSearch notes by content or title
get_note_linksGet all outgoing wiki links from a note
get_note_backlinksGet all notes that link to a specific note
extract_note_metadataExtract frontmatter and metadata
rename_noteRename a note and update references

Workspace-level operations and statistics.

ToolDescription
get_workspace_infoComprehensive workspace information
get_workspace_statsStatistics: note count, total size, etc.
list_foldersList all folders up to a specified depth
get_workspace_settingsRead workspace-specific settings
search_workspaceGlobal full-text search across all file types
get_recent_filesRecently modified files

Manage structured data in Lokus Bases.

ToolDescription
list_basesList all databases in the workspace
get_baseGet schema and records for a specific base
create_baseCreate a new base with a schema definition
add_base_recordAdd a record to a base
query_baseQuery records with filters
update_base_recordUpdate an existing record
delete_base_recordDelete a record
get_base_statsStatistics for a base

Work with Lokus Canvas (visual whiteboard).

ToolDescription
list_canvasesList all canvases
get_canvasGet canvas data including shapes and connections
create_canvasCreate a new canvas
add_canvas_shapeAdd a shape (text, rectangle, arrow, etc.)
get_canvas_connectionsGet all arrows/connections between shapes
export_canvasExport canvas data

Manage kanban boards and cards.

ToolDescription
list_boardsList all kanban boards
get_boardGet board with columns and cards
create_boardCreate a board with columns (supports date-based columns)
add_cardAdd a card to a column
move_cardMove a card between columns
update_cardUpdate card content or properties
get_board_statsBoard statistics

Navigate and analyze the knowledge graph built from wiki links.

ToolDescription
get_graph_overviewOverview of the entire knowledge graph
get_node_connectionsAll connections for a specific note
find_pathFind the shortest path between two notes
get_orphan_notesFind notes with no connections
get_hub_notesFind the most-connected notes
get_clustersIdentify clusters of related notes

Create and manage reusable note templates. Templates support variables: {{date}}, {{time}}, {{cursor}}, {{title}}, and custom variables.

ToolDescription
list_templatesList templates, optionally filtered by category
create_templateCreate a template with variables and metadata
read_templateRead a template’s content and metadata
update_templateUpdate an existing template
delete_templateDelete a template

Create, manage, and apply editor themes. Themes use 20+ CSS custom property tokens.

ToolDescription
list_themesList built-in and custom themes
get_themeGet theme details including all tokens
create_themeCreate a custom theme
update_themeModify a theme’s tokens
delete_themeDelete a custom theme
apply_themeApply a theme to the editor
get_current_themeGet the currently active theme
export_themeExport a theme to JSON
import_themeImport a theme from JSON
ToolDescription
daily_noteOpen or create a daily note. Actions: today, yesterday, tomorrow, date, list. Notes are stored in the Daily Notes/ folder with yyyy-MM-dd.md filenames.
ToolDescription
manage_tasksList, search, update, and get stats for tasks across all notes. Parses checkbox syntax: - [ ] todo, - [x] done, - [/] in progress, - [!] urgent, - [?] question, - [-] cancelled, - [>] delegated.

Graph-enhanced search that combines full-text matching with knowledge graph traversal.

ToolDescription
smart_searchFull-text search enhanced with wiki link graph traversal. Returns matching notes plus their connected notes.
explore_topicNavigate the knowledge graph from a starting point to discover related content.

The MCP server includes a file tools plugin (file-tools-plugin.js) that registers additional file operation tools when the MCP integration system is available inside the Lokus app. This plugin provides workspace-level file management capabilities and is loaded automatically — no manual configuration is needed.

VariableDescriptionDefault
LOKUS_WORKSPACEWorkspace pathAuto-detected
LOKUS_MCP_PORTHTTP server port3456

The HTTP server whitelists the following origins for cross-origin requests:

  • http://localhost (and any port)
  • http://127.0.0.1 (and any port)
  • tauri://localhost
  • https://tauri.localhost

Requests from other origins will not receive CORS headers. Preflight OPTIONS requests are handled automatically.

"List all notes in my workspace, sorted by last modified."

The AI calls list_notes with sortBy: "modified" and returns the results.

"Create a note called 'Meeting Notes - Feb 22' with the summary we just discussed."

The AI calls create_note with the path and content.

"Find all notes mentioning 'machine learning' and show me how they're connected."

The AI calls smart_search to find matching notes, then get_node_connections to map relationships.

"Show me all urgent tasks across my workspace."

The AI calls manage_tasks with action search and status filter urgent.

"What are the most connected notes in my workspace? Are there any orphan notes?"

The AI calls get_hub_notes and get_orphan_notes to analyze graph structure.

All requests to the HTTP API (except /health) require the bearer token from ~/.lokus/mcp-token.

Send MCP requests to the HTTP endpoint using JSON-RPC 2.0:

Terminal window
# Read the auth token
TOKEN=$(cat ~/.lokus/mcp-token)
# List all tools
curl -X POST http://localhost:3456/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
# Call a tool
curl -X POST http://localhost:3456/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"jsonrpc":"2.0",
"method":"tools/call",
"params":{
"name":"list_notes",
"arguments":{"sortBy":"modified"}
},
"id":2
}'
# Get server info
curl -H "Authorization: Bearer $TOKEN" http://localhost:3456/mcp/info
  • Local-only connections. The HTTP server binds to 127.0.0.1. No remote access by default.
  • Bearer token authentication. Every HTTP request (except /health) must include a valid Authorization: Bearer <token> header. The token is stored at ~/.lokus/mcp-token with 0600 permissions and regenerated on each server start.
  • Constant-time token comparison. Token validation uses a byte-by-byte XOR comparison to prevent timing attacks.
  • CORS origin whitelisting. Only localhost, 127.0.0.1, and Tauri origins are allowed.
  • File system permissions. The server respects OS-level read/write permissions.
  • No external network calls. The MCP server never phones home or calls external APIs.
  • Logging to stderr. All server logs are written to stderr, not to files on disk.
  1. Check if port 3456 is already in use:
    Terminal window
    lsof -i :3456
  2. Verify Node.js 18+ is installed:
    Terminal window
    node --version
  3. Check server logs in the terminal where Lokus is running (logs go to stderr).
  4. Delete ~/.lokus/mcp-server/ and restart Lokus to rebuild.
  1. Confirm the Claude Desktop config exists at the correct OS-specific path (see the config path table above).
  2. Restart your AI client after adding the configuration.
  3. Test the HTTP endpoint directly:
    Terminal window
    curl http://localhost:3456/health

The bearer token is regenerated each time the HTTP server starts. If you are getting 401 errors:

  1. Re-read the token:
    Terminal window
    cat ~/.lokus/mcp-token
  2. Update your requests with the new token value.
  3. MCP clients configured via .mcp.json or claude mcp add using stdio transport are not affected — only direct HTTP callers need the token.

Set the workspace explicitly:

Terminal window
export LOKUS_WORKSPACE="/path/to/your/workspace"

Or use the set_workspace_context tool to switch workspaces within a conversation.

The MCP server also exposes documentation resources that AI assistants can read, including a Markdown syntax reference covering wiki links, math equations, task checkboxes, and highlights. Access resources via the resources/list and resources/read MCP methods.