> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alpic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy from GitLab CI

> Deploy your MCP server from a GitLab CI/CD pipeline using the Alpic CLI

## Prerequisites

<Steps>
  <Step title="Get an API key">
    In the [Alpic dashboard](https://app.alpic.ai), open your team and go to **API Keys** in the sidebar. Click **New
    API key**, name it, and copy the key.
  </Step>

  <Step title="Find your project and environment IDs">
    * **Project ID** : In your project, copy the project ID from **Settings** → **General**, - **Environment ID** : from
      the environment's card, in the **Environments** tab.
  </Step>

  <Step title="Add them as CI/CD variables">
    In your GitLab project, go to **Settings** → **CI/CD** → **Variables** and add `ALPIC_API_KEY` (masked),
    `ALPIC_PROJECT_ID`, and `ALPIC_ENVIRONMENT_ID`.
  </Step>
</Steps>

## Configure the pipeline

Add a deploy job to your `.gitlab-ci.yml`:

```yaml .gitlab-ci.yml theme={null}
stages:
  - deploy

deploy-alpic:
  stage: deploy
  image: node:24
  script:
    - npx alpic@latest deploy
      --non-interactive
      --project-id "$ALPIC_PROJECT_ID"
      --environment-id "$ALPIC_ENVIRONMENT_ID"
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
```

Every push to `main` now deploys to your Alpic environment.

## Deploy to multiple environments

To target several environments (for example staging and production), extend a shared job and set the IDs per environment. Here production is a manual action:

```yaml .gitlab-ci.yml theme={null}
.deploy-alpic:
  stage: deploy
  image: node:24
  script:
    - npx alpic@latest deploy
      --non-interactive
      --project-id "$ALPIC_PROJECT_ID"
      --environment-id "$ALPIC_ENVIRONMENT_ID"

deploy-staging:
  extends: .deploy-alpic
  environment: staging
  variables:
    ALPIC_PROJECT_ID: $ALPIC_STAGING_PROJECT_ID
    ALPIC_ENVIRONMENT_ID: $ALPIC_STAGING_ENV_ID
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'

deploy-production:
  extends: .deploy-alpic
  environment: production
  variables:
    ALPIC_PROJECT_ID: $ALPIC_PROD_PROJECT_ID
    ALPIC_ENVIRONMENT_ID: $ALPIC_PROD_ENV_ID
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
      when: manual
      allow_failure: true
```

<Note>
  Use `--project-id` and `--environment-id` rather than `--project-name` in CI: names can be changed, IDs are stable.
  See the `alpic deploy` reference [right here](/cli/deploy).
</Note>
