Back to Gitlabhq

GitLab MCP server tools

doc/user/model_context_protocol/mcp_server_tools.md

19.3.036.5 KB
Original Source

{{< details >}}

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
  • Status: Beta

{{< /details >}}

[!warning] To provide feedback on this feature, leave a comment on issue 561564.

The GitLab MCP server provides a set of tools that integrate with your existing GitLab workflows. You can use these tools to interact directly with GitLab and perform common GitLab operations.

get_mcp_server_version

{{< history >}}

{{< /history >}}

Returns the current version of the GitLab MCP server.

Example:

plaintext
What version of the GitLab MCP server am I connected to?

create_issue

{{< history >}}

{{< /history >}}

Creates a new issue in a GitLab project.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
titlestringYesTitle of the issue.
descriptionstringNoDescription of the issue.
assignee_idsarray of integersNoArray of IDs of assigned users.
milestone_idintegerNoID of the milestone.
labelsarray of stringsNoArray of label names.
confidentialbooleanNoSets the issue to confidential. Default is false.
epic_idintegerNoID of the linked epic.

Example:

plaintext
Create a new issue titled "Fix login bug" in project 123 with description
"Users cannot log in with special characters in password"

get_issue

{{< history >}}

{{< /history >}}

Retrieves detailed information about a specific GitLab issue.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
issue_iidintegerYesInternal ID of the issue.

Example:

plaintext
Get details for issue 42 in project 123

create_merge_request

{{< history >}}

  • Introduced in GitLab 18.5.
  • assignee_ids, reviewer_ids, description, labels, and milestone_id added in GitLab 18.8.

{{< /history >}}

Creates a merge request in a GitLab project.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
titlestringYesTitle of the merge request.
source_branchstringYesName of the source branch.
target_branchstringYesName of the target branch.
target_project_idintegerNoID of the target project.
assignee_idsarray of integersNoArray of IDs of merge request assignees. Set to 0 or an empty value to unassign all assignees.
reviewer_idsarray of integersNoArray of IDs of merge request reviewers. Set to 0 or an empty value to unassign all reviewers.
descriptionstringNoDescription of the merge request.
labelsarray of stringsNoArray of label names. Set to an empty string to unassign all labels.
milestone_idintegerNoID of the milestone.

Example:

plaintext
Create a merge request in project gitlab-org/gitlab titled "Bug fix broken specs"
from branch "fix/specs-broken" into "master" and enable squash

get_merge_request

{{< history >}}

  • Introduced in GitLab 18.4.
  • Changed to accept url and return associated data facets in GitLab 19.3.

{{< /history >}}

Retrieves a merge request and, optionally, its diffs, commits, notes, pipelines, or discussions. Only the base merge request is returned unless you request associated data with the include parameter.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the merge request. Provide this, or project_id and merge_request_iid.
project_idstringNoID or URL-encoded path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
includearrayNoAssociated facets to return with the merge request. One of diffs, commits, notes, pipelines, or discussions. Limited to one facet per call.
notes_afterstringNoCursor for forward pagination of notes. Applies only when include is ["notes"].
notes_firstintegerNoNumber of notes to return after the cursor, up to 100. Applies only when include is ["notes"].

The diffs facet returns change statistics only: overall totals and per-file additions and deletions. To get patch text, use get_merge_request_diffs.

Example:

plaintext
Get merge request 15 in project gitlab-org/gitlab with its commits

list_duo_sessions

{{< history >}}

{{< /history >}}

Lists your GitLab Duo Agent Platform sessions, excluding Duo Chat sessions. Each session includes its individual status, goal preview, flow definition, and creation timestamp. Project sessions also include a session URL. The goal preview might be truncated.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the project to filter sessions by. Do not use with project_id.
project_idstringNoNumeric ID or full path of the project to filter sessions by. Do not use with url.
status_groupstringNoSession status group. One of active, paused, awaiting_input, completed, failed, or canceled.
afterstringNoCursor for forward pagination.
firstintegerNoNumber of sessions to return for forward pagination. Default is 20, maximum is 100.

The status_group filter can return sessions with multiple individual statuses. Each call returns a single page of results. If more pages exist, the response includes pageInfo.endCursor that you can pass as after.

Example:

plaintext
List my active Duo Agent Platform sessions in gitlab-org/gitlab

list_merge_requests

{{< history >}}

{{< /history >}}

