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"]
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the action ('index') but lacks critical behavioral details: it doesn't specify if this is a one-time or incremental operation, what happens if the project already exists (overwrite? error?), permission requirements, or any side effects like data persistence or performance impact. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and target, making it easy to understand at a glance. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of indexing a directory (a mutation operation with potential side effects), no annotations, and no output schema, the description is incomplete. It fails to address key contextual aspects like what 'indexing' entails (e.g., file parsing, embedding generation), error handling, or what the tool returns upon success/failure. This leaves significant gaps for an AI agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds no additional meaning beyond what's in the schema—it doesn't explain parameter interactions, default behaviors, or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('index') and target ('a local project directory into the vector database'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'list_indexed_projects' or 'search_codebase', which are related but serve different purposes (listing vs. indexing vs. searching).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing directory), exclusions (e.g., when not to index), or how it relates to siblings like 'list_indexed_projects' for checking existing indexes or 'search_codebase' for querying after indexing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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