Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

416 linesCodeBlameRaw
1---
2title: Connect an AI client
3description: Connect coding agents, ChatGPT, Claude chat, Grok, Open WebUI or LibreChat to g1t projects through MCP.
4---
5
6import AgentSetup from '../../../components/AgentSetup.astro';
7
8Coding agents such as Claude Code and Codex, chat apps such as ChatGPT
9and Grok, and open-source MCP clients connect to g1t and act as you,
10with the access you give them:
11
12| To | Use |
13| --- | --- |
14| Read and change anything on g1t from inside the agent | The MCP server at `https://mcp.g1t.sh`: [MCP tools](/reference/mcp/) |
15| Work from the agent's shell | The [g1t CLI](/guides/cli/): `g1t pr create`, `g1t pr checks --watch`, `g1t run logs --failed` |
16| Push code | git over HTTPS, signed in with `g1t auth setup-git` or an [access token](/guides/authentication/#access-tokens) |
17| Start the agent when something happens | [Webhooks](/guides/webhooks/), or a [workflow](/guides/actions/) on `issues` or `issue_comment` |
18| Show people how a change was made | The pull request's [session](/guides/why-blame/#sessions) |
19| See who is working on what, and not collide | [Sessions, claims and dependencies](/guides/sessions/) |
20| Script anything else | The [REST API](/reference/api/), which has the same operations as the tools |
21
22The agent runs where you run it: on your machine, in your CI, or on a
23[runner](/guides/self-hosted-runners/) of your own, on your own model
24account. g1t runs no agents of its own; it keeps the code, the issues and
25pull requests, the checks and the record of what happened. To start one
26from g1t instead, see [hand an issue to g1t](#hand-an-issue-to-g1t).
27
28## Connect your AI client
29
30Choose your client below. The project pages and these docs remember your choice.
31When you open a project, the workspace's first configured AI provider supplies the
32default; your explicit choice takes priority. OpenAI defaults to Codex, Anthropic
33to Claude Code, Gemini to Gemini CLI, xAI to Grok, and self-hosted OpenAI-compatible
34endpoints to Open WebUI. Other providers default to OpenCode. This only
35chooses the instructions shown; it does not change your model or share your API key.
36
37Claude Code's plugin records sessions through hooks. Codex can use the
38[Codex plugin](#codex-marketplace), or connect directly with the commands below.
39ChatGPT and other MCP clients connect through the same server.
40
41<AgentSetup />
42
43### Chat apps and open-weight models
44
45The connection belongs to the **chat client**, while the model supplies its
46answers. For example, Open WebUI or LibreChat can connect g1t's tools to a
47compatible model you host. An Ollama or vLLM model endpoint alone is not an MCP
48client: configure the model in your chat app and add g1t separately.
49Use a model with reliable tool calling.
50
51| Client | Connection |
52| --- | --- |
53| Grok chat | [Custom MCP connector](https://docs.x.ai/grok/connectors) at grok.com/connectors; sign in to g1t. |
54| Claude chat / Desktop | [Custom remote connector](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp); choose automatic OAuth client registration. |
55| Open WebUI | An admin adds an [MCP Streamable HTTP server](https://docs.openwebui.com/features/extensibility/mcp/) with OAuth 2.1. |
56| LibreChat | Add the [MCP server configuration](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/mcp_servers) shown above; each user signs in. |
57
58These are setup instructions based on the clients' documented capabilities;
59they are not an end-to-end certification of every model and client version.
60A chat app can read and act through g1t's tools without having a local shell.
61Using Grok as g1t's configured AI provider is separate from connecting Grok chat
62to your projects. The same distinction applies to GPT and open-weight models.
63
64Signing in opens g1t in your browser. The page lists what the agent will be
65able to do; untick anything you would rather it could not, and approve.
66There is no token to copy. An agent that asks for nothing in particular gets
67the [Agent preset](/guides/authentication/#presets), which never includes an
68admin scope. It shows up in
69[Settings → Connected applications](https://g1t.sh/settings/applications),
70where you can change what it may do, or sign it out.
71
72A coding agent that pushes changes also needs git access. Where the [g1t CLI](/guides/cli/)
73is signed in, `g1t auth setup-git` makes git use the same sign-in.
74Otherwise git asks for a username and a password: use your g1t username
75and an [access token](/guides/authentication/#access-tokens) with
76`code:write`.
77
78Ask it to list the open issues on a repository, or to work on one, and it
79will use g1t's tools. It sees only the tools and actions its access allows.
80
81### With a token instead
82
83To skip the browser, for a script, a CI job or a machine without one, put an
84[access token](/guides/authentication/#access-tokens) in `G1T_TOKEN` and
85send it as a bearer token:
86
87<AgentSetup variant="token" />
88
89### What to give an agent
90
91Give an agent the least that lets it do its work:
92
93| Choose | For an agent |
94| --- | --- |
95| Scopes | The **Agent** [preset](/guides/authentication/#presets), which reads across g1t and writes what an agent's work needs, and never includes an admin scope. Add one only for a task that needs it. |
96| Expires | The shortest that fits the work, such as 30 days. |
97
98A token reaches every workspace and repository you can. To keep an agent
99to one workspace, give it that workspace's own
100[workspace token](/guides/workspaces/#workspace-access-tokens) instead.
101
102The same choices are on the sign-in page for an agent that connects with
103OAuth, and in [Settings → Access tokens](https://g1t.sh/settings/tokens)
104for a token. A call the agent's access does not allow is refused with the
105scope it needs; see [scopes](/guides/authentication/#scopes). Everything
106the agent does is done as you, and shows as you in the
107[audit log](/guides/audit-log/).
108
109## How an agent works on an issue
110
1111. `issue` with `work`, to load everything about it in one call: what
112 done means, who has claimed it, the pull requests already made for it,
113 and what it is blocked by. Then `issue` with `claim`, which also says
114 who else is on it.
1152. `pull_request` with `create` and the issue's number. This opens a draft
116 pull request and returns the git remote of its [working copy](/concepts/forks/#working-copies-for-pull-requests).
1173. Clone the working copy, make changes, commit and push.
1184. `pull_request` with `record_session` as it goes, so people can see its
119 reasoning.
1205. `pull_request` with `get`, to check `overlaps`, `behind` and the checks.
1216. `pull_request` with `ready` and a summary of what changed and why.
122
123### Work with no issue yet
124
125Most of what an agent is asked starts without an issue, and a question,
126a look around or a trivial fix never needs one. Record the session
127anyway (`session` with `start`), with a `title` saying what it is for: the
128team sees it in **Live now** on the project's overview and **Work** page,
129under its pull request or branch. When the work becomes a change others
130should know about (a branch to push, a pull request), look for its issue
131(`issue` with `list` or `list_claims`) and claim it. If there is none,
132`issue` with `claim`, a `title` and no `number` opens one and claims it
133in one step, and attaches the session (`session_id`) to it:
134
135```json
136{ "name": "issue", "arguments": { "action": "claim", "repo": "flagon-io/hello", "title": "Preview builds time out on large repositories", "session_id": "ses_01m4b2c3d4e5f6g7h8j9k0m1n2" } }
137```
138
139See [Work with no issue yet](/guides/sessions/#work-with-no-issue-yet).
140
141The call that starts the pull request:
142
143```json
144{ "name": "pull_request", "arguments": { "action": "create", "repo": "flagon-io/hello", "issue": 42, "agent": "claude-code" } }
145```
146
147`agent` names the harness, so people can see what made the change. Its
148commits show with the agent's name and mark too, from the address the
149agent writes on them.
150
151Every push runs the repository's [workflows](/guides/actions/#checks) on
152the pull request, as for anyone's. `pull_request` with `get` returns its
153`statuses` and `required_checks`, the checks the default branch requires
154before it merges. When one fails, `workflow` with `get_run` and `job_logs`
155says why; push a fix and the workflows run again. Run the same tests and
156linters the workflows run before you push, and you will rarely need to.
157
158When `main` has moved, `pull_request` with `update_branch` brings the pull
159request up to date in a few seconds. When the changes clash, pull `main`
160into the working copy, resolve and push. The pull request can then be
161merged, or joins the [merge queue](/guides/merge-queue/) when the
162repository uses one.
163
164When the merge queue takes an agent's pull request out because it fails
165combined with the pull requests ahead of it, g1t
166[says which ones and which check failed](/guides/merge-queue/#who-is-told):
167in the pull request's session, as an `integration_failure` decision
168(`pull_request` `list_decisions`), and as the `integration.failed` event.
169The agent reads the other pull request's changes, fixes its own, and
170pushes; once the checks pass, the pull request rejoins the queue by
171itself. It can say what it changed with `pull_request` `record_decision`
172(`kind` `fix`), and `repository` `why` explains any line it is unsure of.
173
174### Repository instructions
175
176Each agent reads a repository's instructions from a file at its root:
177Claude Code from `CLAUDE.md`, and Codex, OpenCode and Cursor from
178`AGENTS.md`. To keep one file, write `AGENTS.md` and put `@AGENTS.md` in
179`CLAUDE.md`. A few lines there make every agent work the same way on g1t:
180
181```md title="AGENTS.md"
182## Working on g1t
183
184- Work in a draft pull request (`pull_request` `create` with the issue),
185 and record your session with `record_session` before each push.
186- Read `overlaps` and `behind` on `pull_request` `get` before going far.
187- Say why you made a choice with `pull_request` `record_decision`.
188```
189
190An agent with a shell can use the [g1t CLI](/guides/cli/) instead of the
191tools, and claim the issue, record its session and hand off with it: the
192lines for that are in
193[other coding agents](/guides/claude-code-plugin/#other-coding-agents).
194With Claude Code, the [plugin](/guides/claude-code-plugin/) does this for
195you.
196
197## Record the session
198
199A pull request's session is the record of how it was made: the prompts,
200the agent's reasoning, the tools it ran and what they returned. People read
201it on the pull request's **Session** tab, and
202[why-blame](/guides/why-blame/) uses it to explain each line.
203
204An agent can record its own session with the `pull_request` tool's
205`record_session` action. It takes a list of `entries`, each with a `kind`
206(`prompt`, `message`, `tool_call`, `tool_result` or `note`) and `text`,
207and tool entries also carry the `tool` name. Record before each push: an
208entry is tied to the commit that was the head when it was recorded. Do not
209put secrets in a session: g1t takes out what looks like a credential, and
210shows what a session recorded only to the workspace's members (a prompt
211only to whoever typed it), but that is a safety net. See
212[Who sees what](/guides/sessions/#who-sees-what).
213
214### Recording sessions automatically
215
216With Claude Code, install g1t's plugin and every session in a g1t
217repository is recorded without the agent having to remember:
218
219```sh
220claude plugin marketplace add https://g1t.sh/flagon-io/g1t-plugins.git
221claude plugin install g1t@g1t
222```
223
224Its hooks record your prompts, the tools Claude uses and what it called
225them with, and its pushes, through the [g1t CLI](/guides/cli/), which
226must be installed and signed in (`g1t auth login`), and title each
227session with what its first prompt asked for. They never send what a
228tool returned. The plugin also gives Claude the issue's work context when
229a session starts (or, with no issue, when to claim or open one), g1t's MCP
230server, and commands to claim and hand off issues. See [Claude Code plugin](/guides/claude-code-plugin/) for
231everything it records, and how to opt out.
232
233Other agents record a session with the same CLI commands, from their
234instructions file: see
235[other coding agents](/guides/claude-code-plugin/#other-coding-agents).
236
237## Staying out of each other's way
238
239Several agents, and people, can work on one repository at once.
240`pull_request` with `get` returns:
241
242- `overlaps`: other pull requests in progress that change files this one
243 changes, with the paths. An overlap with a pull request for a different
244 issue will become a conflict for whichever merges second, so narrow the
245 change, or say so in the pull request.
246- `behind`: whether `main` has moved since the pull request was made. If
247 it has, `update_branch` before asking for a merge.
248
249Required checks, [rules](/guides/rules/) and the
250[merge queue](/guides/merge-queue/) hold for an agent's pull request
251exactly as for a person's.
252
253## Hand an issue to g1t
254
255g1t runs no model of its own, but it can start a session for you on the
256workspace's own Anthropic account. Once an owner adds an Anthropic key
257under [**AI**](/guides/ai/):
258
259- **Assign to g1t** in an issue's sidebar (or `g1t issue edit 12
260 --add-assignee g1t`), or mention `@g1t` in a comment on an issue or pull
261 request, with what you want done.
262- **Start a session** on an issue's page, `g1t work dispatch 12`, or the
263 `session` tool's `dispatch` action, to choose the mode (`plan`,
264 `implement` or `review`).
265
266g1t reacts 👀, then starts the session as you, with a token for that
267repository only that is revoked when the session ends. It installs the
268g1t CLI, clones the repository and works the way this page describes; its
269card shows in the issue's conversation, and Anthropic bills the account
270for it. Without an Anthropic key, `g1t work dispatch` prints a Claude Code
271command to run yourself instead. See
272[Assign g1t](/guides/sessions/#assign-g1t-or-ask-it-in-the-thread) and
273[Start a session on your Anthropic account](/guides/sessions/#start-a-session-on-your-anthropic-account).
274
275## Start an agent when something happens
276
277To run your agent without anyone starting it by hand, react to g1t's
278events:
279
280- **Webhooks.** Register an address for a repository or a whole workspace
281 with the `webhook` tool or in its settings, and choose the events, such
282 as `issue.labeled`, `issue.assigned`, `comment.created`,
283 `checks.completed` or `workflow.completed`. Each delivery is signed. See
284 [webhooks](/guides/webhooks/).
285- **Workflows.** A workflow in `.g1t/workflows/` can start on `issues` or
286 `issue_comment` and run your agent's command line on a g1t runner, with
287 its key in a [secret](/guides/secrets-and-variables/). See
288 [GitHub Actions](/guides/actions/).
289- **Notifications.** An agent that works as you can read your inbox with
290 the `notifications` tool: review requests, mentions, assignments and
291 your work's checks, each with why you were told.
292
293## Reviewing as an agent
294
295An agent can review as well as write. Given an issue with several pull
296requests, it can call `pull_request` with `changes` and `read_session` on
297each, compare them, and read each one's check results from `get`. It can
298leave findings on specific lines with `issue` and `comment`, give a verdict
299with `pull_request` and `review`, and, with the Write role, `merge` the
300best one. It cannot approve or request changes on a pull request it opened.
301
302## Artifacts
303
304Your agent can read and write a workspace's artifacts: its docs, and later
305its slides, designs and dashboards. The `artifact` tool does it as you,
306so it opens only what you can open, and changes only what you can change.
307Its token needs `artifacts:read` to read them (the Read only and Agent
308[presets](/guides/authentication/#presets) have it), `artifacts:write` to
309make and change them, and `artifacts:admin` to share them or delete them
310for good. A token without one of these sees no `artifact` tool, and a
311token sees only the actions its scope allows.
312
3131. Find what is there with `list` (narrow with `kind`, `space` or `q`) or
314 `search`, which matches words and meaning and returns the passage that
315 matched.
3162. Read one with `read`. A doc comes back as Markdown in `content`, with
317 its top-level `blocks` and their ids, and `can` says whether you may
318 edit it or only suggest.
3193. Change it with `edit`: `markdown` and a `target`, which is `append`,
320 `document` (replace it all), a `section` by its `heading`, or `blocks`
321 from one block id to another. With the edit role the change is made, as
322 a new version; with the comment role, or with `suggest_only`, it is
323 filed as a suggestion that the doc's editors accept or reject.
3244. Make one with `create`. Left out `space` and `parent_id`, it lands in
325 your Private, where only you can open it until you share it.
326
327```json
328{ "action": "edit", "workspace": "acme", "artifact_id": "fol_01kq7c4e6g8j0m2p4r6t8v0x2z",
329 "target": { "kind": "section", "heading": "Risks" },
330 "markdown": "## Risks\n\nThe migration needs a maintenance window.\n",
331 "note": "Adds the migration risk" }
332```
333
334Name an artifact by its id (`fol_…`) or by its link. Each action is also
335a REST route under `/workspaces/{workspace}/artifacts`; see the
336[API reference](/reference/api/). These are not workflow runs' artifacts,
337which are the `workflow` tool's. Slides, designs and dashboards answer
338that they are not here yet. A workspace's own token cannot use artifacts:
339they always belong to a person.
340
341## Filing issues from another system
342
343Anything that holds an access token can open issues: an error tracker, a
344monitor, a script. Call the `issue` tool with `create`, or `POST
345/repos/{owner}/{name}/issues`, with a title, a description and labels
346such as `bug`. Its token needs `issues:write`. The issue is attributed to
347the account the token belongs to.
348
349## Tools
350
351Each tool is a kind of thing on g1t and takes an `action`, such as `get`
352or `create`. Repositories are given as `owner/name`, and issues and pull
353requests as the repository and a `number`.
354
355| Tool | What it covers |
356| --- | --- |
357| `search` | Code, repositories, issues, pull requests and people across g1t; a tracker's ticket |
358| `repository` | Repositories, their settings, rulesets, branches, labels, milestones and releases |
359| `issue` | Issues, labels and comments; an issue's whole context, and claims |
360| `pull_request` | Pull requests: create, record and read sessions, review, merge, the merge queue |
361| `session` | Your harness's session: start, update, record, end, get, list; dispatch work on an issue; who else is working |
362| `workflow` | Workflow runs and logs, checks, deployments, environments and runners |
363| `observability` | A project's requests, logs, traces, errors and metrics in production |
364| `package` | Packages in every registry |
365| `secret` | Secrets and variables |
366| `security` | Secret scanning, code scanning, vulnerable dependencies and advisories |
367| `webhook` | Webhooks and their deliveries |
368| `access` | Who has which role on a repository, and deploy keys |
369| `team` | Teams and their members and repositories |
370| `workspace` | Workspaces, members, integrations, projects, rulesets and token rules |
371| `ai` | The workspace's AI providers, and what Ask answers with |
372| `billing` | Usage, budget and invoices |
373| `notifications` | Your inbox |
374| `account` | Who the token acts as, and your invitations |
375| `artifact` | A workspace's docs |
376
377[MCP tools](/reference/mcp/) lists every action with its required inputs,
378its scope and its REST route.
379
380## Other clients
381
382The server speaks MCP over streamable HTTP and answers each request with
383JSON. Every call needs to be signed in. Opening
384[mcp.g1t.sh](https://mcp.g1t.sh) in a browser shows what the server is, how
385to connect, and the tools it offers.
386
387A client that supports MCP authorization needs only the URL. An
388unauthenticated request is answered with `401` and a pointer to
389`https://mcp.g1t.sh/.well-known/oauth-protected-resource`, from which the
390client finds g1t's authorization server, registers itself, and sends you to
391your browser. A client that asks for scopes sends them in `scope` on the
392authorization request. See
393[signing in with OAuth](/guides/authentication/#signing-in-with-oauth).
394
395A client that does not can send `Authorization: Bearer <token>` with an
396access token.
397
398## Codex marketplace
399
400Add g1t's small plugin marketplace:
401
402```sh
403codex plugin marketplace add https://g1t.sh/flagon-io/g1t-plugins.git
404codex plugin add g1t@g1t
405```
406
407In the ChatGPT desktop app's Plugins directory, select the **g1t** marketplace,
408install **g1t**, and authorize its MCP connection. Restart the app if the source
409has not appeared. The plugin bundles the MCP server and a skill for working on
410g1t issues and recording sessions. It does not install Claude Code's hooks.
411If you already added the standalone `g1t` MCP server, disable that duplicate
412connection when using the plugin.
413
414The direct Codex MCP commands above work without a marketplace. ChatGPT's
415**Add custom MCP server** flow is also available independently; a Git marketplace
416is not a listing in OpenAI's public plugin directory.