Lists or searches merge requests in a GitLab project, returning compact merge request metadata.

ParameterTypeRequiredDescription
urlstringNoURL of the project. Provide exactly one of url or project_id.
project_idstringNoID or full path of the project. Provide exactly one of url or project_id.
author_usernamestringNoFilter by the username of the merge request author.
assignee_usernamestringNoFilter by the username of an assignee.
reviewer_usernamestringNoFilter by the username of a reviewer.
statestringNoFilter by state. One of opened, closed, merged, locked, or all. Omit to include any state.
scopestringNoFilter relative to the authenticated user. One of created_by_me, assigned_to_me, or review_requested. An explicit username wins for that field.
milestonestringNoFilter by the title of the milestone.
labelsstringNoComma-separated list of label names. Only merge requests with all of these labels are returned.
searchstringNoSearch query matched against merge request title and description.
afterstringNoCursor for forward pagination.
firstintegerNoNumber of merge requests to return for forward pagination. Default is 20, maximum is 100.

To retrieve a single merge request in full detail, use get_merge_request. Its diffs, commits, and notes are available from get_merge_request_diffs, get_merge_request_commits, and get_merge_request_notes. For full-text search across resource types, use search.

Example:

plaintext
List my open merge requests in gitlab-org/gitlab

get_merge_request_commits

{{< history >}}

{{< /history >}}

Retrieves the list of commits in a specific GitLab merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of commits per page.
pageintegerNoCurrent page number.

Example:

plaintext
Show me all commits in merge request 42 from project 123

get_merge_request_diffs

{{< history >}}

{{< /history >}}

Retrieves the diffs for a specific GitLab merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of diffs per page.
pageintegerNoCurrent page number.

Example:

plaintext
What files were changed in merge request 25 in the gitlab project?

get_merge_request_pipelines

{{< history >}}

{{< /history >}}

Retrieves the pipelines for a specific GitLab merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.

Example:

plaintext
Show me all pipelines for merge request 42 in project gitlab-org/gitlab

create_merge_request_note

{{< history >}}

{{< /history >}}

Adds a comment or reply to a discussion on a GitLab merge request as the authenticated user.

