# Generate docs, SDKs and MCP servers

> Turn a collection into a self-contained HTML API reference, a TypeScript, Python or Swift client SDK, or a runnable Node.js MCP server for AI tools.

Source: https://docs.subcloak.com/cloak-proxy/api-client/run/generate-docs-sdks-and-mcp-servers/

A collection already describes your API: its requests, parameters, bodies, auth and example responses. Cloak Proxy can turn it into three things you can hand to other people or tools. **HTML documentation** is one file you can host anywhere. A **client SDK** gives developers typed methods for each request. An **MCP server** lets AI assistants such as Claude call your API as tools. Everything is generated on your Mac, from the collection as it is now.

| Output | Formats | Where to start |
| --- | --- | --- |
| [API documentation](#api-documentation) | One HTML file | **More** › **Export API Documentation (HTML)…**, or **Docs Branding** › **Export HTML Docs…** |
| [Client SDK](#client-sdks) | TypeScript, Python, Swift | Right-click the collection › **Generate SDK** |
| [MCP server](#mcp-servers) | Node.js project in a zip | **More** › **Generate MCP Server…** |

Only HTTP and GraphQL requests are included in SDKs and MCP servers. Docs list every request, with code samples for HTTP and GraphQL requests.

*[Screenshot: The Petstore collection tab with Run, Load Test, Mock and More buttons in the header and an Overview tab showing 12 requests, 1 folder, 4 examples and 3 with tests. The More menu in a collection's header has the generators and exports.]*

## API documentation

API documentation is a single, self-contained HTML file: no server, build step or external files. Host it on GitHub Pages, S3 or your own domain, or send it as an attachment.

1. Write the docs you want readers to see: the collection's **Overview** documentation, folder overviews and each request's docs, all in Markdown. Save examples for the responses you want to show. See [Examples and docs](https://docs.subcloak.com/cloak-proxy/api-client/examples-and-docs/).

2. Optionally set the title, accent color, logo and footer on the collection's **Docs Branding** tab, and click **Preview** to check them.

3. Open the collection and choose **More** › **Export API Documentation (HTML)…**. You can also right-click the collection and choose **Export** › **API Documentation (HTML)…**, or click **Export HTML Docs…** on the **Docs Branding** tab.

4. Choose where to save the file (by default `Collection name docs.html`).

   It opens in your browser when it's saved.

### What's in the docs

| Part | Contents |
| --- | --- |
| Navigation | A sidebar with every folder and request in collection order, with colored method badges. On narrow screens it's hidden and the page is a single column. |
| Introduction | The collection's documentation, an **Authorization** note naming the collection's auth type (when it has one), and a **Variables** table with each enabled collection variable's name, value and description. Secret variables are left out. |
| Folders | A heading with the folder's documentation. |
| Each request | The method and name, the URL, the request's documentation, then tables of **Path variables**, **Query parameters** (optional ones are marked) and **Headers**, and the **Body** (raw, form, multipart or GraphQL query and variables). |
| Code examples | A snippet for each HTTP and GraphQL request in the language picked under **Code examples**: cURL, JavaScript, Python, NodeJS – Axios, Go, Swift, Java – OkHttp, C# – HttpClient, PHP – cURL or Ruby – Net::HTTP. The reader's choice is remembered in their browser. Snippets keep `{{variables}}` as they are, so readers can see what to fill in. |
| Examples | Each saved example with its name, status code and pretty-printed body. |
| Footer | Your branding footer, and **Made with Cloak Proxy** with the date unless you hide it. |

The page follows the reader's light or dark mode. Markdown in docs supports headings, paragraphs, bold, italic, inline code, code blocks, bulleted and numbered lists, `http` and `https` links, quotes and horizontal rules.

### Brand the docs

*[Screenshot: The Docs Branding tab with the title Petstore API Reference, accent color #ff6c37, a logo field, a Markdown footer and a toggle to hide Made with Cloak Proxy. Docs Branding applies to every docs export of the collection.]*

| Field | What it does |
| --- | --- |
| **Title** | Replaces the collection name as the page title. |
| **Accent color** | A CSS color such as `#ff6c37`, typed or picked with the color well. Used for the title, links and hover states. Only plain color syntax is accepted. |
| **Logo** | An `https://` URL, or **Choose…** to embed a PNG, JPEG, SVG or GIF under 512 KB in the file itself. |
| **Footer (Markdown)** | Text at the bottom of the page, such as a copyright line and a link to your status page. |
| **Hide “Made with Cloak Proxy”** | Removes the attribution line. |

Branding is saved with the collection, so `cloakctl docs` uses it too. See [Examples and docs](https://docs.subcloak.com/cloak-proxy/api-client/examples-and-docs/) for more on writing docs.

> **Check what you publish:**
> Docs include request URLs, headers, example bodies and enabled collection variable values. Secret variables are left out, but values typed directly into headers or bodies aren't. Review the file before you publish it, and use `{{variables}}` for tokens and keys.

### Generate docs from the command line

```bash title="Terminal"
cloakctl docs "Petstore" --out ./site/index.html
```

`NAME` can be a collection in the workspace, or a Postman collection or OpenAPI file. `--out` is required. Add `--workspace DIR` for a different workspace. This makes it easy to rebuild docs in CI whenever the collection changes. A spec's **Preview Docs** button builds the same kind of page from an OpenAPI spec; see [Specs](https://docs.subcloak.com/cloak-proxy/api-client/run/specs/#preview-docs).

## Client SDKs

A client SDK wraps each request in the collection in a method, so developers call `api.getPet(1)` instead of building URLs by hand.

1. In the sidebar, right-click the collection and choose **Generate SDK** › **TypeScript…**, **Python…** or **Swift…**.

2. Choose a folder and click **Generate Here**.

   Cloak Proxy creates a folder named `<collection>-<language>-sdk` inside it, for example `petstore-typescript-sdk`, and shows it in Finder.

### How requests become methods

| From the collection | In the SDK |
| --- | --- |
| Collection name | The client class: `Petstore` → `PetstoreClient`. |
| `baseUrl` collection variable | The default base URL. Without one, the scheme and host of the first absolute request URL. You can override it when creating the client. |
| Request name | The method name in camelCase (`Get pet` → `getPet`), or snake_case in Python (`get_pet`). Names that clash with language keywords get a `Request` suffix, and duplicates get a number. |
| Path variables (`:id`) and `{{variable}}` path segments | Required arguments, URL-encoded into the path. |
| Query params | An optional `query` argument with those keys. |
| Body | An optional `body` argument, sent as JSON, for requests with a raw or GraphQL body and for every `POST`, `PUT` and `PATCH`. |
| First line of the request's docs | The method's doc comment. |

Every client sends `Accept: application/json`, adds `Authorization: Bearer <token>` when you pass a token, parses JSON responses, and raises an error for status codes outside 2xx. Other auth types from the collection aren't carried over; pass extra headers yourself where the language supports it.

**TypeScript**

- petstore-typescript-sdk/
  - src/
    - index.ts
  - package.json
  - tsconfig.json
  - README.md

```ts title="Usage"
import { PetstoreClient } from "./src/index";

const api = new PetstoreClient({ token: process.env.API_TOKEN });
const result = await api.getPet(1);
console.log(result.status, result.data);
```

- `new PetstoreClient(options)` takes `baseUrl`, `token`, `headers` (added to every request) and `fetch` (your own fetch implementation).
- Each method returns `Promise<ApiResponse>` with `status`, `headers` and `data`.
- Errors are thrown as an `Error` with `status` and `data` properties.
- `npm run build` compiles it with TypeScript (`typescript` is the only dev dependency).

**Python**

- petstore-python-sdk/
  - petstore_client.py
  - README.md

```python title="Usage"
from petstore_client import PetstoreClient

api = PetstoreClient(token="...")
print(api.get_pet(1))
```

- `PetstoreClient(base_url=..., token=None, headers=None, timeout=30)`.
- Methods return the parsed JSON, or the text when the response isn't JSON.
- Errors raise `ApiError` with `status` and `data`.
- Uses only the standard library (`urllib`), so there's nothing to install.

**Swift**

- petstore-swift-sdk/
  - Package.swift
  - Sources/
    - PetstoreClient/
      - PetstoreClient.swift
  - README.md

```swift title="Usage"
let api = PetstoreClient(token: "...")
let response = try await api.getPet(petId: "1")
let pet = try response.decode(Pet.self)
```

- A Swift package for macOS 12 and iOS 15 or later, with no dependencies.
- `PetstoreClient(baseURL:token:session:)`; methods are `async throws` and return `APIResponse` with `status`, `headers`, `data` and `decode(_:)`.
- Errors throw `APIError` with `status` and `data`.

Each SDK's `README.md` has a usage example and lists every method with its HTTP method and path. Generating again into the same folder overwrites the files.

## MCP servers

An MCP server lets AI assistants call your API. Cloak Proxy generates a small Node.js project, using the official MCP TypeScript SDK, with one tool per request in the collection. This is like Postman's MCP Generator. It's different from [Cloak Proxy's own MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/), which lets AI tools control Cloak Proxy itself.

1. Open the collection and choose **More** › **Generate MCP Server…**, or right-click the collection and choose **Generate MCP Server…**.

2. Choose where to save the zip (by default `<collection>-mcp.zip`). The dialog says how many tools it contains.

   The zip is shown in Finder. It holds one folder named after the collection.

3. Unzip it and install the dependencies (Node.js 18 or later):

   ```bash title="Terminal"
   cd petstore
   npm install
   cp .env.example .env
   ```

4. Fill in `.env` with your token and any other values.

5. Add the server to your MCP client. The project's `README.md` has ready-made configuration for Claude Desktop, Claude Code, Cursor and VS Code.

If the collection has no HTTP or GraphQL requests, Cloak Proxy shows **Add at least one request to generate an MCP server**.

### What's in the project

- petstore/
  - package.json  dependencies, start scripts and a bin entry
  - index.js  the server and its tool definitions
  - .env.example  every environment variable the server reads
  - README.md  tools, setup and client configuration
  - .gitignore  ignores node_modules and .env

The project depends only on `@modelcontextprotocol/sdk` and `zod`.

### How requests become tools

| From the request | In the tool |
| --- | --- |
| Name | The tool name in lowercase with underscores (`Get pet` → `get_pet`), made unique. The original name is the tool's title. |
| Docs | The tool description. Without docs, the method and URL. |
| Path variables | Required arguments, filled into the URL. |
| Query params | Arguments added to the query string. Required when the param is turned on. |
| Top-level fields of a flat JSON body | Optional arguments, typed from the example value (string, integer, number, boolean, array or object). A GraphQL request sends its query as a JSON `query` field. |
| Enabled headers | Sent with every call. |
| Collection or folder auth | **Bearer Token** → `Authorization: Bearer {{API_TOKEN}}`. **API Key** in a header → that header with `{{API_KEY}}`. **Basic Auth** → `Authorization: Basic {{BASIC_AUTH}}` (put the Base64-encoded `user:password` in `BASIC_AUTH`). Other auth types, and API keys in the query string, aren't carried over. |

Any other `{{variable}}` left in a URL, header or body is read from an environment variable with the same name. Non-secret collection variables, such as `baseUrl`, become defaults in `index.js` and `.env.example`. Secret variables are never copied into the project.

When a tool runs, it sends the request (with a 30-second timeout) and returns `HTTP status` and the response body, pretty-printed when it's JSON and cut off after 100,000 characters. A response outside 2xx is reported to the AI client as an error. If a needed environment variable is missing, the tool returns **Missing environment variable NAME. Set it in .env or your MCP client config.**

### Run the server

**stdio**

Most desktop MCP clients start the server themselves and talk to it over stdio:

```bash title="Terminal"
node index.js
```

```json title="Claude Desktop: claude_desktop_config.json"
{
  "mcpServers": {
    "petstore": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/petstore/index.js"],
      "env": { "API_TOKEN": "<your API_TOKEN>", "baseUrl": "https://api.example.com/v1" }
    }
  }
}
```

**Streamable HTTP**

Run it as a local HTTP server and point the client at `/mcp`:

```bash title="Terminal"
node index.js --http --port 3000
```

The server listens on `http://127.0.0.1:3000/mcp`. Set `PORT` and `HOST` environment variables to change where it listens. `npm run start:http` starts it on the default port.

`.env` next to `index.js` is loaded automatically on Node.js 20.12 and later; real environment variables take precedence. Test the server with the MCP Inspector: `npx @modelcontextprotocol/inspector node index.js`.

> **An AI client can call every tool:**
> Each tool sends a real request with your credentials, including any `DELETE` or `POST` requests in the collection. Before you connect an AI assistant, remove tools you don't want it to call from the `TOOLS` list in `index.js`, and use a token with the least access it needs. Keep `.env` out of version control (the generated `.gitignore` already does). The HTTP mode has no authentication of its own, so keep it on `127.0.0.1`.

## From the command line and AI assistants

| Output | Command line | [MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/) tool |
| --- | --- | --- |
| HTML docs | `cloakctl docs NAME --out FILE.html` | `generate_docs` |
| Client SDK | `cloakctl sdk NAME --language typescript\|python\|swift --out DIR` (added in Cloak Proxy 0.2.0) | `generate_sdk` |
| MCP server | `cloakctl mcp-server NAME --out DIR\|FILE.zip` (a zip when the path ends in `.zip`, otherwise a folder) (added in Cloak Proxy 0.2.0) | `generate_mcp_server` (writes a zip when the path ends in `.zip`, otherwise a folder) |
| OpenAPI spec | — | `generate_openapi` |

`NAME` can be a collection in the workspace, or a Postman collection or OpenAPI file, and every command accepts `--workspace DIR`. `cloakctl sdk` writes its files straight into the `--out` folder, without the extra `<collection>-<language>-sdk` folder the app adds. `cloakctl mcp-server` writes a zip like the app's when `--out` ends in `.zip`, and otherwise writes the project's files straight into the folder. Either way you can regenerate an SDK or server in CI whenever the collection changes. See [cloakctl](https://docs.subcloak.com/cloak-proxy/automation/cloakctl/#generate-an-sdk) for details and [MCP tools reference](https://docs.subcloak.com/cloak-proxy/automation/mcp-tools-reference/) for the arguments of each tool.

## Related

  - [Examples and docs](https://docs.subcloak.com/cloak-proxy/api-client/examples-and-docs/): Write the docs and examples that generators use.
  - [Specs](https://docs.subcloak.com/cloak-proxy/api-client/run/specs/): Lint the operation IDs and descriptions SDKs rely on.
  - [MCP server](https://docs.subcloak.com/cloak-proxy/automation/mcp-server/): Connect AI tools to Cloak Proxy itself.
  - [Code snippets](https://docs.subcloak.com/cloak-proxy/api-client/code-snippets/): Copy one request as code in many languages.
