From 1e5d05e36a20b52307a90aa23d21869e42b4bab2 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Sat, 9 Aug 2025 19:28:40 -0700 Subject: [PATCH] remove leann_index from MCP interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users should use CLI command 'leann build' to create indexes first. MCP now only provides search functionality: - leann_search: search existing indexes - leann_status: check index health - leann_list: list available indexes This separates index creation (CLI) from search (Claude Code). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- packages/leann-core/src/leann/mcp.py | 116 +-------------------------- 1 file changed, 1 insertion(+), 115 deletions(-) diff --git a/packages/leann-core/src/leann/mcp.py b/packages/leann-core/src/leann/mcp.py index f67c3e3..92f79e3 100755 --- a/packages/leann-core/src/leann/mcp.py +++ b/packages/leann-core/src/leann/mcp.py @@ -23,57 +23,6 @@ def handle_request(request): "id": request.get("id"), "result": { "tools": [ - { - "name": "leann_index", - "description": """🏗️ Index a codebase for intelligent code search and understanding. - -🎯 **When to use**: Before analyzing, modifying, or understanding any codebase -📁 **What it does**: Creates a semantic search index of code files and documentation -⚡ **Why it's useful**: Enables fast, intelligent searches like "authentication logic", "error handling patterns", "API endpoints" - -This is your first step for any serious codebase work - think of it as giving yourself superpowers to understand and navigate code.""", - "inputSchema": { - "type": "object", - "properties": { - "index_name": { - "type": "string", - "description": "Name for the new index. Use descriptive names like 'my-project' or 'backend-api'.", - }, - "docs_path": { - "type": "string", - "description": "Path to the directory containing code/documents to index. Can be relative (e.g., './src') or absolute.", - }, - "force": { - "type": "boolean", - "default": False, - "description": "Force rebuild of existing index. Use when you want to completely reindex and overwrite existing data.", - }, - "backend": { - "type": "string", - "enum": ["hnsw", "diskann"], - "default": "hnsw", - "description": "Vector index backend: 'hnsw' for balanced performance, 'diskann' for large-scale datasets.", - }, - "embedding_model": { - "type": "string", - "default": "facebook/contriever", - "description": "Embedding model to use. Popular options: 'facebook/contriever', 'sentence-transformers/all-MiniLM-L6-v2'", - }, - "file_types": { - "type": "array", - "items": {"type": "string"}, - "description": "File extensions to include (e.g., ['.py', '.js', '.ts', '.md']). If not specified, uses default supported types.", - }, - "ignore_patterns": { - "type": "array", - "items": {"type": "string"}, - "default": [], - "description": "Patterns to ignore during indexing (e.g., ['node_modules', '__pycache__', '*.tmp', 'dist']). Common patterns are automatically ignored.", - }, - }, - "required": ["index_name", "docs_path"], - }, - }, { "name": "leann_search", "description": """🔍 Search code using natural language - like having a coding assistant who knows your entire codebase! @@ -142,70 +91,7 @@ This is your first step for any serious codebase work - think of it as giving yo args = request["params"].get("arguments", {}) try: - if tool_name == "leann_index": - # Validate required parameters - if not args.get("index_name") or not args.get("docs_path"): - return { - "jsonrpc": "2.0", - "id": request.get("id"), - "result": { - "content": [ - { - "type": "text", - "text": "Error: Both index_name and docs_path are required", - } - ] - }, - } - - # Validate docs_path exists - import os - - docs_path = args["docs_path"] - if not os.path.exists(docs_path): - return { - "jsonrpc": "2.0", - "id": request.get("id"), - "result": { - "content": [ - { - "type": "text", - "text": f"Error: Path '{docs_path}' does not exist", - } - ] - }, - } - - # Build index command - cmd = [ - "leann", - "build", - args["index_name"], - "--docs", - docs_path, - "--backend", - args.get("backend", "hnsw"), - "--embedding-model", - args.get("embedding_model", "facebook/contriever"), - ] - - # Add force flag if specified - if args.get("force", False): - cmd.append("--force") - - # Add file types if specified (now as array) - file_types = args.get("file_types") - if file_types and isinstance(file_types, list): - cmd.extend(["--file-types", ",".join(file_types)]) - - # Add ignore patterns if specified - ignore_patterns = args.get("ignore_patterns", []) - if ignore_patterns and isinstance(ignore_patterns, list): - # For now, pass as comma-separated string - CLI can be enhanced later - cmd.extend(["--ignore", ",".join(ignore_patterns)]) - result = subprocess.run(cmd, capture_output=True, text=True) - - elif tool_name == "leann_search": + if tool_name == "leann_search": # Validate required parameters if not args.get("index_name") or not args.get("query"): return {