ParameterTypeRequiredDescription
urlstringNoURL of the GitLab merge request. Required if project_id and merge_request_iid are missing.
project_idstringNoID or URL-encoded path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
bodystringYesContent of the note. Lines cannot start with / to avoid triggering quick actions (for example, /merge).
discussion_idstringNoGlobal ID of the discussion to reply to (in the format gid://gitlab/Discussion/<id>). If missing, creates a new top-level note.

Example:

plaintext
Reply "Thanks, fixed in the latest push" to merge request 42 in project gitlab-org/gitlab

get_merge_request_notes

{{< history >}}

{{< /history >}}

Retrieves the notes (comments and system notes) for a specific GitLab merge request.

ParameterTypeRequiredDescription
urlstringNoURL of the GitLab merge request. Required if project_id and merge_request_iid are missing.
project_idstringNoID or URL-encoded path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
afterstringNoCursor for forward pagination.
beforestringNoCursor for backward pagination.
firstintegerNoNumber of notes to return for forward pagination.
lastintegerNoNumber of notes to return for backward pagination.

Each returned note includes its discussion ID, so related notes can be grouped into threads.

Example:

plaintext
Show me all comments on merge request 5 in project gitlab-org/gitlab

add_branch

{{< history >}}

  • Introduced in GitLab 19.3. create_branch is also accepted as an alias.

{{< /history >}}

Adds a branch to a GitLab project from a source ref.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the project. Provide this, or project_id.
project_idstringNoID or path of the project. Required if url is not provided.
branchstringYesName of the new branch.
refstringYesBranch name or commit SHA to create the new branch from.

Example:

plaintext
Create a branch named feature/x from main in project gitlab-org/gitlab

get_repository_file

{{< history >}}

{{< /history >}}

Retrieves the contents of a single file from a repository at a specific ref.

Content comes from the repository, not from your local filesystem. The file is returned as committed at ref, so uncommitted changes in a local checkout are not included.

ParameterTypeRequiredDescription
urlstringNoURL of the file, for example https://gitlab.example.com/my-group/my-project/-/blob/main/app/models/user.rb. Provide this, or project_id, file_path, and ref.
project_idstringNoID or full path of the project. Required if url is not provided.
file_pathstringNoPath of the file relative to the repository root. Required if url is not provided.
refstringNoBranch name, tag name, or commit SHA. Use HEAD for the default branch. Required if url is not provided.
offsetintegerNoZero-indexed line to start reading from. Default is 0.
limitintegerNoMaximum number of lines to return. Default and maximum are 2000.

The response contains a metadata object with total_lines, returned_lines, truncated, and size_bytes. When the response covers only part of the file, system_instruction states the offset to use in the next call.

This tool returns text only. Binary files and files stored in Git LFS return an error. Files that a project excludes from GitLab Duo context also return an error.

Example:

plaintext
Show me app/models/user.rb from the main branch of my-group/my-project

get_pipeline

{{< history >}}

{{< /history >}}

Retrieves a pipeline, and optionally its jobs, downstream pipelines, or bridge (trigger) jobs.

ParameterTypeRequiredDescription
idstringYesID or full path of the project.
pipeline_idintegerYesID of the pipeline.
includearrayNoFacet to include alongside the pipeline, one per call: jobs, downstream_pipelines, or bridge_jobs.
job_statusstringNoFilters the jobs facet by status (for example, failed). Only applies when include is jobs.
firstintegerNoNumber of items to return for the selected include facet. Default is 20, maximum is 100.
afterstringNoCursor for forward pagination of the selected include facet. Use the previous response's page_info.end_cursor.

A bridge job's downstream_pipeline is omitted (null) both when the trigger job hasn't triggered a downstream pipeline yet, and when you don't have access to that pipeline.

Each downstream pipeline includes a project_full_path, because a downstream pipeline can belong to a different project. Use that value as the id of a follow-up call.

Examples:

  • Get a pipeline:

    plaintext
    Get the status of pipeline 12345 in project gitlab-org/gitlab
    
  • Get a pipeline's failed jobs:

    plaintext
    Show me the failed jobs in pipeline 12345 for project gitlab-org/gitlab
    
  • Get a pipeline's downstream pipelines:

    plaintext
    Show me the downstream pipelines triggered by pipeline 12345 in project gitlab-org/gitlab
    

get_pipeline_jobs

{{< history >}}

{{< /history >}}

Retrieves the jobs for a specific GitLab CI/CD pipeline. To get jobs alongside the rest of the pipeline's data in a single call, use the get_pipeline tool with include: jobs instead.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
pipeline_idintegerYesID of the pipeline.
per_pageintegerNoNumber of jobs per page.
pageintegerNoCurrent page number.

Example:

plaintext
Show me all jobs in pipeline 12345 for project gitlab-org/gitlab

get_job_log

Retrieves the trace (log output) for a specific CI/CD job.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
job_idintegerYesID of the job.

Example:

plaintext
Show me the log output for job 88 in project gitlab-org/gitlab

list_pipelines

{{< history >}}

{{< /history >}}

Lists pipelines in a GitLab project, with optional filters.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
refstringNoBranch or tag name. Filters pipelines by ref.
statusstringNoFilters pipelines by status (for example, running, success, failed).
sourcestringNoFilters pipelines by source (for example, push, web, schedule).
created_afterstringNoReturns pipelines created after the specified datetime (ISO 8601 format).
created_beforestringNoReturns pipelines created before the specified datetime (ISO 8601 format).
order_bystringNoOrders pipelines by id, status, ref, updated_at, or user_id. Default is id.
sortstringNoSort direction, asc or desc. Default is desc.
pageintegerNoCurrent page number. Default is 1.
per_pageintegerNoNumber of items per page. Default is 20.

Child pipelines are excluded from the results by default. To return only child pipelines, set source to parent_pipeline.

The default order (id, desc) returns pipelines with the highest ID first. ID order usually matches creation order, but the two aren't guaranteed to agree. Use created_after or created_before to filter by an explicit time boundary. A caller can page through results and stop at the first pipeline outside its target range.

Example:

plaintext
List all failed pipelines on the main branch for project gitlab-org/gitlab

save_pipeline

{{< history >}}

{{< /history >}}

Runs, retries, or cancels a CI/CD pipeline in a GitLab project. To update pipeline metadata or delete a pipeline, use the manage_pipeline tool instead. To list pipelines, use the list_pipelines tool instead.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the project. Used only to create a pipeline. Provide this, or project_id.
project_idstringNoID or full path of the project. Used only to create a pipeline. Provide this, or url.
pipeline_idintegerNoID of an existing pipeline to target. When set, requires action. Omit to create a new pipeline.
actionstringNoLifecycle action to perform on pipeline_id: retry or cancel. Required when pipeline_id is set.
refstringNoBranch or tag name. Required to create a pipeline (when pipeline_id is absent).
variablesarrayNoPipeline variables in array format ([{key, value, variable_type}]).
inputshashNoPipeline input parameters as key-value pairs.

Examples:

  • Create a pipeline:

    plaintext
    Create a pipeline on the main branch for project gitlab-org/gitlab
    
  • Retry a pipeline:

    plaintext
    Retry failed jobs in pipeline 12345 for project gitlab-org/gitlab
    
  • Cancel a pipeline:

    plaintext
    Cancel pipeline 12345 in project gitlab-org/gitlab
    

manage_pipeline

{{< history >}}

  • Introduced in GitLab 18.10.
  • Removed the list action in favor of the list_pipelines tool in GitLab 19.3.
  • Removed the create, retry, and cancel actions in favor of the save_pipeline tool in GitLab 19.3.

{{< /history >}}

Updates pipeline metadata or deletes a pipeline in a GitLab project. To create, retry, or cancel a pipeline, use the save_pipeline tool instead. To list pipelines, use the list_pipelines tool instead.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
pipeline_idintegerYesID of the pipeline. If only this parameter is set, deletes a pipeline and all related data.
namestringNoName of the pipeline. If this parameter and pipeline_id are set, updates the pipeline metadata.

Examples:

  • Update a pipeline:

    plaintext
    Rename pipeline 12345 to "My deploy pipeline" in project gitlab-org/gitlab
    
  • Delete a pipeline:

    plaintext
    Delete pipeline 12345 in project gitlab-org/gitlab
    

create_workitem_note

{{< history >}}

{{< /history >}}

Creates a new note (comment) on a GitLab work item.

ParameterTypeRequiredDescription
bodystringYesContent of the note.
urlstringNoURL for the work item. Required if group_id or project_id and work_item_iid are missing.
group_idstringNoID or path of the group. Required if url and project_id are missing.
project_idstringNoID or path of the project. Required if url and group_id are missing.
work_item_iidintegerNoInternal ID of the work item. Required if url is missing.
internalbooleanNoMarks the note as internal (visible only to users with the Reporter, Developer, Maintainer, or Owner role for the project). Default is false.
discussion_idstringNoGlobal ID of the discussion to reply to (in the format gid://gitlab/Discussion/<id>).

Example:

plaintext
Add a comment "This looks good to me" to work item 42 in project gitlab-org/gitlab

get_workitem_notes

{{< history >}}

{{< /history >}}

Retrieves all notes (comments) for a specific GitLab work item.

ParameterTypeRequiredDescription
urlstringNoURL for the work item. Required if group_id or project_id and work_item_iid are missing.
group_idstringNoID or path of the group. Required if url and project_id are missing.
project_idstringNoID or path of the project. Required if url and group_id are missing.
work_item_iidintegerNoInternal ID of the work item. Required if url is missing.
afterstringNoCursor for forward pagination.
beforestringNoCursor for backward pagination.
firstintegerNoNumber of notes to return for forward pagination.
lastintegerNoNumber of notes to return for backward pagination.

Example:

plaintext
Show me all comments on work item 42 in project gitlab-org/gitlab

{{< history >}}

{{< /history >}}

Links a work item to one or more other work items with a relationship type.

ParameterTypeRequiredDescription
work_items_idsarray of stringsYesGlobal IDs of the work items to link to (in the format gid://gitlab/WorkItem/<id>). Maximum 10 items.
urlstringNoURL for the source work item. Required if group_id or project_id and work_item_iid are missing.
group_idstringNoID or path of the group. Required if url and project_id are missing.
project_idstringNoID or path of the project. Required if url and group_id are missing.
work_item_iidintegerNoInternal ID of the source work item. Required if url is missing.
link_typestringNoType of relationship. One of relates_to, blocks, or blocked_by. Default is relates_to. The blocks and blocked_by types require GitLab Premium or Ultimate.

Example:

plaintext
Mark work item 42 in project gitlab-org/gitlab as blocked by work item 40

get_saved_view_work_items

{{< history >}}

{{< /history >}}

Retrieves a saved view and its list of work items from a namespace. The tool applies the filters and the sort order in the saved view to the returned work items.

ParameterTypeRequiredDescription
saved_view_idstringYesGlobal ID of the saved view (in the format gid://gitlab/WorkItems::SavedViews::SavedView/<id>).
urlstringNoURL for the namespace (project or group). Required if group_id or project_id is missing.
group_idstringNoID or path of the group. Required if url and project_id are missing.
project_idstringNoID or path of the project. Required if url and group_id are missing.
afterstringNoCursor for forward pagination.
firstintegerNoNumber of work items to return. Maximum 100.

Example:

plaintext
Show me the work items in this saved view: <URL>

{{< history >}}

  • Introduced in GitLab 18.4.
  • Searching groups and projects and ordering and sorting results added in GitLab 18.6.
  • Renamed from gitlab_search to search in GitLab 18.8.

{{< /history >}}

Searches for a term across the entire GitLab instance with the search API. This tool is available for global, group, and project search. Available scopes depend on the search type.

ParameterTypeRequiredDescription
scopestringYesSearch scope (for example, work_items, merge_requests, or projects).
searchstringYesSearch term.
group_idstringNoID or URL-encoded path of the group you want to search.
project_idstringNoID or URL-encoded path of the project you want to search.
statestringNoState of search results (for work_items and merge_requests).
confidentialbooleanNoFilters results by confidentiality (for work_items). Default is false.
fieldsarray of stringsNoArray of fields you want to search (for work_items and merge_requests).
order_bystringNoAttribute to order results by. Default is created_at for basic search and relevance for advanced search.
sortstringNoSort direction for results. Default is desc.
per_pageintegerNoNumber of results per page. Default is 20.
pageintegerNoCurrent page number. Default is 1.

Example:

plaintext
Search issues for "flaky test" across GitLab

search_labels

{{< history >}}

{{< /history >}}

Searches for labels in a GitLab project or group.

ParameterTypeRequiredDescription
full_pathstringYesFull path of the project or group (for example, group/project).
is_projectbooleanYesWhether to search in a project (true) or group (false).
searchstringNoSearch term to filter labels by title.

When you search group labels, the results include labels from ancestor and descendant groups.

Example:

plaintext
Show me all labels in project gitlab-org/gitlab

list_wiki_pages

{{< history >}}

{{< /history >}}

Lists the wiki pages in a GitLab project or group.

ParameterTypeRequiredDescription
project_idstringNoFull path or numeric ID of the project (for example, gitlab-org/gitlab or 278964).
group_idstringNoFull path or numeric ID of the group (for example, gitlab-org or 9970).
firstintegerNoNumber of wiki pages to return for forward pagination (maximum 100).
afterstringNoCursor for forward pagination.

Provide only one project_id or group_id. Each call returns a single page of results. If more pages exist, the response includes an end_cursor you can pass as after to fetch the next page.

Example:

plaintext
List the wiki pages in gitlab-org/gitlab

{{< details >}}

  • Add-on: GitLab Duo Core, Pro, or Enterprise
  • Offering: GitLab.com, GitLab Self-Managed

{{< /details >}}

{{< history >}}

{{< /history >}}

[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.

Searches for relevant code snippets in a GitLab project. For more information, including setup and enablement, see semantic code search.

ParameterTypeRequiredDescription
semantic_querystringYesSearch query for the code.
project_idstringYesID or path of the project.
directory_pathstringNoPath of the directory (for example, app/services/).
knnintegerNoNumber of nearest neighbors used to find similar code snippets. Default is 64.
limitintegerNoMaximum number of results to return. Default is 20.

For best results, describe the functionality or behavior you're interested in rather than using generic keywords or specific function or variable names.

Example:

plaintext
How are authorizations managed in this project?

attach_scan_profile

{{< history >}}

{{< /history >}}

Attaches the given security scan profile to the specified projects, or to all projects under the specified groups.

ParameterTypeRequiredDescription
security_scan_profile_idstringYesGlobal ID of the security scan profile (for example, gid://gitlab/Security::ScanProfile/1).
project_idsarray of stringsNoArray of global IDs of projects (for example, [gid://gitlab/Project/1]). This is required unless group_ids is provided.
group_idsarray of stringsNoArray of global IDs of groups (for example, [gid://gitlab/Group/1]). This is required unless project_ids is provided.

Example:

plaintext
Attach `gid://gitlab/Security::ScanProfile/1` to all projects under `gid://gitlab/Group/1`.