search_gitlab
Query and retrieve GitLab projects and repositories with customizable search parameters through the Open Search MCP server, streamlining repository discovery.
Instructions
Search GitLab projects and repositories
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of results to return | |
| query | Yes | Search query for GitLab repositories |
Input Schema (JSON Schema)
{
"properties": {
"maxResults": {
"default": 20,
"description": "Maximum number of results to return",
"maximum": 100,
"minimum": 1,
"type": "number"
},
"query": {
"description": "Search query for GitLab repositories",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- The execute function implementing the core logic of the search_gitlab tool. It takes query and optional maxResults, simulates GitLab API search results with mock repository data.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 }; } }
- Input schema defining the parameters for the search_gitlab tool: required 'query' string and optional 'maxResults' number (1-100, default 20).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'] },
- src/tools/tech/gitlab-bitbucket-tools.ts:11-72 (registration)Registration of the search_gitlab tool in the ToolRegistry, including name, description, category, schema, and execute 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)Call to registerGitLabBitbucketTools which registers the search_gitlab tool among others during server startup.registerGitLabBitbucketTools(this.toolRegistry); // 2 tools: search_gitlab, search_bitbucket
- src/utils/input-validator.ts:245-245 (schema)Additional input validation schema mapping for search_gitlab tool using basicSearch schema in the global input validator.'search_gitlab': ToolSchemas.basicSearch,