# Connect an AI Client

Set up Claude, ChatGPT, Claude Code, Codex or Cursor with Foundry's MCP server, or connect any other MCP client with a personal token.

Every app connects to the same address and signs in with your Foundry account, where you choose which areas it can read and change.

## The Address

For your own account, signed in:

```text
https://api.joinfoundry.xyz/mcp
```

For the public tools only, with no sign-in:

```text
https://api.joinfoundry.xyz/mcp/public
```

Add the public address the same way as below, without the sign-in step. The difference between the two is in [Foundry MCP Overview](https://joinfoundry.xyz/help/developers/mcp#endpoints).

## Claude

Add a custom connector with the address above. Claude opens Foundry so you can sign in and choose what it may do.

## ChatGPT

Add a custom connector (an MCP server) with the address above. ChatGPT opens Foundry so you can sign in and choose what it may do.

## Claude Code, Codex and Cursor

- **Claude Code and Codex:** run the first command to add Foundry, then the second to sign in.
- **Cursor:** add this to your `mcp.json`, then sign in when Cursor asks.

```bash tab="Claude Code"
claude mcp add --transport http foundry https://api.joinfoundry.xyz/mcp
claude mcp login foundry
```

```bash tab="Codex"
codex mcp add foundry --url https://api.joinfoundry.xyz/mcp
codex mcp login foundry
```

```json tab="Cursor"
{
  "mcpServers": {
    "foundry": {
      "url": "https://api.joinfoundry.xyz/mcp"
    }
  }
}
```

Signing in opens Foundry's consent page, where you choose Read and Write for each area and select **Allow**. What the page shows is in [Foundry MCP Overview](https://joinfoundry.xyz/help/developers/mcp#connect-an-app-with-oauth).

Any other MCP client that supports MCP's OAuth sign-in connects the same way: give it the address, and it finds Foundry's sign-in from the server's `401` response.

## Personal Token

Use a personal token for any other MCP client, or if you'd rather not sign in from the app.

1. Open [AI Agents settings](https://joinfoundry.xyz/workspace/agents) and find **Personal Tokens**.
2. If Foundry asks you to confirm your sign-in, enter your current password or the code sent to your email and select **Confirm Sign-In**, or select **Confirm with Google** or **Confirm with GitHub**. Foundry asks when your last sign-in confirmation is more than five minutes old, because a token keeps working after you close the browser.
3. Enter a **Token Name**, check Read, Write or both for each area under **Permissions**, and select **Create Token**.
4. Select **Copy Token**. The token is shown only once.

After you create a token, settings shows these same commands with your token filled in. Replace `YOUR_TOKEN` with your token. For Codex and Cursor, put the token in the `FOUNDRY_TOKEN` environment variable instead of the config.

```bash tab="Claude Code"
claude mcp add --transport http foundry https://api.joinfoundry.xyz/mcp --header "Authorization: Bearer YOUR_TOKEN"
```

```bash tab="Codex"
codex mcp add foundry --url https://api.joinfoundry.xyz/mcp --bearer-token-env-var FOUNDRY_TOKEN
```

```json tab="Cursor"
{
  "mcpServers": {
    "foundry": {
      "url": "https://api.joinfoundry.xyz/mcp",
      "headers": {
        "Authorization": "Bearer ${env:FOUNDRY_TOKEN}"
      }
    }
  }
}
```

```text tab="Any MCP Client"
Authorization: Bearer YOUR_TOKEN
```

For any other client, add a Streamable HTTP server at `https://api.joinfoundry.xyz/mcp` and send that header with every request.

## Check the Connection

Once connected, the app lists Foundry's tools. It sees only the tools for the areas you allowed, and a missing tool usually means its area wasn't granted. A connection's areas can't be changed afterwards. To change them, disconnect the app and connect it again, or create a new token, with the areas you want. [Permissions and Scopes](https://joinfoundry.xyz/help/developers/mcp-permissions) shows which area each tool needs.

## Troubleshooting

| What you see | What it means |
| --- | --- |
| `401` "Sign in to Foundry or use a personal token." | The request had no credential. Sign in from the app, or add your token header. |
| `401` "This token or connection has ended. Sign in again or create a new personal token." | The token was revoked, the app was disconnected, or a password, sign-in email or two-step sign-in change ended it. |
| `403` "This origin is not allowed." | The request came from a web page on another site. Call the server from an MCP client instead. |
| `429` "Too many requests. Try again in a minute." | The connection made more than 120 calls in a minute. |
| `503` "Sign-in for AI apps is temporarily unavailable. Try again shortly." | Foundry couldn't check an app's sign-in. Personal tokens keep working. |
| "Review and accept the updated Terms of Service on Foundry before publishing" | Publishing needs your agreement to the current Terms, which only you can give on Foundry. |
