index_repository
Index a repository to enable searchable queries across its codebase, making it accessible for future analysis and information retrieval.
Instructions
Index a repository to make it searchable for future queries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| remote | Yes | Repository host (github or gitlab) | |
| repository | Yes | Repository in owner/repo format | |
| branch | Yes | Branch to index | |
| reload | No | Force reprocessing of previously indexed repository | |
| notify | No | Send email notification when indexing completes |
Implementation Reference
- src/server.ts:415-451 (handler)Main handler function that executes the index_repository tool logic, checks for Greptile client availability, parses arguments, calls the client method, and formats the response.private async handleIndexRepository( args: unknown ): Promise<{ content: Array<{ type: string; text: string }> }> { if (!this.greptileClient) { return { content: [ { type: 'text', text: createErrorResponse( 'Cannot index repository: Missing environment variables. Use greptile_env_check for setup guidance.', 'Configuration Error', undefined ), }, ], }; } const { remote, repository, branch, reload = true, notify = false } = args as any; const result = await this.greptileClient.indexRepository( remote, repository, branch, reload, notify ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/server.ts:102-134 (schema)JSON schema definition for the index_repository tool input, including properties, descriptions, defaults, and required fields.{ name: 'index_repository', description: 'Index a repository to make it searchable for future queries', inputSchema: { type: 'object', properties: { remote: { type: 'string', enum: ['github', 'gitlab'], description: 'Repository host (github or gitlab)', }, repository: { type: 'string', description: 'Repository in owner/repo format', }, branch: { type: 'string', description: 'Branch to index', }, reload: { type: 'boolean', description: 'Force reprocessing of previously indexed repository', default: true, }, notify: { type: 'boolean', description: 'Send email notification when indexing completes', default: false, }, }, required: ['remote', 'repository', 'branch'], }, },
- src/server.ts:231-232 (registration)Tool dispatch registration in the CallToolRequestSchema handler switch statement.case 'index_repository': return await this.handleIndexRepository(request.params.arguments);
- src/clients/greptile.ts:48-68 (helper)GreptileClient helper method that performs the actual API request to index the repository.* Index a repository for code search and querying */ async indexRepository( remote: string, repository: string, branch: string, reload: boolean = true, notify: boolean = false, timeout?: number ): Promise<Record<string, unknown>> { const url = `${this.baseUrl}/repositories`; const payload = { remote, repository, branch, reload, notify, }; return this.makeRequest('POST', url, payload, timeout); }
- src/types/index.ts:70-76 (schema)TypeScript interface defining the input structure for the index_repository tool.export interface IndexRepositoryInput { remote: string; repository: string; branch: string; reload?: boolean; notify?: boolean; }