Gitlab

GitlabTools provides read-focused access to GitLab projects, merge requests, and issues.

GitlabTools enables an Agent to read GitLab project, merge request, and issue data.

Prerequisites

Install the required dependencies:

1uv pip install -U python-gitlab httpx

Set environment variables:

1export GITLAB_ACCESS_TOKEN="YOUR_GITLAB_ACCESS_TOKEN"
2export GITLAB_BASE_URL="https://gitlab.com"

GITLAB_BASE_URL is optional. If unset, https://gitlab.com is used.

Example

1from kern.agent import Agent
2from kern.tools.gitlab import GitlabTools
3
4agent = Agent(
5 instructions=[
6 "Use GitLab tools to answer repository questions.",
7 "Use read-only operations unless explicitly asked to modify data.",
8 ],
9 tools=[GitlabTools()],
10)
11
12agent.print_response(
13 "List open merge requests for project 'gitlab-org/gitlab' and summarize the top 5 by recency.",
14 markdown=True,
15)

Toolkit Params

ParameterTypeDefaultDescription
access_tokenOptional[str]NoneGitLab access token. If not provided, uses GITLAB_ACCESS_TOKEN.
base_urlOptional[str]NoneGitLab instance URL. If not provided, uses GITLAB_BASE_URL, then https://gitlab.com.
timeoutfloat30HTTP timeout in seconds for API requests.
enable_list_projectsboolTrueRegister the list_projects tool.
enable_get_projectsboolTrueRegister the get_project tool.
enable_list_merge_requestsboolTrueRegister the list_merge_requests tool.
enable_get_merge_requestboolTrueRegister the get_merge_request tool.
enable_list_issuesboolTrueRegister the list_issues tool.
include_toolsOptional[list[str]]NoneOptional inherited toolkit filter to include only specific tools.
exclude_toolsOptional[list[str]]NoneOptional inherited toolkit filter to exclude specific tools.

Toolkit Functions

FunctionDescription
list_projectsList projects visible to the authenticated user. Supports search, owned, membership, and pagination filters.
get_projectGet details for one project by project ID or group/project path.
list_merge_requestsList merge requests for a project with state, branch, author, and pagination filters.
get_merge_requestGet details for one merge request by project and merge request IID.
list_issuesList project issues with state, labels, author, assignee, search, and pagination filters.

Use the enable_* constructor toggles to register only selected GitLab tools. You can also use include_tools or exclude_tools to filter available tools. See selecting tools.

Developer Resources