> For the complete documentation index, see [llms.txt](https://docs.trendswap.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trendswap.app/integrations/mcp-server.md).

# mcp server

TrendSwap provides a native **Model Context Protocol (MCP)** server compliant with Anthropic's open standard. This allows AI assistants, such as Claude Desktop, Cursor, and custom LLM agents, to programmatically inspect templates, verify credit balances, and generate viral videos on behalf of users.

## Endpoint Details

* **MCP Server URL**: `https://trendswap.app/api/mcp`
* **Transport**: Streamable HTTP / Server-Sent Events (SSE)
* **Authentication**: Bearer token via `Authorization: Bearer sk_...` (obtain from `/settings/apikeys`).

## Registered MCP Tools

### `list_templates` (Public / Read-Only)

Returns a list of all active viral video templates with their identifiers, descriptions, supported resolutions, and preview image URLs.

* **Inputs**: None (`{}`)
* **Authentication**: None required.

### `get_credits_balance` (Authenticated)

Retrieves the current user's available credit balance and active account tier.

* **Inputs**: None (`{}`)
* **Authentication**: Required (`sk_...`).

### `create_generation_job` (Authenticated)

Dispatches an AI motion transfer and character recasting task.

* **Parameters**:
  * `template` (string, required): e.g. `"burning-bridges"`, `"smalltown-boy-ai"`, `"topo-gigio"`.
  * `image_url` (string, optional): Public URL of portrait photo.
  * `portrait_id` (string, optional): ID of previously uploaded portrait.
  * `resolution` (enum, optional): `"480p"` (default), `"720p"`, or `"1080p"`.
  * `format` (enum, optional): `"vertical"` (default) or `"horizontal"`.
  * `idempotency_key` (string, optional): Client-generated unique key to prevent duplicate charges.

### `get_generation_job_status` (Authenticated)

Polls the execution status and output video URL of an active generation job.

* **Parameters**:
  * `job_id` (string, required): The task ID returned by `create_generation_job`.

## Claude Desktop Configuration Example

Add the following to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "trendswap": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fetch",
        "https://trendswap.app/api/mcp"
      ],
      "env": {
        "AUTHORIZATION": "Bearer YOUR_TRENDSWAP_API_KEY"
      }
    }
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.trendswap.app/integrations/mcp-server.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
