Skip to content

MCP Server Setup

LocalLens ships as an MCP (Model Context Protocol) server, letting AI agents like Claude Code and Claude Desktop search your files.

Install

bash
pip install "locallens[mcp]"

Start

bash
locallens serve --mcp

The server starts on port 8811 by default, using SSE transport.

Custom port

bash
locallens serve --mcp --port 9000

Environment variables

Configure the MCP server via environment variables:

VariableDefaultDescription
LOCALLENS_DATA_DIR~/.locallensData directory
LOCALLENS_COLLECTIONlocallensCollection name
LOCALLENS_OLLAMA_URLhttp://localhost:11434Ollama URL
LOCALLENS_OLLAMA_MODELqwen2.5:3bOllama model
LOCALLENS_EMBEDDING_MODELall-MiniLM-L6-v2Embedding model

Verify

Once running, the server prints:

LocalLens MCP server running on http://localhost:8811/sse

You can test the SSE endpoint:

bash
curl http://localhost:8811/sse

Index first

The MCP server searches whatever is already indexed. Index your files before starting:

bash
locallens index ~/my-project
locallens serve --mcp

Or use the locallens_index tool from within your AI client to index on demand.

Released under the MIT License.