gitlab-api


Namegitlab-api JSON
Version 25.8.17 PyPI version JSON
download
home_pageNone
SummaryGitLab API Python Wrapper
upload_time2025-09-08 01:25:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GitLab API

![PyPI - Version](https://img.shields.io/pypi/v/gitlab-api)
![PyPI - Downloads](https://img.shields.io/pypi/dd/gitlab-api)
![GitHub Repo stars](https://img.shields.io/github/stars/Knuckles-Team/gitlab-api)
![GitHub forks](https://img.shields.io/github/forks/Knuckles-Team/gitlab-api)
![GitHub contributors](https://img.shields.io/github/contributors/Knuckles-Team/gitlab-api)
![PyPI - License](https://img.shields.io/pypi/l/gitlab-api)
![GitHub](https://img.shields.io/github/license/Knuckles-Team/gitlab-api)

![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/Knuckles-Team/gitlab-api)
![GitHub pull requests](https://img.shields.io/github/issues-pr/Knuckles-Team/gitlab-api)
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/Knuckles-Team/gitlab-api)
![GitHub issues](https://img.shields.io/github/issues/Knuckles-Team/gitlab-api)

![GitHub top language](https://img.shields.io/github/languages/top/Knuckles-Team/gitlab-api)
![GitHub language count](https://img.shields.io/github/languages/count/Knuckles-Team/gitlab-api)
![GitHub repo size](https://img.shields.io/github/repo-size/Knuckles-Team/gitlab-api)
![GitHub repo file count (file type)](https://img.shields.io/github/directory-file-count/Knuckles-Team/gitlab-api)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/gitlab-api)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/gitlab-api)

*Version: 25.8.17*

Pythonic GitLab API Library

GitLab MCP Server for Agentic AI! Get started with Pip or Docker

Includes a large portion of useful API calls to GitLab and SQLAlchemy Models to handle loading API calls directly to a database!

This repository is actively maintained - Contributions are welcome!

Additional Features:
- All responses are returned as native Pydantic models
- Save Pydantic models to pickle files locally
- Easily convert Pydantic to SQLAlchemy models for quick database insertion

### API Calls:
- Branches
- Commits
- Deploy Tokens
- Groups
- Jobs
- Members
- Merge Request
- Merge Request Rules
- Merge Request Rule Settings
- Namespaces
- Packages
- Pipeline
- Pipeline Schedules
- Projects
- Protected Branches
- Releases
- Runners
- Users
- Wiki
- Environments
- Protected Environments
- Tags
- Protected Tags
- Custom Endpoint

If your API call isn't supported, you can always run the standard custom API endpoint function to get/post/put/delete and endpoint



<details>
  <summary><b>Usage:</b></summary>

### Using an an MCP Server:

AI Prompt:
```text
Get me the details of my gitlab project with id 420.
```

AI Response:
```text
Here are the details for your GitLab project:

Project Name: Docker Registry

Project ID: 420

Namespace: Homelab

Visibility: Internal

Created: November 13, 1999

Default Branch: main

Last Activity: August 20, 2025

Web URL:
http://gitlab.arpa/homelab/docker-registry

This project is configured with container registry capabilities
and supports CI/CD pipelines, merge requests, and issue tracking.
It is currently active with no open issues and follows
the default branch strategy for its workflow.
```

AI Prompt:
```text
Run the gitlab pipeline for this project id 133 on the main branch
```

AI Response:
```text
The pipeline has been successfully created for the project ID 133 on the main reference. Here are the details:

Pipeline ID: 20601
Reference: main
SHA: asidfaskdjvalksdjv
Status: Created
Web URL:

Created At: 2025-08-27T02:49:20.068Z
The pipeline is now queued and will start executing soon. Let me know if you'd like further details or actions!
```

AI Prompt:
```text
Create a branch called "test" from the main branch in this gitlab project with id 133
```

AI Response:
```text
The branch test has been successfully created from the main branch in the project with ID 133.

Branch Details:
Name: test
URL:

Commit:
Short ID: 1c3775ac
Message: "Add adgurad."
Author: KnucklesSG1
Committed Date: August 25, 2025, at 05:03:01 (UTC-05:00)
This branch is not protected, and it is not set as the default branch.
The branch is currently unmerged and can be pushed to by authorized users.

Let me know if you'd like further actions (e.g., merging, pushing changes)!
```

AI Prompt:
```text
Create a merge request for project 133 from the test branch to the main branch with a title of
"This is a merge request by Qwen3" and a description of "This is a description populated by qwen3 LLM"
```

AI Response:
```text
The merge request has been successfully created with the following details:

Title: This is a merge request by Qwen3
Description: This is a description populated by qwen3 LLM
Source Branch: test
Target Branch: main
Project: homelab/containers/services/project
Merge Request URL:

Status: Opened
Created At: 2025-08-27T03:15:51.520000Z
The merge request is currently in the "preparing" state and is ready for review. Let me know if you'd like further actions, such as assigning reviewers or approving the merge! 😊
```

### Use API directly

```python
#!/usr/bin/python

import gitlab_api
from gitlab_api import pydantic_to_sqlalchemy, upsert, save_model, load_model
from gitlab_api.gitlab_db_models import (
    BaseDBModel as Base,
)
import urllib3
import os
from urllib.parse import quote_plus

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

gitlab_token = os.environ["GITLAB_TOKEN"]
postgres_username = os.environ["POSTGRES_USERNAME"]
postgres_password = os.environ["POSTGRES_PASSWORD"]
postgres_db_host = os.environ["POSTGRES_DB_HOST"]
postgres_port = os.environ["POSTGRES_PORT"]
postgres_db_name = os.environ["POSTGRES_DB_NAME"]


if __name__ == "__main__":
    print("Creating GitLab Client...")
    client = gitlab_api.Api(
        url="http://gitlab.arpa/api/v4/",
        token=gitlab_token,
        verify=False,
    )
    print("GitLab Client Created\n\n")

    print("\nFetching User Data...")
    user_response = client.get_users(active=True, humans=True)
    print(
        f"Users ({len(user_response.data)}) Fetched - "
        f"Status: {user_response.status_code}\n"
    )

    print("\nFetching Namespace Data...")
    namespace_response = client.get_namespaces()
    print(
        f"Namespaces ({len(namespace_response.data)}) Fetched - "
        f"Status: {namespace_response.status_code}\n"
    )

    print("\nFetching Project Data...")
    project_response = client.get_nested_projects_by_group(group_id=2, per_page=100)
    print(
        f"Projects ({len(project_response.data)}) Fetched - "
        f"Status: {project_response.status_code}\n"
    )

    print("\nFetching Merge Request Data...")
    merge_request_response = client.get_group_merge_requests(
        argument="state=all", group_id=2
    )

    print(
        f"\nMerge Requests ({len(merge_request_response.data)}) Fetched - "
        f"Status: {merge_request_response.status_code}\n"
    )

    # Pipeline Jobs table
    pipeline_job_response = None
    for project in project_response.data:
        job_response = client.get_project_jobs(project_id=project.id)
        if (
                not pipeline_job_response
                and hasattr(job_response, "data")
                and len(job_response.data) > 0
        ):
            pipeline_job_response = job_response
        elif (
                pipeline_job_response
                and hasattr(job_response, "data")
                and len(job_response.data) > 0
        ):
            pipeline_job_response.data.extend(job_response.data)
            print(
                f"Pipeline Jobs ({len(getattr(pipeline_job_response, 'data', []))}) "
                f"Fetched for Project ({project.id}) - "
                f"Status: {pipeline_job_response.status_code}\n"
            )

    print("Saving Pydantic Models...")
    user_file = save_model(model=user_response, file_name="user_model", file_path=".")
    namespace_file = save_model(
        model=namespace_response, file_name="namespace_model", file_path="."
    )
    project_file = save_model(
        model=project_response, file_name="project_model", file_path="."
    )
    merge_request_file = save_model(
        model=merge_request_response, file_name="merge_request_model", file_path="."
    )
    pipeline_job_file = save_model(
        model=pipeline_job_response, file_name="pipeline_job_model", file_path="."
    )
    print("Models Saved")

    print("Loading Pydantic Models...")
    user_response = load_model(file=user_file)
    namespace_response = load_model(file=namespace_file)
    project_response = load_model(file=project_file)
    merge_request_response = load_model(file=merge_request_file)
    pipeline_job_response = load_model(file=pipeline_job_file)
    print("Models Loaded")

    print("Converting Pydantic to SQLAlchemy model...")
    user_db_model = pydantic_to_sqlalchemy(schema=user_response)
    print(f"Database Models: {user_db_model}\n")

    print("Converting Pydantic to SQLAlchemy model...")
    namespace_db_model = pydantic_to_sqlalchemy(schema=namespace_response)
    print(f"Database Models: {namespace_db_model}\n")

    print("Converting Pydantic to SQLAlchemy model...")
    project_db_model = pydantic_to_sqlalchemy(schema=project_response)
    print(f"Database Models: {project_db_model}\n")

    print("Converting Pydantic to SQLAlchemy model...")
    merge_request_db_model = pydantic_to_sqlalchemy(schema=merge_request_response)
    print(f"Database Models: {merge_request_db_model}\n")

    print("Converting Pydantic to SQLAlchemy model...")
    pipeline_db_model = pydantic_to_sqlalchemy(schema=pipeline_job_response)
    print(f"Database Models: {pipeline_db_model}\n")

    print("Creating Engine")
    engine = create_engine(
        f"postgresql://{postgres_username}:{quote_plus(postgres_password)}@"
        f"{postgres_db_host}:{postgres_port}/{postgres_db_name}"
    )
    print("Engine Created\n\n")

    print("Creating Tables...")
    Base.metadata.create_all(engine)
    print("Tables Created\n\n")

    print("Creating Session...")
    Session = sessionmaker(bind=engine)
    session = Session()
    print("Session Created\n\n")

    print(f"Inserting ({len(user_response.data)}) Users Into Database...")
    upsert(session=session, model=user_db_model)
    print("Users Synchronization Complete!\n")

    print(f"Inserting ({len(namespace_response.data)}) Namespaces Into Database...")
    upsert(session=session, model=namespace_db_model)
    print("Namespaces Synchronization Complete!\n")

    print(f"Inserting ({len(project_response.data)}) Projects Into Database...\n")
    upsert(session=session, model=project_db_model)
    print("Projects Synchronization Complete!\n")

    print(
        f"Inserting ({len(merge_request_response.data)}) Merge Requests Into Database..."
    )
    upsert(session=session, model=merge_request_db_model)
    print("Merge Request Synchronization Complete!\n")

    print(
        f"Inserting ({len(pipeline_job_response.data)}) Pipeline Jobs Into Database..."
    )
    upsert(session=session, model=pipeline_db_model)
    print("Pipeline Jobs Synchronization Complete!\n")

    session.close()
    print("Session Closed")
```

### Use with AI

Deploy MCP Server as a Service
```bash
docker pull knucklessg1/gitlab:latest
```

Modify the `compose.yml`

```compose
services:
  gitlab-mcp:
    image: knucklessg1/gitlab:latest
    environment:
      - HOST=0.0.0.0
      - PORT=8003
    ports:
      - 8003:8003
```

Configure `mcp.json`

Recommended: Store secrets in environment variables with lookup in JSON file.

For Testing Only: Plain text storage will also work, although **not** recommended.

```json
{
  "mcpServers": {
    "gitlab": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "gitlab-api",
        "gitlab-mcp"
      ],
      "env": {
        "GITLAB_INSTANCE": "https://gitlab.com/api/v4/", // Optional
        "ACCESS_TOKEN": "glpat-askdfalskdvjas",          // Optional
        "VERIFY": "True"                                 // Optional
      },
      "timeout": 200000
    }
  }
}
```

```

</details>

<details>
  <summary><b>Installation Instructions:</b></summary>

Install Python Package

```bash
python -m pip install gitlab-api
```

</details>

<details>
  <summary><b>Tests:</b></summary>

pre-commit check
```bash
pre-commit run --all-files
```

pytest
```bash
python -m pip install -r test-requirements.txt
pytest ./test/test_gitlab_models.py
```

Full pytests

```bash
rm -rf ./dist/* \
&& python setup.py bdist_wheel --universal \
&& python -m pip uninstall gitlab-api -y \
&& python -m pip install  ./dist/*.whl \
&& pytest -vv ./test/test_gitlab_models.py \
&& pytest -vv ./test/test_gitlab_db_models.py \
&& python ./test/test_sqlalchemy.py
```

Validate MCP Server

```bash
npx @modelcontextprotocol/inspector gitlab-mcp
```

</details>

<details>
  <summary><b>Repository Owners:</b></summary>

<img width="100%" height="180em" src="https://github-readme-stats.vercel.app/api?username=Knucklessg1&show_icons=true&hide_border=true&&count_private=true&include_all_commits=true" />

![GitHub followers](https://img.shields.io/github/followers/Knucklessg1)
![GitHub User's stars](https://img.shields.io/github/stars/Knucklessg1)

</details>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gitlab-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Audel Rouhi <knucklessg1@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6d/b7/46a929978d711897495c1230d58935cb9cb67b7685ba1aca330f5eacd6a6/gitlab_api-25.8.17.tar.gz",
    "platform": null,
    "description": "# GitLab API\n\n![PyPI - Version](https://img.shields.io/pypi/v/gitlab-api)\n![PyPI - Downloads](https://img.shields.io/pypi/dd/gitlab-api)\n![GitHub Repo stars](https://img.shields.io/github/stars/Knuckles-Team/gitlab-api)\n![GitHub forks](https://img.shields.io/github/forks/Knuckles-Team/gitlab-api)\n![GitHub contributors](https://img.shields.io/github/contributors/Knuckles-Team/gitlab-api)\n![PyPI - License](https://img.shields.io/pypi/l/gitlab-api)\n![GitHub](https://img.shields.io/github/license/Knuckles-Team/gitlab-api)\n\n![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/Knuckles-Team/gitlab-api)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/Knuckles-Team/gitlab-api)\n![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/Knuckles-Team/gitlab-api)\n![GitHub issues](https://img.shields.io/github/issues/Knuckles-Team/gitlab-api)\n\n![GitHub top language](https://img.shields.io/github/languages/top/Knuckles-Team/gitlab-api)\n![GitHub language count](https://img.shields.io/github/languages/count/Knuckles-Team/gitlab-api)\n![GitHub repo size](https://img.shields.io/github/repo-size/Knuckles-Team/gitlab-api)\n![GitHub repo file count (file type)](https://img.shields.io/github/directory-file-count/Knuckles-Team/gitlab-api)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/gitlab-api)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/gitlab-api)\n\n*Version: 25.8.17*\n\nPythonic GitLab API Library\n\nGitLab MCP Server for Agentic AI! Get started with Pip or Docker\n\nIncludes a large portion of useful API calls to GitLab and SQLAlchemy Models to handle loading API calls directly to a database!\n\nThis repository is actively maintained - Contributions are welcome!\n\nAdditional Features:\n- All responses are returned as native Pydantic models\n- Save Pydantic models to pickle files locally\n- Easily convert Pydantic to SQLAlchemy models for quick database insertion\n\n### API Calls:\n- Branches\n- Commits\n- Deploy Tokens\n- Groups\n- Jobs\n- Members\n- Merge Request\n- Merge Request Rules\n- Merge Request Rule Settings\n- Namespaces\n- Packages\n- Pipeline\n- Pipeline Schedules\n- Projects\n- Protected Branches\n- Releases\n- Runners\n- Users\n- Wiki\n- Environments\n- Protected Environments\n- Tags\n- Protected Tags\n- Custom Endpoint\n\nIf your API call isn't supported, you can always run the standard custom API endpoint function to get/post/put/delete and endpoint\n\n\n\n<details>\n  <summary><b>Usage:</b></summary>\n\n### Using an an MCP Server:\n\nAI Prompt:\n```text\nGet me the details of my gitlab project with id 420.\n```\n\nAI Response:\n```text\nHere are the details for your GitLab project:\n\nProject Name: Docker Registry\n\nProject ID: 420\n\nNamespace: Homelab\n\nVisibility: Internal\n\nCreated: November 13, 1999\n\nDefault Branch: main\n\nLast Activity: August 20, 2025\n\nWeb URL:\nhttp://gitlab.arpa/homelab/docker-registry\n\nThis project is configured with container registry capabilities\nand supports CI/CD pipelines, merge requests, and issue tracking.\nIt is currently active with no open issues and follows\nthe default branch strategy for its workflow.\n```\n\nAI Prompt:\n```text\nRun the gitlab pipeline for this project id 133 on the main branch\n```\n\nAI Response:\n```text\nThe pipeline has been successfully created for the project ID 133 on the main reference. Here are the details:\n\nPipeline ID: 20601\nReference: main\nSHA: asidfaskdjvalksdjv\nStatus: Created\nWeb URL:\n\nCreated At: 2025-08-27T02:49:20.068Z\nThe pipeline is now queued and will start executing soon. Let me know if you'd like further details or actions!\n```\n\nAI Prompt:\n```text\nCreate a branch called \"test\" from the main branch in this gitlab project with id 133\n```\n\nAI Response:\n```text\nThe branch test has been successfully created from the main branch in the project with ID 133.\n\nBranch Details:\nName: test\nURL:\n\nCommit:\nShort ID: 1c3775ac\nMessage: \"Add adgurad.\"\nAuthor: KnucklesSG1\nCommitted Date: August 25, 2025, at 05:03:01 (UTC-05:00)\nThis branch is not protected, and it is not set as the default branch.\nThe branch is currently unmerged and can be pushed to by authorized users.\n\nLet me know if you'd like further actions (e.g., merging, pushing changes)!\n```\n\nAI Prompt:\n```text\nCreate a merge request for project 133 from the test branch to the main branch with a title of\n\"This is a merge request by Qwen3\" and a description of \"This is a description populated by qwen3 LLM\"\n```\n\nAI Response:\n```text\nThe merge request has been successfully created with the following details:\n\nTitle: This is a merge request by Qwen3\nDescription: This is a description populated by qwen3 LLM\nSource Branch: test\nTarget Branch: main\nProject: homelab/containers/services/project\nMerge Request URL:\n\nStatus: Opened\nCreated At: 2025-08-27T03:15:51.520000Z\nThe merge request is currently in the \"preparing\" state and is ready for review. Let me know if you'd like further actions, such as assigning reviewers or approving the merge! \ud83d\ude0a\n```\n\n### Use API directly\n\n```python\n#!/usr/bin/python\n\nimport gitlab_api\nfrom gitlab_api import pydantic_to_sqlalchemy, upsert, save_model, load_model\nfrom gitlab_api.gitlab_db_models import (\n    BaseDBModel as Base,\n)\nimport urllib3\nimport os\nfrom urllib.parse import quote_plus\n\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker\n\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\ngitlab_token = os.environ[\"GITLAB_TOKEN\"]\npostgres_username = os.environ[\"POSTGRES_USERNAME\"]\npostgres_password = os.environ[\"POSTGRES_PASSWORD\"]\npostgres_db_host = os.environ[\"POSTGRES_DB_HOST\"]\npostgres_port = os.environ[\"POSTGRES_PORT\"]\npostgres_db_name = os.environ[\"POSTGRES_DB_NAME\"]\n\n\nif __name__ == \"__main__\":\n    print(\"Creating GitLab Client...\")\n    client = gitlab_api.Api(\n        url=\"http://gitlab.arpa/api/v4/\",\n        token=gitlab_token,\n        verify=False,\n    )\n    print(\"GitLab Client Created\\n\\n\")\n\n    print(\"\\nFetching User Data...\")\n    user_response = client.get_users(active=True, humans=True)\n    print(\n        f\"Users ({len(user_response.data)}) Fetched - \"\n        f\"Status: {user_response.status_code}\\n\"\n    )\n\n    print(\"\\nFetching Namespace Data...\")\n    namespace_response = client.get_namespaces()\n    print(\n        f\"Namespaces ({len(namespace_response.data)}) Fetched - \"\n        f\"Status: {namespace_response.status_code}\\n\"\n    )\n\n    print(\"\\nFetching Project Data...\")\n    project_response = client.get_nested_projects_by_group(group_id=2, per_page=100)\n    print(\n        f\"Projects ({len(project_response.data)}) Fetched - \"\n        f\"Status: {project_response.status_code}\\n\"\n    )\n\n    print(\"\\nFetching Merge Request Data...\")\n    merge_request_response = client.get_group_merge_requests(\n        argument=\"state=all\", group_id=2\n    )\n\n    print(\n        f\"\\nMerge Requests ({len(merge_request_response.data)}) Fetched - \"\n        f\"Status: {merge_request_response.status_code}\\n\"\n    )\n\n    # Pipeline Jobs table\n    pipeline_job_response = None\n    for project in project_response.data:\n        job_response = client.get_project_jobs(project_id=project.id)\n        if (\n                not pipeline_job_response\n                and hasattr(job_response, \"data\")\n                and len(job_response.data) > 0\n        ):\n            pipeline_job_response = job_response\n        elif (\n                pipeline_job_response\n                and hasattr(job_response, \"data\")\n                and len(job_response.data) > 0\n        ):\n            pipeline_job_response.data.extend(job_response.data)\n            print(\n                f\"Pipeline Jobs ({len(getattr(pipeline_job_response, 'data', []))}) \"\n                f\"Fetched for Project ({project.id}) - \"\n                f\"Status: {pipeline_job_response.status_code}\\n\"\n            )\n\n    print(\"Saving Pydantic Models...\")\n    user_file = save_model(model=user_response, file_name=\"user_model\", file_path=\".\")\n    namespace_file = save_model(\n        model=namespace_response, file_name=\"namespace_model\", file_path=\".\"\n    )\n    project_file = save_model(\n        model=project_response, file_name=\"project_model\", file_path=\".\"\n    )\n    merge_request_file = save_model(\n        model=merge_request_response, file_name=\"merge_request_model\", file_path=\".\"\n    )\n    pipeline_job_file = save_model(\n        model=pipeline_job_response, file_name=\"pipeline_job_model\", file_path=\".\"\n    )\n    print(\"Models Saved\")\n\n    print(\"Loading Pydantic Models...\")\n    user_response = load_model(file=user_file)\n    namespace_response = load_model(file=namespace_file)\n    project_response = load_model(file=project_file)\n    merge_request_response = load_model(file=merge_request_file)\n    pipeline_job_response = load_model(file=pipeline_job_file)\n    print(\"Models Loaded\")\n\n    print(\"Converting Pydantic to SQLAlchemy model...\")\n    user_db_model = pydantic_to_sqlalchemy(schema=user_response)\n    print(f\"Database Models: {user_db_model}\\n\")\n\n    print(\"Converting Pydantic to SQLAlchemy model...\")\n    namespace_db_model = pydantic_to_sqlalchemy(schema=namespace_response)\n    print(f\"Database Models: {namespace_db_model}\\n\")\n\n    print(\"Converting Pydantic to SQLAlchemy model...\")\n    project_db_model = pydantic_to_sqlalchemy(schema=project_response)\n    print(f\"Database Models: {project_db_model}\\n\")\n\n    print(\"Converting Pydantic to SQLAlchemy model...\")\n    merge_request_db_model = pydantic_to_sqlalchemy(schema=merge_request_response)\n    print(f\"Database Models: {merge_request_db_model}\\n\")\n\n    print(\"Converting Pydantic to SQLAlchemy model...\")\n    pipeline_db_model = pydantic_to_sqlalchemy(schema=pipeline_job_response)\n    print(f\"Database Models: {pipeline_db_model}\\n\")\n\n    print(\"Creating Engine\")\n    engine = create_engine(\n        f\"postgresql://{postgres_username}:{quote_plus(postgres_password)}@\"\n        f\"{postgres_db_host}:{postgres_port}/{postgres_db_name}\"\n    )\n    print(\"Engine Created\\n\\n\")\n\n    print(\"Creating Tables...\")\n    Base.metadata.create_all(engine)\n    print(\"Tables Created\\n\\n\")\n\n    print(\"Creating Session...\")\n    Session = sessionmaker(bind=engine)\n    session = Session()\n    print(\"Session Created\\n\\n\")\n\n    print(f\"Inserting ({len(user_response.data)}) Users Into Database...\")\n    upsert(session=session, model=user_db_model)\n    print(\"Users Synchronization Complete!\\n\")\n\n    print(f\"Inserting ({len(namespace_response.data)}) Namespaces Into Database...\")\n    upsert(session=session, model=namespace_db_model)\n    print(\"Namespaces Synchronization Complete!\\n\")\n\n    print(f\"Inserting ({len(project_response.data)}) Projects Into Database...\\n\")\n    upsert(session=session, model=project_db_model)\n    print(\"Projects Synchronization Complete!\\n\")\n\n    print(\n        f\"Inserting ({len(merge_request_response.data)}) Merge Requests Into Database...\"\n    )\n    upsert(session=session, model=merge_request_db_model)\n    print(\"Merge Request Synchronization Complete!\\n\")\n\n    print(\n        f\"Inserting ({len(pipeline_job_response.data)}) Pipeline Jobs Into Database...\"\n    )\n    upsert(session=session, model=pipeline_db_model)\n    print(\"Pipeline Jobs Synchronization Complete!\\n\")\n\n    session.close()\n    print(\"Session Closed\")\n```\n\n### Use with AI\n\nDeploy MCP Server as a Service\n```bash\ndocker pull knucklessg1/gitlab:latest\n```\n\nModify the `compose.yml`\n\n```compose\nservices:\n  gitlab-mcp:\n    image: knucklessg1/gitlab:latest\n    environment:\n      - HOST=0.0.0.0\n      - PORT=8003\n    ports:\n      - 8003:8003\n```\n\nConfigure `mcp.json`\n\nRecommended: Store secrets in environment variables with lookup in JSON file.\n\nFor Testing Only: Plain text storage will also work, although **not** recommended.\n\n```json\n{\n  \"mcpServers\": {\n    \"gitlab\": {\n      \"command\": \"uv\",\n      \"args\": [\n        \"run\",\n        \"--with\",\n        \"gitlab-api\",\n        \"gitlab-mcp\"\n      ],\n      \"env\": {\n        \"GITLAB_INSTANCE\": \"https://gitlab.com/api/v4/\", // Optional\n        \"ACCESS_TOKEN\": \"glpat-askdfalskdvjas\",          // Optional\n        \"VERIFY\": \"True\"                                 // Optional\n      },\n      \"timeout\": 200000\n    }\n  }\n}\n```\n\n```\n\n</details>\n\n<details>\n  <summary><b>Installation Instructions:</b></summary>\n\nInstall Python Package\n\n```bash\npython -m pip install gitlab-api\n```\n\n</details>\n\n<details>\n  <summary><b>Tests:</b></summary>\n\npre-commit check\n```bash\npre-commit run --all-files\n```\n\npytest\n```bash\npython -m pip install -r test-requirements.txt\npytest ./test/test_gitlab_models.py\n```\n\nFull pytests\n\n```bash\nrm -rf ./dist/* \\\n&& python setup.py bdist_wheel --universal \\\n&& python -m pip uninstall gitlab-api -y \\\n&& python -m pip install  ./dist/*.whl \\\n&& pytest -vv ./test/test_gitlab_models.py \\\n&& pytest -vv ./test/test_gitlab_db_models.py \\\n&& python ./test/test_sqlalchemy.py\n```\n\nValidate MCP Server\n\n```bash\nnpx @modelcontextprotocol/inspector gitlab-mcp\n```\n\n</details>\n\n<details>\n  <summary><b>Repository Owners:</b></summary>\n\n<img width=\"100%\" height=\"180em\" src=\"https://github-readme-stats.vercel.app/api?username=Knucklessg1&show_icons=true&hide_border=true&&count_private=true&include_all_commits=true\" />\n\n![GitHub followers](https://img.shields.io/github/followers/Knucklessg1)\n![GitHub User's stars](https://img.shields.io/github/stars/Knucklessg1)\n\n</details>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "GitLab API Python Wrapper",
    "version": "25.8.17",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8838a29617dd2e1ec23c80520dd8206018cab7df3817e2f6faaeba528b23b156",
                "md5": "b1056c46b727db4c166bdebd6fd30a93",
                "sha256": "002d2a2c3dc8124ef663cde279946449e7dac6f2b20c0301cdc6a8c7891cc98d"
            },
            "downloads": -1,
            "filename": "gitlab_api-25.8.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b1056c46b727db4c166bdebd6fd30a93",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 144061,
            "upload_time": "2025-09-08T01:24:59",
            "upload_time_iso_8601": "2025-09-08T01:24:59.780644Z",
            "url": "https://files.pythonhosted.org/packages/88/38/a29617dd2e1ec23c80520dd8206018cab7df3817e2f6faaeba528b23b156/gitlab_api-25.8.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6db746a929978d711897495c1230d58935cb9cb67b7685ba1aca330f5eacd6a6",
                "md5": "44d43b8e7041031bb454e8e6cbfa0ed1",
                "sha256": "bb4d0d8c1b1f3ad81095aafe61a769a057774c12e0992c82da315a2a190da89b"
            },
            "downloads": -1,
            "filename": "gitlab_api-25.8.17.tar.gz",
            "has_sig": false,
            "md5_digest": "44d43b8e7041031bb454e8e6cbfa0ed1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 141362,
            "upload_time": "2025-09-08T01:25:01",
            "upload_time_iso_8601": "2025-09-08T01:25:01.657924Z",
            "url": "https://files.pythonhosted.org/packages/6d/b7/46a929978d711897495c1230d58935cb9cb67b7685ba1aca330f5eacd6a6/gitlab_api-25.8.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 01:25:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gitlab-api"
}
        
Elapsed time: 3.42972s