> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecorn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents

# Agents guide

This page is the agent-facing entry point to Pipecorn. If you are an AI agent or LLM tool helping a user integrate with Pipecorn, read this first — it tells you which surface to use, the conventions to follow, and the auth flow.

Looking for the full docs in a single file? See [`llms-full.txt`](https://docs.pipecorn.com/llms-full.txt). For a short navigational index, see [`llms.txt`](https://docs.pipecorn.com/llms.txt). To search and read these docs on demand, connect the [docs MCP server](https://docs.pipecorn.com/api-reference/docs-mcp.md) at `https://docs.pipecorn.com/mcp` (no auth). It only reads the docs; the Pipecorn MCP server below is the one that calls Pipecorn.

## What Pipecorn is

Pipecorn is a B2B sales intelligence platform. Three primary jobs:

1. **Find companies** matching a profile (firmographics, technographics, buying signals).
2. **Find people** at those companies (titles, seniority, locations, industries).
3. **Enrich contacts** with verified business email and phone via waterfall sourcing across 20+ providers.

## Pick your integration surface

| Surface | When to use | Docs |
| - | - | - |
| **MCP server** | You are an LLM tool (Claude, ChatGPT, Cursor, Claude Code, Cline). Highest leverage — 44 tools, OAuth or API key, no glue code. | [MCP docs](https://docs.pipecorn.com/mcp/overview.md) |
| **REST API** | You are integrating Pipecorn into custom backend code or workflow tools (Zapier, Make, n8n via HTTP). | [API reference](https://docs.pipecorn.com/api-reference/main-use-cases.md) |
| **CLI (`@pipecorn/cli`)** | You are scripting against Pipecorn from a shell, CI, or local automation. JSON output, structured exit codes. | [CLI docs](https://docs.pipecorn.com/cli/overview.md), [source](https://github.com/pipecorn/cli-pipecorn) |

When in doubt: use MCP. It already exposes the most common workflows and handles auth, polling, and credit warnings for you.

## MCP quick reference

* **Endpoint:** `https://mcp.pipecorn.com/mcp`
* **Transport:** Streamable HTTP
* **Auth:** OAuth access token in `Authorization: Bearer <token>` (Claude, ChatGPT), or an API key in `X-API-Key` (personal key) or `X-Workspace-Key` (workspace key) for Claude Code, Cursor and custom clients. A raw API key in `Authorization` is rejected.
* **Tool count:** 44, across accounts, leads, contacts, lists, personas, signals, jobs, and utilities
* **Discovery:** [`/.well-known/mcp.json`](https://docs.pipecorn.com/.well-known/mcp.json)
* **Registry:** [`com.pipecorn/mcp`](https://registry.modelcontextprotocol.io/v0/servers/com.pipecorn%2Fmcp/versions/latest) in the official MCP registry, also listed on [Glama](https://glama.ai/mcp/connectors/com.pipecorn/mcp)
* **Agent Plugin:** [`Pipecorn/cli-pipecorn`](https://github.com/Pipecorn/cli-pipecorn) (`plugin.json`, `mcp.json`, `skills/pipecorn/SKILL.md`)
* **OAuth metadata:** `https://mcp.pipecorn.com/.well-known/oauth-authorization-server`

## Conventions agents must follow

These aren't optional — they're how you avoid burning the user's credits and surfacing wrong results.

1. **Preview before extracting.** For lead and account search, call the `preview_*` variant first to get the result count, which tells you how much of the plan's extraction or import quota the search would use. Only run the extracting variant after the user confirms.
2. **Resolve industries by name.** Before any search with an industry filter, call `search_industries` to get the LinkedIn industry ID. Do not guess IDs.
3. **Resolve locations by name.** Same pattern: call `search_locations` before any geo-filtered search.
4. **Poll asynchronous jobs.** Several endpoints return a job ID. Call `get_job_result` with it; the tool waits up to about two minutes itself. If it answers `timed_out`, call it again after 5s. Never tight-loop.
5. **Check credits for bulk work.** Call `get_credits` before bulk enrichment or large extractions. If estimated cost exceeds remaining credits, warn the user and stop. Read the response carefully: only `credits.enrichment` is the spendable balance; `credits.daily_profile_scraping` and `credits.*_company_import` are remaining plan quotas for extraction, which reset on their own and cannot be topped up. See [Credits vs limits](https://docs.pipecorn.com/api-reference/credits-vs-limits.md).
6. **Over MCP, use `bulk_enrich_contacts` for 2+ contacts.** It runs them as one job instead of a loop of `single_enrich_contact` calls; the price per contact is the same. Over REST, `POST /contacts/bulk_enrich` is deprecated: send one `POST /contacts/single_enrich` per contact.
7. **Over REST, send an `Idempotency-Key` on every POST.** Retrying with the same key and body replays the first response instead of enriching or charging again. See [Retries and idempotency](https://docs.pipecorn.com/essentials/idempotency.md).
8. **Pace yourself with the rate limit headers.** REST responses from endpoints under the plan limit carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`; a `429` adds `Retry-After`. Wait that long, do not tight-loop. See [Rate limiting](https://docs.pipecorn.com/essentials/rate-limiting.md).
9. **Follow `Location` on async calls.** Async REST enrichment returns a `Location` header (and `status_url`) pointing at the status URL. Poll it with backoff. Page through list endpoints with `cursor`, not `page`. See [Async results](https://docs.pipecorn.com/essentials/async-results.md) and [Pagination](https://docs.pipecorn.com/essentials/pagination.md).
10. **Branch on the credit and limit error codes.** Over REST, an exhausted balance is `402` with `code: "insufficient_credits"` and a `top_up_url` — surface that link and stop, do not retry. A workspace weekly limit is `403` with `code: "workspace_limit_exceeded"`; buying credits will not lift it, so stop and tell the user to ask a workspace admin. An exhausted extraction quota is `422` with the message `"Can't proceed with the request. Plan limit reached."`; it resets daily or monthly and credits do not help either. On the Scale plan the same request answers `202` with `status: "queued"` instead: it is accepted and starts on its own after the reset, so treat it as a success, poll its `status_url` and never resend it. See [Credit and limit errors](https://docs.pipecorn.com/api-reference/errors.md).

## Authentication

Generate an API key at [https://app.pipecorn.com/settings/apis/keys](https://app.pipecorn.com/settings/apis/keys).

* **REST:** `X-API-KEY: <key>` header, or `X-WORKSPACE-KEY: <key>` for a workspace key. See [auth docs](https://docs.pipecorn.com/essentials/authentication.md).
* **REST sandbox:** send a test key (`pc_test_…`, or the public demo key `pc_test_demo`) in `X-API-KEY` to build against sample data. It spends no credits and changes nothing; responses carry `Pipecorn-Mode: test`. See [Sandbox](https://docs.pipecorn.com/essentials/sandbox.md).
* **MCP via OAuth:** Handled by the client (Claude, ChatGPT), which sends the access token as `Authorization: Bearer <token>`. No key needed. In ChatGPT, install the [Pipecorn app](https://chatgpt.com/plugins/plugin_asdk_app_6a902702ee288191a40d2cb04a0ed9fd) from the app directory.
* **MCP via API key:** `X-API-Key: <key>` header, or `X-Workspace-Key: <key>` for a workspace key. Used by `mcp-remote`, Claude Code, Cursor, and any client supporting custom headers. Never put the key in `Authorization`: that header only accepts OAuth access tokens.
* **CLI:** `PIPECORN_API_KEY` env var, or `~/.config/pipecorn/credentials.json` (mode 0600).

CLI exit codes for programmatic callers: `0` success, `1` API error, `2` input error, `3` auth, `4` rate limit, `5` credits or plan limit exhausted.

## OpenAPI specs

The full REST API is available as a single spec at [https://docs.pipecorn.com/openapi.json](https://docs.pipecorn.com/openapi.json), with an `operationId` and a tag on every operation. There is no language SDK: generate a typed client from this spec ([SDK and client libraries](https://docs.pipecorn.com/sdk.md)). It is generated from the fragments under `api-reference/specs/` by `scripts/build-openapi.mjs`, and a GitHub Action regenerates it whenever a fragment changes. `x-mcp-tool` cross-references are on the roadmap.

## Repository layout

* `docs.json` — Mintlify config: tabs (Home, Get Started, API Reference, CLI, MCP, Integrations), navbar, footer
* `index.mdx` — docs home page, styled by `home.css`
* `introduction.mdx` — Get Started overview
* `sdk.mdx` — SDK and client libraries: calling the API directly, generating a client from the OpenAPI spec
* `api-reference/` — MDX pages and OpenAPI fragments under `specs/`
* `mcp/` — MCP overview, per-client setup, tool reference, example workflows
* `cli/` — CLI overview and command reference (mirrors the `cli-pipecorn` README)
* `essentials/` — authentication and concepts
* `changelog.mdx` — release notes
* `llms.txt` — machine-readable navigational index for LLMs
* `llms-full.txt` — full docs as a single file, auto-generated by Mintlify at the served URL
* `.well-known/mcp.json` — machine-readable MCP server discovery
* `.well-known/ai-plugin.json` — legacy ChatGPT plugin manifest

## Contact

Issues with the agent surface: [mathieu@pipecorn.com](mailto:mathieu@pipecorn.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.