index_repository
Index code repositories from GitHub or GitLab to enable search and query capabilities for specific branches.
Instructions
Index a repository to make it searchable for future queries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | Yes | Branch to index | |
| notify | No | Send email notification when indexing completes | |
| reload | No | Force reprocessing of previously indexed repository | |
| remote | Yes | Repository host (github or gitlab) | |
| repository | Yes | Repository in owner/repo format |
Implementation Reference
- src/server.ts:415-451 (handler)Main MCP tool handler for index_repository. Extracts arguments, checks client availability, calls GreptileClient.indexRepository, and formats 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 (registration)Tool registration in ListToolsRequestSchema handler, including name, description, and input schema.{ 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/clients/greptile.ts:50-68 (helper)GreptileClient method that performs the actual HTTP POST request to the Greptile API to index the repository.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 index_repository.export interface IndexRepositoryInput { remote: string; repository: string; branch: string; reload?: boolean; notify?: boolean; }