# Connect and install

> Connect threefold to Claude, ChatGPT, Grok, Claude Code, Codex, Cursor, VS Code, Gemini CLI or OpenCode through one remote MCP server at `https://api.threefold.eco/mcp`, or use the REST API. The CLI and the TypeScript and Python SDKs are built and not published yet. Sign in with OAuth 2.1, an API key, or keyless reads.

## Three ways in

- **Remote MCP server:** `https://api.threefold.eco/mcp` (Streamable HTTP, browser OAuth 2.1 sign-in, Bearer API key or `?keyless=1`).
- **CLI and SDKs:** Built, not published. The CLI (`npx threefold`) and the TypeScript and Python SDKs are not publicly available yet: their npm and PyPI packages are not published, so they do not run today. Use MCP or REST.
- **REST API:** Plain JSON HTTP API at `https://api.threefold.eco` with OpenAPI 3.1 at `https://api.threefold.eco/openapi.json` and `/llms.txt`.

## Authentication options

- **Browser sign-in (OAuth 2.1):** Emailed sign-in link with workspace and scope consent.
- **API key (`tf_live_…`):** Bearer token scoped to `read`, `track`, `ingest`, `analysis` or `admin`.
- **Sandbox key (`tf_test_…`):** Fixture data only, read-only, never charged, for tests and CI.
- **No account (`?keyless=1`):** Read-only library access capped per IP address per day.

## MCP clients

### One command for coding agents

```sh
npx threefold mcp install
```

With no flags it writes a `threefold` entry for Claude Code, Codex, Cursor, Gemini CLI, OpenCode and VS Code. Pick one client with `--client`. Existing config files are copied to `<file>.bak` before they change, and running the command again changes nothing.

| Flag | What it does |
|---|---|
| `--client <name>` | `claude-code`, `codex`, `cursor`, `gemini`, `opencode`, `vscode` or `all` (default) |
| `--key tf_live_…` | Writes your API key into the entry as an `Authorization: Bearer` header |
| `--oauth` | Writes the URL only; your client signs in through the browser |
| `--url <url>` | Server URL (default `https://api.threefold.eco/mcp`) |
| `--dry-run` | Prints what would change and writes nothing |

Without `--key`, the entry is just the server URL. The first request gets an OAuth challenge, and clients that support MCP authorization open a browser to sign in.

<div class="note">

If `npx threefold` reports that the package does not exist, the npm package has not been published yet. Use the per-client settings below: they are exactly what the installer writes.

</div>

### Claude Code

```sh
claude mcp add --transport http --scope user threefold https://api.threefold.eco/mcp
```

To use an API key instead of browser sign-in:

```sh
claude mcp add --transport http --scope user threefold https://api.threefold.eco/mcp \
  --header "Authorization: Bearer tf_live_your_key"
```

### Claude (claude.ai and Claude Desktop)

Add a custom connector with the URL `https://api.threefold.eco/mcp`. Claude registers itself with threefold (OAuth 2.1 dynamic client registration), then opens threefold's sign-in page (an emailed link) and a consent screen where you pick the workspace and scopes. threefold is not in the Connectors Directory yet, so add it by URL.

### ChatGPT

In developer mode, create a custom app or connector with the URL `https://api.threefold.eco/mcp` and sign in when asked. The same OAuth 2.1 flow applies. threefold is not in the ChatGPT app directory yet.

### Grok

At grok.com/connectors, add a custom connector with the URL `https://api.threefold.eco/mcp` and sign in.

Chat-app sign-in follows the MCP authorization spec (protected resource metadata, PKCE with S256, dynamic client registration, refresh and revocation) and passes our in-process tests. We have not yet recorded a test in each chat app.

### Cursor

`~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "threefold": {
      "url": "https://api.threefold.eco/mcp"
    }
  }
}
```

Or open this install link in Cursor: `cursor://anysphere.cursor-deeplink/mcp/install?name=threefold&config=eyJ0aHJlZWZvbGQiOnsidXJsIjoiaHR0cHM6Ly9hcGkudGhyZWVmb2xkLmVjby9tY3AifX0=`

### VS Code

User profile `mcp.json` (macOS `~/Library/Application Support/Code/User/mcp.json`, Linux `~/.config/Code/User/mcp.json`, Windows `%APPDATA%\Code\User\mcp.json`):

```json
{
  "servers": {
    "threefold": {
      "type": "http",
      "url": "https://api.threefold.eco/mcp"
    }
  }
}
```

### Codex

`~/.codex/config.toml`:

```toml
[mcp_servers.threefold]
url = "https://api.threefold.eco/mcp"
```

