# Connect Codex to Onsite

> Add Onsite to Codex from the Codex app or the command line, sign in, and ask about your sites.

Add Onsite to Codex once and use it in the Codex app and the Codex command line.

## Before you start

- An Onsite account on a team with an active plan.
- Codex installed and signed in.

## Add Onsite

<Tabs>
  <Tab title="Codex app">
    <Steps>
      <Step title="Open the setup message">
        In Onsite, open [**Settings › MCP**](https://onsite.so/settings/mcp), choose **Codex**, and select **Add to Codex**. Codex opens a new chat with a setup message in it.
      </Step>
      <Step title="Send it">
        Send the message. Codex adds Onsite for you and pauses when it's time to sign in.
      </Step>
      <Step title="Sign in and allow access">
        Sign in to Onsite with Google, or with a code sent to your email. If you're on more than one team, pick the one Codex should use, then select **Allow**.
      </Step>
    </Steps>
  </Tab>
  <Tab title="Command line">
    <Steps>
      <Step title="Add the server">
        In a terminal, run:

        ```bash
        codex mcp add onsite --url https://onsite.so/mcp
        ```
      </Step>
      <Step title="Sign in to Onsite">
        Codex usually opens Onsite in your browser. If it doesn't, run:

        ```bash
        codex mcp login onsite
        ```
      </Step>
      <Step title="Choose a team and allow access">
        Sign in with Google, or with a code sent to your email. If you're on more than one team, pick the one Codex should use, then select **Allow**.
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Check it worked

Open a new Codex chat, so it picks up Onsite, and ask:

<Prompt>
  Using Onsite, show me the sites I can access.
</Prompt>

## Use a token instead of signing in

If you can't sign in from this computer, create a token in [**Settings › MCP**](https://onsite.so/settings/mcp) under **Connected apps and tokens**, and add this to `~/.codex/config.toml`:

```toml
[mcp_servers.onsite]
url = "https://onsite.so/mcp"
http_headers = { "Authorization" = "Bearer <your-onsite-token>" }
```

A token lasts 90 days. Keep it private, and revoke it in **Settings › MCP** when you no longer need it.

## If something goes wrong

<AccordionGroup>
  <Accordion title="Onsite's tools don't show in the chat">
    Codex loads servers when a chat starts. Open a new chat after you sign in.
  </Accordion>
  <Accordion title="Codex shows the wrong team's sites">
    Each connection uses one team. Run `codex mcp logout onsite`, then `codex mcp login onsite`, and pick the other team. See [Manage connections](/mcp/manage-connections#switch-to-another-team).
  </Accordion>
  <Accordion title="It worked before and now it doesn't">
    A connection lasts 90 days, and stops if you revoke it or leave the team. Run `codex mcp login onsite` to sign in again. See [Troubleshooting](/mcp/troubleshooting).
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="What you can ask" icon="lightbulb" href="/mcp/ask">
    Example questions to try next.
  </Card>
  <Card title="Manage connections" icon="key-round" href="/mcp/manage-connections">
    Tokens, teams and disconnecting.
  </Card>
</CardGroup>
