---
title: "Reactor from GitLab CI with your Control CLI token · Selan"
description: "Keep Reactor agents, prompts and triggers in Git, applied on merge by a Control CLI token: whose rights it carries, making and revoking one, the CI job."
url: https://selan.ai/docs/reactor-gitlab-ci
updated: 2026-12-03T10:06:56+02:00
---

Agents

Docs · Reactor from GitLab CI

# Reactor from GitLab CI with your Control CLI token

Keep your agents, their prompts and their triggers in your own repository, and let a CI job apply them on merge. The job calls Selan MCP with a CLI token from Selan Control.

The token

## Whose rights the token carries

**A CLI token acts as the member who made it, with exactly their rights.** Over Selan MCP at `https://mcp.selan.ai/selan/mcp` it may do in Reactor what that member may do signed in, and nothing more: in a workspace where they are an Editor or Owner it creates, updates, archives and unarchives agents and manages their triggers, groups, MCP servers, plugins and variables; in a workspace they may only read, every change is refused; a workspace they cannot see does not exist for it.

Every call is checked as it is made. The token never reads a variable's value, since no tool answers one, and deleting an agent still needs an Owner of its workspace, as it does for anybody over MCP.

## Make a token

An Owner makes it in [Selan Control](https://control.selan.ai):

1.  Open **Settings → API tokens**.
2.  Give the token a name, such as the repository it is for (`gitlab-ci`), and how long it lives.
3.  Create it and copy the token, which starts with `selanct_`. It is shown once: Selan keeps only its hash.

**The token acts with whatever role its maker holds at each call**, not the one they held when they made it. If the job should reach one workspace and nothing else, have a dedicated member make it while an Owner, then lower them from Owner and give them edit access to that workspace alone.

## When a token stops working

A token is refused on its very next call once any of these is true:

-   somebody revoked it in **Settings → API tokens**;
-   it has passed its expiry;
-   the member who made it is no longer a member of the company.

Every change the token makes shows in the agent's **History** as `you@company.com via CLI token gitlab-ci`, so a change from CI is never mistaken for one made by hand, and a bad one can be reverted there.

GitLab CI

## Store the token in GitLab

In the repository, open **Settings → CI/CD → Variables** and add `SELAN_TOKEN` with the token as its value. Tick **Mask variable** and **Protect variable**, so it never prints in a job log and only jobs on protected branches, such as your default branch, receive it.

## Call Selan MCP from a job

Selan MCP takes plain JSON-RPC over HTTPS: each request is one `POST`, answered with one JSON body, with no session to keep. This job runs on the default branch only. It keeps each agent as a JSON file of the arguments `selan_remote_agent_update` takes (its `id`, `name`, `systemPrompt`, `model`, `effort`, `tags`, `workspaceId` and `runnerIds`), and sends each one.

```yaml
apply-reactor-agents:
  stage: deploy
  image: alpine:3.22
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes: [reactor/agents/*.json]
  script:
    - apk add --no-cache curl jq
    - |
      mcp() {
        curl -fsS https://mcp.selan.ai/selan/mcp \
          -H "Authorization: Bearer $SELAN_TOKEN" \
          -H 'Content-Type: application/json' \
          -H 'Accept: application/json, text/event-stream' \
          -d "$1" | tee /dev/stderr | jq -e '.error == null and .result.isError != true' > /dev/null
      }
      mcp '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"gitlab-ci","version":"1"}}}'
      for file in reactor/agents/*.json; do
        echo "Applying $file"
        mcp "$(jq -c '{jsonrpc: "2.0", id: 1, method: "tools/call",
          params: {name: "selan_remote_agent_update", arguments: .}}' "$file")"
      done
```

**A refusal fails the job.** A token Selan no longer takes (revoked, expired, its member gone) is an HTTP error, which `curl -f` fails on. A change the member may not make, or arguments Reactor will not take, comes back as a tool result with `"isError": true` and Reactor's own sentence, which the `jq -e` check fails on.

To see every tool the token may call, with its arguments, ask for the list:

```bash
curl -fsS https://mcp.selan.ai/selan/mcp \
  -H "Authorization: Bearer $SELAN_TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | jq -r '.result.tools[].name'
```

| To | Call |
| --- | --- |
| Make an agent | `selan_remote_agent_create` |
| Change an agent's prompt, model or placement | `selan_remote_agent_update` |
| Retire an agent, or bring one back | `selan_remote_agent_archive`, `selan_remote_agent_unarchive` |
| Add or change a schedule | `selan_remote_agent_trigger_create`, `selan_remote_agent_trigger_update` |
| Switch a schedule on or off | `selan_remote_agent_trigger_set_enabled` |
| Set a variable | `selan_remote_agent_env_set` |

**A variable's value goes in, never out.** Put secrets an agent needs in other masked variables and pass them to `selan_remote_agent_env_set`; no tool answers a value back, so nothing CI applies can leak one into a log.
