Skip to main content
Glama
damian-pramparo

Enterprise Code Search MCP Server

index_local_project

Index a local project directory into a vector database to enable semantic code search and analysis across your codebase.

Instructions

Index a local project directory into the vector database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exclude_patternsNoFile patterns to exclude (optional)
include_patternsNoFile patterns to include (optional)
project_nameYesName for the project (used as identifier)
project_pathYesAbsolute path to the local project directory

Implementation Reference

  • Core handler function for the 'index_local_project' tool. Validates input, traverses directory, processes files into chunks, generates embeddings, and stores them in ChromaDB.
    async indexLocalProject(args: { project_path: string; project_name: string; include_patterns?: string[]; exclude_patterns?: string[]; }) { const { project_path, project_name, include_patterns = this.getDefaultIncludePatterns(), exclude_patterns = this.getDefaultExcludePatterns() } = args; try { const stats = await fs.stat(project_path); if (!stats.isDirectory()) { throw new Error(`Path is not a directory: ${project_path}`); } } catch (error) { throw new Error(`Cannot access project path: ${project_path}`); } const projectId = this.sanitizeProjectId(project_name); try { const collection = await this.getOrCreateCollection(); const files = await this.getFilesToIndex(project_path, include_patterns, exclude_patterns); const chunks = []; let processedFiles = 0; for (const filePath of files) { try { const relativePath = path.relative(project_path, filePath); const fileExtension = path.extname(filePath).slice(1) || 'txt'; const fileStats = await fs.stat(filePath); const fileSizeMB = fileStats.size / (1024 * 1024); console.error(`Processing file: ${relativePath} (${fileSizeMB.toFixed(2)} MB)`); const fileChunks = await this.processFileWithStreaming(filePath, relativePath, fileExtension); if (fileChunks.length > 0) { chunks.push(...fileChunks.map(chunk => ({ ...chunk, project_id: projectId, project_name, project_path, source_type: 'local', indexed_at: new Date().toISOString() }))); } processedFiles++; } catch (error) { console.error(`Error processing file ${filePath}:`, error); } } if (chunks.length > 0) { await this.storeChunksInBatches(collection, chunks, projectId); } return { content: [ { type: "text", text: `Successfully indexed local project: ${project_name}\n` + `Project ID: ${projectId}\n` + `Project Path: ${project_path}\n` + `Files processed: ${processedFiles}\n` + `Chunks created: ${chunks.length}\n` + `Embedding provider: ${this.config.embedding_provider}` } ] }; } catch (error) { throw error; } }
  • Input schema definition for the index_local_project tool, used in tool listing for HTTP server.
    name: "index_local_project", description: "Index a local project directory into the vector database", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Absolute path to the local project directory" }, project_name: { type: "string", description: "Name for the project (used as identifier)" }, include_patterns: { type: "array", items: { type: "string" }, description: "File patterns to include (optional)" }, exclude_patterns: { type: "array", items: { type: "string" }, description: "File patterns to exclude (optional)" } }, required: ["project_path", "project_name"] }
  • Tool registration/dispatch in HTTP server's callTool switch statement.
    case "index_local_project": return await this.indexLocalProject(args);
  • src/index.ts:112-113 (registration)
    Tool registration/dispatch in stdio server's CallToolRequestSchema handler.
    case "index_local_project": return await this.indexLocalProject(args as any);
  • Input schema definition for the index_local_project tool, used in tool listing for stdio server.
    name: "index_local_project", description: "Index a local project directory into the vector database", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Absolute path to the local project directory" }, project_name: { type: "string", description: "Name for the project (used as identifier)" }, include_patterns: { type: "array", items: { type: "string" }, description: "File patterns to include (optional)" }, exclude_patterns: { type: "array", items: { type: "string" }, description: "File patterns to exclude (optional)" } }, required: ["project_path", "project_name"] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/damian-pramparo/semantic-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server