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

# Use MCP Server

> Use the Trunk MCP server from your IDE or AI application to access flaky test insights and configure test uploads

Trunk Flaky Tests includes a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) server. AI applications like Claude Code or Cursor can use MCP servers to connect to data sources, tools, and workflows, enabling them to access key information and perform tasks.

## Supported AI applications

The following applications are currently supported: Cursor, Claude Code, Gemini CLI, and GitHub Copilot.

<Info>
  Gemini Code Assist and Windsurf are not supported due to their limited support for MCP servers
</Info>

## API

The Trunk MCP server is available at `https://mcp.trunk.io/mcp` and exposes the following tools:

| Tool                                                 | Capability                                                  |
| ---------------------------------------------------- | ----------------------------------------------------------- |
| [`search-test`](./search-test)                       | Experimental: Lookup the id of a test case                  |
| [`fix-flaky-test`](./fix-flaky-test)                 | Experimental: Retrieve insights around a failing/flaky test |
| [`investigate-ci-failure`](./investigate-ci-failure) | Experimental: Retrieve failing test logs from a CI run      |
| [`setup-trunk-uploads`](./set-up-test-uploads)       | Create a setup plan to upload test results                  |

## Authorization

The Trunk MCP server supports two authentication methods.

**OAuth (default)**

OAuth 2.0 + OpenID Connect is the default. MCP clients that support the [MCP authorization spec](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization) will initiate the OAuth flow automatically. Most interactive clients (Cursor, Claude Code, GitHub Copilot) use this path.

**API token**

As an alternative, you can authenticate with your Trunk organization API token. This is useful for MCP clients that do not support OAuth, CI/headless environments, or quick manual setup.

Find your token under **Settings** → **Organization** → **General**, in the **API** section of the Trunk dashboard. Pass it as a Bearer token in the `Authorization` header:

```json theme={null}
{
  "mcpServers": {
    "trunk": {
      "url": "https://mcp.trunk.io/mcp",
      "headers": {
        "Authorization": "Bearer <your-trunk-api-token>"
      }
    }
  }
}
```

API token auth is org-level — all requests are attributed to the organization rather than to a specific user. OAuth remains the preferred method for interactive use because it provides user-level identity.

## Get started

**To get started, configure your AI application to communicate with Trunk's MCP server:**

* [Cursor](./configuration/cursor-ide)
* [GitHub Copilot](./configuration/github-copilot-ide)
* [Claude Code CLI](./configuration/claude-code-cli)
* [Gemini CLI](./configuration/gemini-cli)
