Skip to main content
Glama

create_pipeline

Trigger new CI/CD pipelines in GitLab by specifying project, branch, and optional variables to automate software deployment and testing workflows.

Instructions

觸發新的 CI/CD Pipeline

Args: project_id: 專案 ID 或路徑 ref: 分支名稱或標籤 variables: Pipeline 變數(JSON 格式,如 '[{"key":"VAR1","value":"val1"}]')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
refYes
variablesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual low-level GitLab API call implementation for creating a pipeline.
        def create_pipeline(
            self, project_id: int | str, ref: str, variables: list[dict] = None
        ) -> dict:
            """POST /projects/:id/pipeline"""
            pid = self._resolve_project_id(project_id)
            data = {"ref": ref}
            if variables:
                data["variables"] = variables
            return self._post_json(f"/projects/{pid}/pipeline", data=data)
    
        def retry_pipeline(self, project_id: int | str, pipeline_id: int) -> dict:
            """POST /projects/:id/pipelines/:pipeline_id/retry"""
            pid = self._resolve_project_id(project_id)
            return self._post_json(f"/projects/{pid}/pipelines/{pipeline_id}/retry")
    
        def cancel_pipeline(self, project_id: int | str, pipeline_id: int) -> dict:
            """POST /projects/:id/pipelines/:pipeline_id/cancel"""
            pid = self._resolve_project_id(project_id)
            return self._post_json(f"/projects/{pid}/pipelines/{pipeline_id}/cancel")
    
        def list_pipeline_jobs(
            self,
            project_id: int | str,
            pipeline_id: int,
            page: int = 1,
            per_page: int = 20,
        ) -> list[dict]:
            """GET /projects/:id/pipelines/:pipeline_id/jobs"""
            pid = self._resolve_project_id(project_id)
            params = {"page": page, "per_page": per_page}
            return self._get_json(
                f"/projects/{pid}/pipelines/{pipeline_id}/jobs", params=params
            )
    
        def get_job(self, project_id: int | str, job_id: int) -> dict:
            """GET /projects/:id/jobs/:job_id"""
            pid = self._resolve_project_id(project_id)
            return self._get_json(f"/projects/{pid}/jobs/{job_id}")
    
        def get_job_log(self, project_id: int | str, job_id: int) -> str:
            """GET /projects/:id/jobs/:job_id/trace — 回傳純文字日誌"""
            pid = self._resolve_project_id(project_id)
            return self._get_text(f"/projects/{pid}/jobs/{job_id}/trace")
    
        def retry_job(self, project_id: int | str, job_id: int) -> dict:
            """POST /projects/:id/jobs/:job_id/retry"""
            pid = self._resolve_project_id(project_id)
            return self._post_json(f"/projects/{pid}/jobs/{job_id}/retry")
    
        # ------------------------------------------------------------------
        # Repository API
        # ------------------------------------------------------------------
    
        def list_branches(
            self,
            project_id: int | str,
            search: str = None,
            page: int = 1,
            per_page: int = 20,
        ) -> list[dict]:
            """GET /projects/:id/repository/branches"""
            pid = self._resolve_project_id(project_id)
            params = {"page": page, "per_page": per_page}
            if search:
                params["search"] = search
            return self._get_json(f"/projects/{pid}/repository/branches", params=params)
    
        def get_branch(self, project_id: int | str, branch_name: str) -> dict:
            """GET /projects/:id/repository/branches/:branch"""
            pid = self._resolve_project_id(project_id)
            encoded_branch = quote(branch_name, safe="")
            return self._get_json(
                f"/projects/{pid}/repository/branches/{encoded_branch}"
            )
    
        def list_commits(
            self,
            project_id: int | str,
            ref_name: str = None,
            path: str = None,
            page: int = 1,
            per_page: int = 20,
        ) -> list[dict]:
            """GET /projects/:id/repository/commits"""
            pid = self._resolve_project_id(project_id)
            params = {"page": page, "per_page": per_page}
            if ref_name:
                params["ref_name"] = ref_name
            if path:
                params["path"] = path
            return self._get_json(f"/projects/{pid}/repository/commits", params=params)
    
        def get_commit(self, project_id: int | str, sha: str) -> dict:
            """GET /projects/:id/repository/commits/:sha"""
            pid = self._resolve_project_id(project_id)
            return self._get_json(f"/projects/{pid}/repository/commits/{sha}")
    
        def compare_branches(
            self, project_id: int | str, from_ref: str, to_ref: str
        ) -> dict:
            """GET /projects/:id/repository/compare"""
            pid = self._resolve_project_id(project_id)
            params = {"from": from_ref, "to": to_ref}
            return self._get_json(f"/projects/{pid}/repository/compare", params=params)
    
        def list_repository_tree(
            self,
            project_id: int | str,
            path: str = "",
            ref: str = None,
            recursive: bool = False,
            page: int = 1,
            per_page: int = 20,
        ) -> list[dict]:
            """GET /projects/:id/repository/tree"""
            pid = self._resolve_project_id(project_id)
            params = {"page": page, "per_page": per_page}
            if path:
                params["path"] = path
            if ref:
                params["ref"] = ref
            if recursive:
                params["recursive"] = True
            return self._get_json(f"/projects/{pid}/repository/tree", params=params)
    
    
    # ------------------------------------------------------------------
    # 全域客戶端實例
    # ------------------------------------------------------------------
    
    _client: Optional[GitLabClient] = None
    
    
    def get_client() -> GitLabClient:
        """取得全域客戶端實例(單例模式)"""
        global _client
        if _client is None:
            _client = GitLabClient()
        return _client
    
    
    def reload_client() -> GitLabClient:
        """重新載入客戶端(主要用於測試)"""
        global _client
        _client = None
        return get_client()
  • The MCP tool registration and wrapper function in the server implementation.
    @mcp.tool()
    def create_pipeline(project_id: int | str, ref: str,
                        variables: str = None) -> str:
        """觸發新的 CI/CD Pipeline
    
        Args:
            project_id: 專案 ID 或路徑
            ref: 分支名稱或標籤
            variables: Pipeline 變數(JSON 格式,如 '[{"key":"VAR1","value":"val1"}]')
        """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool triggers a pipeline but doesn't disclose behavioral traits: whether it's idempotent, what permissions are needed, if it's asynchronous, rate limits, error conditions, or what happens on success (e.g., returns pipeline ID). 'Trigger' implies a write/mutation, but details are missing for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the main purpose, followed by parameter details in a structured 'Args:' section. The description is appropriately sized with no redundant sentences. However, the parameter explanations could be more integrated rather than listed, and the JSON example is slightly verbose but informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 3 parameters with 0% schema coverage, and an output schema exists (so return values needn't be explained), the description is moderately complete. It covers the basic action and parameters but lacks behavioral context (e.g., mutation effects, error handling) and usage guidelines, which are important for a pipeline creation tool with write implications.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for all three parameters: 'project_id' as project ID or path, 'ref' as branch name or tag, and 'variables' as pipeline variables with JSON format example. However, it doesn't explain parameter interactions, constraints (e.g., ref must exist), or optionality (variables is optional per schema default). Partial compensation given the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('觸發新的 CI/CD Pipeline' - trigger new CI/CD pipeline) and identifies the resource (pipeline). It distinguishes from siblings like 'get_pipeline', 'list_pipelines', 'cancel_pipeline', and 'retry_pipeline' by specifying creation/triggering rather than retrieval or modification. However, it doesn't explicitly contrast with 'retry_pipeline' which also initiates pipeline execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., project access, branch existence), when not to use it (e.g., for existing pipelines), or direct alternatives among siblings like 'retry_pipeline' for restarting existing pipelines. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/snowild/gitlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server