# Install the GitHub CLI and MCP server (/en/docs/gthb/installation)

Connect your GitHub repositories once, and from then on your AI agent answers about their issues and READMEs without
you pasting links into the chat. GitHub lets `gthb` in with a fine-grained personal access token, a key you make in
GitHub's settings that reads only the repositories you pick. Making the token, installing `gthb` and signing in take
about five minutes.

When you finish, the agent on this computer reads a copy of your issues, comments and READMEs, even without the
internet. `gthb` never changes anything on GitHub, and the token you make cannot either.

**On this page:**

1. [In short](#in-short)
2. [What you need](#what-you-need)
3. [Make a read-only token](#make-a-read-only-token)
4. [Install gthb](#install-gthb)
5. [Sign in](#sign-in)
6. [Check that it works](#check-that-it-works)
7. [Sign out](#sign-out)

## In short [#in-short]

1. [Make the token](#make-a-read-only-token) on GitHub, read-only, for the repositories you want.
2. Install the tool, sign in with the token and copy one repository:

```sh
npm install -g @wirecat/github-cli
gthb work session start --owner octo-org
gthb work repos add octo-org/app
gthb work sync
```

`work` is a profile, a name you choose. `octo-org` and `octo-org/app` stand for your own user or organization and
repository.

## What you need [#what-you-need]

- A GitHub account that can read the repositories. For an organization's repositories, the organization may ask an
  owner to approve the token before it works.
- Node.js 22.16 or a later 22.x, or Node.js 24 or later. Node 23 is not supported.

## Make a read-only token [#make-a-read-only-token]

GitHub describes these steps on its page about
[fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).

1. Open [Fine-grained personal access tokens](https://github.com/settings/personal-access-tokens/new).
2. **Resource owner**: the user or organization whose repositories this profile reads. You give the same name to
   `--owner` when you sign in. One profile reads one owner: make another profile for another owner.
3. **Repository access**: only the repositories you will copy.
4. **Repository permissions**, all **Read-only**: Metadata, Issues, Pull requests and Contents. Nothing else, and no
   write access.
5. Generate the token and copy it. GitHub shows it only once, and it begins with `github_pat_`.

**Contents** lets `gthb` read the README, the branches, the tags and the commits. The README is the one file whose
text `gthb` copies. It never copies your code or a diff. A classic token (it begins with `ghp_`) is refused, because it can write to every repository you can.

## Install gthb [#install-gthb]

Install `gthb` once on each computer where you or an agent use it:

```sh
npm install -g @wirecat/github-cli
gthb --version
gthb doctor
```

`doctor` needs no network and opens no keyring. It shows the version, where settings live, the profiles that exist,
and whether other users of the computer can read the settings.

Give your terminal agent the tool's skill, the short guide to its commands. An app that connects to MCP servers uses
the tool over MCP instead, as [use it](/llms.mdx/docs/gthb/usage/content.md#agents) shows.

```sh
gthb skill install
```

## Sign in [#sign-in]

A profile is a name you choose for one GitHub owner, such as `work`. It is the first word of every command that uses
an account. Sign the profile in and name the owner the token reads:

```sh
gthb work session start --owner octo-org
```

The command shows the token steps, then asks for the token without showing it, or reads it from stdin, never as an
argument. GitHub checks the token first. Then it goes into the system keyring. Where no keyring works, it goes into
a private file by itself, and `--credential-storage file` chooses the file on purpose.

A script or a CI job can give the token in `GTHB_TOKEN` instead, with the owner in `GTHB_TOKEN_OWNER` beside it.

## Check that it works [#check-that-it-works]

```sh
gthb work session status --check
gthb work repos add octo-org/app
gthb work sync
gthb work issues list type:unstarted
```

`session status --check` asks GitHub whose token it is. `repos add` checks that the token can read the repository
before it keeps it. `sync` copies the repository, and `issues list type:unstarted` shows its open issues from the
copy.

## Sign out [#sign-out]

`gthb work session end` forgets the token on this computer. The token itself stays valid on GitHub until it expires
or you delete it in the same settings page.

Next: [use it](/llms.mdx/docs/gthb/usage/content.md).
