search_gitlab
Search GitLab projects and repositories using queries to find relevant codebases and development resources.
Instructions
Search GitLab projects and repositories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for GitLab repositories | |
| maxResults | No | Maximum number of results to return |
Implementation Reference
- The execute handler function that performs the core logic of the search_gitlab tool, simulating GitLab repository search with fake results.execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { query, maxResults = 20 } = args; // Simulated GitLab search results const results = Array.from({ length: Math.min(maxResults, 10) }, (_, i) => ({ name: `${query}-project-${i + 1}`, description: `A GitLab project related to ${query}`, url: `https://gitlab.com/user${i + 1}/${query}-project-${i + 1}`, stars: Math.floor(Math.random() * 1000), forks: Math.floor(Math.random() * 100), language: ['JavaScript', 'Python', 'Go', 'Rust', 'Java'][i % 5], lastActivity: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000).toISOString(), visibility: i % 3 === 0 ? 'private' : 'public', namespace: `user${i + 1}`, topics: [query, 'gitlab', 'open-source'] })); return { success: true, data: { source: 'GitLab', query, results, totalResults: results.length }, metadata: { searchTime: Date.now(), source: 'GitLab API' } }; } catch (error) { return { success: false, error: `GitLab search failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } }
- src/tools/tech/gitlab-bitbucket-tools.ts:11-72 (registration)The registry.registerTool call that defines and registers the search_gitlab tool including its schema, description, and inline handler.registry.registerTool({ name: 'search_gitlab', description: 'Search GitLab projects and repositories', category: 'developer', source: 'GitLab', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for GitLab repositories' }, maxResults: { type: 'number', description: 'Maximum number of results to return', default: 20, minimum: 1, maximum: 100 } }, required: ['query'] }, execute: async (args: ToolInput): Promise<ToolOutput> => { try { const { query, maxResults = 20 } = args; // Simulated GitLab search results const results = Array.from({ length: Math.min(maxResults, 10) }, (_, i) => ({ name: `${query}-project-${i + 1}`, description: `A GitLab project related to ${query}`, url: `https://gitlab.com/user${i + 1}/${query}-project-${i + 1}`, stars: Math.floor(Math.random() * 1000), forks: Math.floor(Math.random() * 100), language: ['JavaScript', 'Python', 'Go', 'Rust', 'Java'][i % 5], lastActivity: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000).toISOString(), visibility: i % 3 === 0 ? 'private' : 'public', namespace: `user${i + 1}`, topics: [query, 'gitlab', 'open-source'] })); return { success: true, data: { source: 'GitLab', query, results, totalResults: results.length }, metadata: { searchTime: Date.now(), source: 'GitLab API' } }; } catch (error) { return { success: false, error: `GitLab search failed: ${error instanceof Error ? error.message : String(error)}`, data: null }; } } });
- src/index.ts:238-238 (registration)Invocation of the registerGitLabBitbucketTools function during MCP server initialization, which registers the search_gitlab tool.registerGitLabBitbucketTools(this.toolRegistry); // 2 tools: search_gitlab, search_bitbucket
- src/utils/input-validator.ts:245-245 (schema)Additional input validation schema reference for search_gitlab using the basicSearch Zod schema.'search_gitlab': ToolSchemas.basicSearch,