With a key, add `http_headers = { "Authorization" = "Bearer tf_live_your_key" }` to the same section.

### Gemini CLI

`~/.gemini/settings.json`:

```json
{
  "mcpServers": {
    "threefold": {
      "url": "https://api.threefold.eco/mcp"
    }
  }
}
```

### OpenCode

`~/.config/opencode/opencode.json`:

```json
{
  "mcp": {
    "servers": {
      "threefold": {
        "type": "remote",
        "url": "https://api.threefold.eco/mcp"
      }
    }
  }
}
```

For Cursor, VS Code, Gemini CLI and OpenCode, an API key goes in a `headers` object next to `url`: `"headers": { "Authorization": "Bearer tf_live_your_key" }`.

### Try it without an account

Library reads work without signing in, up to 50 requests per IP address per day. Point your client at:

```text
https://api.threefold.eco/mcp?keyless=1
```

Keyless calls get the read-only library tools. Tools that track apps, pull fresh data or run AI analyses need you to sign in or use a key.

## SDKs

Both clients are generated from the OpenAPI document, default to `https://api.threefold.eco`, and raise a typed error that carries the API's `code`, `whose_error`, `retryable` and `hint`. Use a `tf_test_…` key to run them against fixture data in tests.

<div class="note">

The TypeScript package (`@threefold/client`) and the Python package (`threefold`) are not on npm or PyPI yet. Until they are, the REST examples on this page do the same job with any HTTP client.

</div>

### TypeScript

```js
import { ThreefoldClient } from "@threefold/client";

const tf = new ThreefoldClient({ apiKey: process.env.THREEFOLD_API_KEY });

const comparison = await tf.compareMarkets({ from: "de", to: "jp", niche: "health-fitness" });
console.log(comparison.shared, comparison.localOnly);
```

Methods: `libraryMeta`, `compareMarkets`, `searchApps`, `searchStore`, `topApps`, `getApp`, `marketBrief`, `b2bChecklist`, `searchPaidCreatives`, `searchOrganicPosts`, `trackApp`, `usage`, plus `get(path)` and `post(path, body)` for any other route. Errors are `ThreefoldError`.

### Python

```python
from threefold import ThreefoldClient

with ThreefoldClient(api_key="tf_live_your_key") as tf:
    comparison = tf.compare_markets("de", "jp", "health-fitness")
    print(comparison["shared"])
```

Methods: `library_meta`, `compare_markets`, `search_apps`, `search_store`, `top_apps`, `get_app`, `market_brief`, `b2b_checklist`, `search_paid_creatives`, `search_organic_posts`, `track_app`, `usage`, plus `get` and `post`. Needs Python 3.9 or later; depends on `httpx` and `pydantic`.

## REST and CLI quickstart

```sh
curl "https://api.threefold.eco/api/compare?from=de&to=jp&niche=health-fitness"
npx threefold login
npx threefold discover "compare meditation apps in DE and JP"
npx threefold call compare_markets --from de --to jp --niche health-fitness
```

See the [MCP docs](https://threefold.eco/docs/mcp.md), [REST API docs](https://threefold.eco/docs/api.md), [API reference](https://threefold.eco/docs/api/reference.md) and [CLI docs](https://threefold.eco/docs/cli.md).

Need help? See [Help](https://threefold.eco/help.md) and [system status](https://threefold.eco/status).

## Questions

### What is the fastest way to connect threefold to Claude, ChatGPT or Cursor?

Add the remote Streamable HTTP MCP URL `https://api.threefold.eco/mcp` in your chat app or coding agent and complete the browser OAuth 2.1 sign-in. The `npx threefold mcp install` command, which configures supported coding agents for you, is built but not published yet, so it does not run today.

### Can I try the MCP server or REST API without creating an account?

Yes. Append `?keyless=1` to the MCP URL (`https://api.threefold.eco/mcp?keyless=1`) or call read-only `GET` routes such as `/api/compare` and `/api/chart` directly. Keyless reads are capped at 50 requests per IP address per day by default.

### Should CI and automated tests use a live key or a sandbox key?

Use a sandbox key (`tf_test_…`) in tests and CI pipelines. Sandbox keys are read-only, return deterministic fixture data, never contact upstream data suppliers and are never charged. Use a scoped `tf_live_…` key with a monthly spend cap for production workflows.

### Do the MCP server, CLI, SDKs and REST API return the same data?

Yes. All four interfaces read from the same shared library and endpoint registry. The MCP server exposes four consolidated agent tools (`app`, `market`, `check`, `workspace`) that combine multiple library reads into a token-budgeted markdown digest with citations.
