# Build with AI coding tools

Claude Code, Codex, Cursor and similar tools write a KLCT integration well when they can read the docs and the API description, and badly when they guess. This page is the shortest way to give them both.

## Give the tool the docs

Every guide and the full reference are served as plain text for models. Point the tool at one of these, in this order of preference:

| Give the tool | When |
|---|---|
| `https://app.klctai.com/llms.txt` | It can browse: an index it follows to the rest. |
| `https://app.klctai.com/developers/llms-full.txt` | It cannot browse, or you want one paste: every guide and every endpoint in a single file. |
| `https://app.klctai.com/developers/openapi.json` | It generates a client, a typed SDK or an MCP server from an OpenAPI file. Each operation has a stable `operationId` and an `x-klct-scope`. |
| `https://app.klctai.com/developers/send-leads.md` | The job is only "push leads into a KLCT account". |

Any guide is also available as Markdown by adding `.md`, for example `https://app.klctai.com/developers/webhooks.md`.

## A prompt to start with

Paste this, changing the last line for your job. The API key goes in an environment variable, never in the prompt.

```text
Read https://app.klctai.com/developers/llms-full.txt before writing any code.
Authenticate with the header "Authorization: Bearer $KLCT_API_KEY" (read it from the environment, never hard-code it).
Base URL: https://app.klctai.com/api
Use only endpoints and fields that appear in the docs. If something is not documented, say so instead of guessing.
Handle 401, 403, 404, 422 and 429 (back off and retry on 429).

Task: push leads from <our source> into KLCT with POST /leads/ingest, 200 per batch, with an Idempotency-Key per batch,
vendor "<name>", lead_source "partner" and list_name "<list>". Log the created, updated and errors counts of each batch.
```

## Keep the rules in the repo

Put this in `CLAUDE.md` (Claude Code), `AGENTS.md` (Codex and others) or `.cursor/rules/klct.mdc` (Cursor) so every session in the project starts with it:

```markdown
## KLCT API
- Docs for models: https://app.klctai.com/developers/llms-full.txt (index: https://app.klctai.com/llms.txt, OpenAPI: https://app.klctai.com/developers/openapi.json).
- Base URL https://app.klctai.com/api. Auth: `Authorization: Bearer $KLCT_API_KEY`. The key is one account's; never commit it or log it.
- Push leads with `POST /leads/ingest` (max 200 per call, send an `Idempotency-Key`, 30 calls/minute).
- A 200 with a non-empty `errors[]` means some rows were rejected: read `errors[].index` and `errors[].issues` and fix those rows. A 422 means the whole call was refused (see `issues`). Send only documented fields; unknown fields are refused.
- Do not call endpoints that are not in the docs.
```

## The KLCT MCP connector

KLCT is also a remote MCP server (Streamable HTTP, OAuth 2.1). It is built for creative work inside an account: drafting emails, sequences, forms, landing pages and knowledge base articles, always as drafts. **It cannot read contacts, send anything or push leads**, so it is not how you build an integration; use the docs above for that. If you want the tool to draft marketing content in your account, add the connector:

```
https://app.klctai.com/mcp
```

| Tool | Add it | Then sign in |
|---|---|---|
| Claude Code | `claude mcp add --transport http klct https://app.klctai.com/mcp` | Run `/mcp` inside Claude Code, choose `klct` and authenticate in the browser. |
| Codex | `codex mcp add klct --url https://app.klctai.com/mcp` | `codex mcp login klct` |
| Cursor | In `.cursor/mcp.json`: `{ "mcpServers": { "klct": { "url": "https://app.klctai.com/mcp" } } }` | Cursor opens the KLCT consent page; pick the account and scopes. |
| Claude (web, desktop) | Settings → Connectors → Add custom connector, paste the URL | Choose **Sign in now**. |

These commands follow each tool's own documentation for remote MCP servers; tool vendors change their flags, so if one is rejected run the tool's `mcp add --help`. The tool list KLCT exposes is at [`/developers/mcp-tools.json`](https://app.klctai.com/developers/mcp-tools.json).

## Generate a client or an MCP server from OpenAPI

If your tool or framework builds from an OpenAPI file, feed it `https://app.klctai.com/developers/openapi.json`. A good minimum for a lead-delivery integration is `ingestLeads`, `listContactLists` and `createContactList`. Give any generated agent the narrowest credentials you can, and put a human approval step in front of anything that contacts a customer.

## Test safely

- Start with `"dry_run": true`: the payload is validated and nothing is saved. Then use a test account, or a list named `TEST`, for the first real batches, and send `"trigger_automations": false` so nothing starts.
- Repeat a batch with the same `Idempotency-Key` to check your retry handling: the response header `Idempotent-Replay: true` confirms the replay.
- Check the result in KLCT: the contacts carry the `vendor:` tag and the lead source you sent, and the list shows its members.
