# AI Agent Setup

This guide is written for AI coding agents: Antigravity, Cursor, Claude Code, OpenAI Codex, Windsurf, OpenCode, Cline, Roo, or any MCP-compatible agent. Follow the steps in order and strictly uphold the API key security boundary in Step 3.

Tipolink Cloud gives you an accurate dependency map of a multi-language repository (TypeScript, JavaScript, Python, Go, Rust, Java, Kotlin, C#, PHP, Ruby, and C/C++), helps you reuse existing helpers instead of writing duplicates, and verifies your edits before you finish. Raw source code is never uploaded (*Zero Source-Code Upload*); the local `@tipolink/mcp` bridge extracts and transmits only minimal structural metadata.

## Step 1: Inspect the workspace

- Look for project manifests in the repository root, such as `package.json`, `tsconfig.json` / `jsconfig.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `pom.xml` / `build.gradle`, `*.csproj`, or `composer.json`.
- Confirm the project contains supported source files (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.py`, `.go`, `.rs`, `.java`, `.kt`, `.kts`, `.cs`, `.php`, `.rb`, `.c`, `.cc`, `.cpp`, `.cxx`, `.h`, `.hh`, `.hpp`, `.hxx`).
- If the project has none of these supported language sources, stop and tell the user which languages Tipolink currently supports.

## Step 2: Install the global Tipolink Skill

Run the Tipolink initializer once:

```bash
npx -y @tipolink/mcp@latest init
```

This command is idempotent and installs only the global skill file at `~/.agents/skills/tipolink/SKILL.md` (`C:\Users\<USER>\.agents\skills\tipolink\SKILL.md` on Windows) without modifying your project repository.

## Step 3: Create the MCP JSON schema for your host coding app (placeholder key only)

Tipolink runs over **MCP** (not ephemeral terminal shell variables). Terminal `export` or `$env:` commands execute in short-lived sub-shells and are **not** inherited by the IDE or harness process that launches MCP servers.

1. Identify the host coding app / harness where you are running and locate its native MCP JSON configuration file according to that harness's rules (for example, your app's user-level MCP config JSON such as Antigravity `mcp_config.json`, Cursor `~/.cursor/mcp.json`, Claude Code `~/.claude.json`, Windsurf `~/.codeium/windsurf/mcp_config.json`, OpenCode `opencode.json`, or the harness's documented MCP JSON path).
2. Create or non-destructively merge the Tipolink MCP server entry into that JSON file using **placeholder credentials only** (`sk_live_PASTE_YOUR_KEY_HERE`). Match the exact JSON schema required by your host harness:

### Tipolink MCP Server (`@tipolink/mcp` — supports automatic local indexing & `tipolink_sync`)

```json
{
  "mcpServers": {
    "tipolink": {
      "command": "npx",
      "args": ["-y", "@tipolink/mcp@latest", "mcp"],
      "env": {
        "TIPOLINK_API_KEY": "sk_live_PASTE_YOUR_KEY_HERE"
      }
    }
  }
}
```

3. **Security Handoff — Stop and let the user insert their own API key:**
   - Do **not** ask the user to paste their live `sk_live_...` secret into the AI chat, and do **not** run shell `export` commands for `TIPOLINK_API_KEY`.
   - Tell the user the exact path of the MCP JSON file you created or updated, and ask **the user** to:
     1. Sign in or create an account at https://tipolink.co/login (new accounts receive **150 free trial credits**).
     2. Open https://tipolink.co/console, go to **API Keys**, create a labeled key, and copy the one-time `sk_live_...` secret.
     3. Open that MCP JSON file directly in their editor, replace `sk_live_PASTE_YOUR_KEY_HERE` with their real `sk_live_...` key inside `env.TIPOLINK_API_KEY`, save the file, and reload/reconnect MCP in their coding app.

## Step 4: Verify MCP connection & sync workspace

Once the user confirms they saved their API key in the MCP JSON file and reloaded MCP:

1. Call `tipolink_workspace({ action: "status" })` (**0 credits / free**) to confirm MCP authentication succeeds and inspect indexed workspaces.
2. Call `tipolink_workspace({ action: "bind", workspaceId: "<repository_root_path>" })` (**0 credits / free**) to lock the current repository as the active workspace.
3. If the repository is not yet indexed, or if a response flags an outdated schema, call `tipolink_sync({})` (**0 credits** no-op / **1 credit** incremental `<10` files / **5 credits** cold index, `>=10` files, or `force: true`) directly via MCP to sync fresh structural metadata to Tipolink Cloud—no CLI invocation required.

## Step 5: Use the Cloud MCP workflow while you code

All five Tipolink operations run natively over MCP:

1. **Workspace Status & Binding (0 credits / free):** Call `tipolink_workspace` (`action: "list"`, `"status"`, or `"bind"`) when switching repositories.
2. **Workspace Sync (0 no-op / 1 incremental / 5 full):** Call `tipolink_sync({})` when onboarding a repository or upgrading an outdated schema (pass `{ force: true }` for a full disk re-extract). Routine edits and deletions are already auto-synced via `manifestDelta` + `activeFiles` whenever you call `tipolink_map`, `tipolink_find_helper`, or `tipolink_guard`.
3. **Impact Map before editing shared files (5 credits):** Call `tipolink_map` on target file(s) before changing exports, signatures, or shared modules.
4. **Helper Discovery before writing new utilities (1 credit):** Call `tipolink_find_helper` and reuse the canonical import statement it returns.
5. **Codebase Guard after editing (2 credits incremental / 5 cold):** Call `tipolink_guard` to verify zero broken imports, zero dependency cycles, and zero duplicated helpers before completing your task.

## Rules for agents

- Never ask the user to send a live `sk_live_...` key in chat; always write a placeholder into the harness MCP JSON file and let the user paste their key locally.
- Never print, log, or commit any real API key or MCP file containing a real key to version control.
- Keep the user's project repository untouched during setup; `npx -y @tipolink/mcp@latest init` installs only the global skill at `~/.agents/skills/tipolink/SKILL.md`.
- Never upload raw source files; only the local `@tipolink/mcp` bridge sends structural metadata.
- If an MCP tool returns authentication failure (401) or exhausted credits (402), stop and tell the user. See https://tipolink.co/docs/troubleshooting.md for fixes.
