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:
- Open Settings → API tokens.
- Give the token a name, such as the repository it is for (
gitlab-ci), and how long it lives. - Create it and copy the token, which starts with
selanct_. It is shown once: Selan keeps only its hash.
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.
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:
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 |
selan_remote_agent_env_set; no tool answers a
value back, so nothing CI applies can leak one into a log.