# FansAPI agent quickstart

Connect your coding agent to public FansAPI documentation. This server reads documentation; it does not access accounts or make account API requests.

Endpoint: https://docs.fansapi.com/api/mcp
Transport: Streamable HTTP
Authentication: none for public documentation.

## Claude Code

Install Claude Code and open a terminal in the project where you want to use FansAPI.

With Claude Code installed, run this in your project’s terminal.

```shell
claude mcp add --transport http fansapi-docs https://docs.fansapi.com/api/mcp
```

Start a new Claude Code session in that project. Run /mcp and check that fansapi-docs is connected.

## Cursor

Install Cursor and open your project. You can add the docs server through the install link or your project configuration.

Merge this server into .cursor/mcp.json. Keep any existing servers.

```json
{
  "mcpServers": {
    "fansapi-docs": {
      "url": "https://docs.fansapi.com/api/mcp"
    }
  }
}
```

In Cursor’s MCP settings, check that fansapi-docs is enabled and its tools are available. Then open a new Agent chat.

## Codex

Install the Codex CLI and open your project in a terminal. Keep any existing MCP configuration when adding this server.

With the Codex CLI installed, run this in your terminal.

```shell
codex mcp add fansapi-docs --url https://docs.fansapi.com/api/mcp
```

Start a new Codex CLI session. Run /mcp and check that fansapi-docs and its tools are available.

## First prompt

Use the fansapi-docs MCP server to find and read the documentation for listing connected accounts. Show a minimal Node.js example using an environment variable for the API key, and link to the source documentation.

## Documentation tools

- search_docs: search for relevant pages.
- get_doc_page: read a documentation page.
- get_overview: read the documentation index.

## Two-file read-only API quickstart

This is separate from public docs MCP. It requires a real API key from https://app.onlyfansapi.com/api-keys. The official OnlyFans API contract specifies Bearer authentication and GET /api/whoami. Do not put the key in a browser bundle or commit it.

Requires Node.js 22 or newer. Create these two files in an empty directory. No dependencies or install step are needed.

### 1. package.json

```json
{"private":true,"type":"module","scripts":{"start":"node index.mjs"},"engines":{"node":">=22"}}
```

### 2. index.mjs

```javascript
const apiKey = process.env.FANSAPI_API_KEY;
if (!apiKey) throw new Error("Set FANSAPI_API_KEY in your server environment.");
const response = await fetch("https://app.onlyfansapi.com/api/whoami", {
  headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
  signal: AbortSignal.timeout(15000)
});
if (!response.ok) throw new Error(`Request failed: HTTP ${response.status}`);
const data = await response.json();
if (!data || typeof data !== "object" || !data.api_key || !data.team) {
  throw new Error("Unexpected response; compare it with the current OpenAPI reference.");
}
console.log("Authenticated: API key and team returned. No account data was modified.");
```

### Run and verify

Set FANSAPI_API_KEY through your shell or secret manager, then run `npm start` (or `bun run start`). Never paste a real key into the source file. A successful request verifies that the response includes `api_key` and `team`, and prints a confirmation without logging their contents. HTTP errors stop the script. Check key validity and the current official reference if it fails.

This example was checked against the official schema and mocked responses; it was not executed with a live API key. The request reads API-key/team details and does not publish or message.

Schema: https://www.fansapi.com/openapi.yaml
Official upstream: https://app.onlyfansapi.com/scribe-docs/openapi.yaml
OpenAPI version: 3.0.3; API document version: 1.0.0. Snapshot checked: 2026-10-10.
Scope: OnlyFans API. Fansly and Fanvue have separate official specifications; this file does not establish Instagram or general social publishing support.

Validation note: YAML parsing and reference resolution pass. The upstream file has schema-validation errors in unrelated media-upload request types and an empty Smart Link update response map. The download preserves the source unchanged. Do not treat it as a fully validated generated-client contract until the API team fixes those upstream errors.


## Next steps

Review generated code and use the authentication specified by the source API documentation. Keep credentials on your server. A docs connection does not grant account access.

Reference: https://docs.fansapi.com/introduction/guides/develop-with-ai-agents

Instructions and public tool discovery checked: 2026-10-09.
