gitlab_search_in_project
Search within a GitLab project for issues, MRs, commits, code, or wiki pages using specified scopes. Retrieve matching results with highlights based on your query. Simplify project navigation by targeting specific content types directly.
Instructions
Search within a project Returns: Results from specified scope Use when: Finding issues, MRs, code, wiki pages Required: Scope (what to search in)
Scopes:
'issues': Search issue titles/descriptions
'merge_requests': Search MR titles/descriptions
'commits': Search commit messages
'blobs': Search file contents
'wiki_blobs': Search wiki pages
Example: Search for "login" in issues Returns matching issues with highlights
Related tools:
gitlab_search_projects: Search across projects
Specific list tools for each type
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination Type: integer Range: ≥1 Default: 1 Example: 3 (to get the third page of results) Note: Use with per_page to navigate large result sets | |
| per_page | No | Number of results per page Type: integer Range: 1-100 Default: 20 Example: 50 (for faster browsing) Tip: Use smaller values (10-20) for detailed operations, larger (50-100) for listing | |
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted | |
| scope | Yes | Search scope Type: string (enum) Options: - 'issues': Search in issues - 'merge_requests': Search in MRs - 'milestones': Search in milestones - 'wiki_blobs': Search in wiki pages - 'commits': Search in commit messages - 'blobs': Search in file contents - 'users': Search for users Required: Yes Example: 'issues' to find issues mentioning a term | |
| search | Yes | Search query Type: string Matching: Case-insensitive, partial matching Searches in: Project names and descriptions Examples: - 'frontend' (finds 'frontend-app', 'old-frontend', etc.) - 'API' (matches 'api', 'API', 'GraphQL-API', etc.) Tip: Use specific terms for better results |
Implementation Reference
- src/mcp_gitlab/tool_handlers.py:226-235 (handler)Main handler function implementing the gitlab_search_in_project tool. Extracts parameters, detects project if needed, and calls GitLabClient.search_in_project.def handle_search_in_project(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle searching in project""" project_id = require_project_id(client, arguments) scope = require_argument(arguments, "scope") search = require_argument(arguments, "search") per_page = get_argument(arguments, "per_page", DEFAULT_PAGE_SIZE) page = get_argument(arguments, "page", 1) return client.search_in_project(project_id, scope, search, per_page, page)
- src/mcp_gitlab/tool_handlers.py:1056-1058 (registration)Registration of the handler function in the TOOL_HANDLERS dictionary, which is used by server.py to dispatch tool calls.TOOL_SEARCH_PROJECTS: handle_search_projects, TOOL_SEARCH_IN_PROJECT: handle_search_in_project,
- src/mcp_gitlab/server.py:479-493 (schema)Tool schema definition returned by @server.list_tools(), including input schema, parameters, and description.types.Tool( name="gitlab_search_in_project", description=desc.DESC_SEARCH_IN_PROJECT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "scope": {"type": "string", "description": desc.DESC_SEARCH_SCOPE, "enum": ["issues", "merge_requests", "milestones", "notes", "wiki_blobs", "commits", "blobs"]}, "search": {"type": "string", "description": desc.DESC_SEARCH_TERM}, "per_page": {"type": "integer", "description": desc.DESC_PER_PAGE, "default": DEFAULT_PAGE_SIZE, "minimum": 1, "maximum": MAX_PAGE_SIZE}, "page": {"type": "integer", "description": desc.DESC_PAGE_NUMBER, "default": 1, "minimum": 1} }, "required": ["scope", "search"] } ),
- Additional schema definition in tool_definitions.py (potentially used or reference).types.Tool( name=TOOL_SEARCH_IN_PROJECT, description=desc.DESC_SEARCH_IN_PROJECT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "scope": {"type": "string", "description": desc.DESC_SEARCH_SCOPE, "enum": ["issues", "merge_requests", "milestones", "notes", "wiki_blobs", "commits", "blobs"]}, "search": {"type": "string", "description": desc.DESC_SEARCH_TERM}, "per_page": {"type": "integer", "description": desc.DESC_PER_PAGE, "default": DEFAULT_PAGE_SIZE, "minimum": 1, "maximum": MAX_PAGE_SIZE}, "page": {"type": "integer", "description": desc.DESC_PAGE_NUMBER, "default": 1, "minimum": 1} }, "required": ["scope", "search"] } ),
- src/mcp_gitlab/constants.py:227-227 (helper)Constant definition for the tool name used across files.TOOL_SEARCH_IN_PROJECT = "gitlab_search_in_project"