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

# MCP server

> Let people ask Compiler questions from Claude, ChatGPT, Claude Code and other MCP clients.

Compiler has a built-in MCP server. Once it's on, people add your instance to their AI tool as a connector, sign in with their Compiler account, and can then ask Compiler about your code without leaving that tool.

There's nothing to install or put in environment variables beyond `PUBLIC_URL`. The server is off until an admin turns it on.

## Prerequisites

* You're an owner or admin of your Compiler organization.
* `PUBLIC_URL` is set to the address people use to reach your instance, such as `https://compiler.yourdomain.com`. The MCP server is only served when it's set.
* The instance is served over HTTPS. MCP clients sign in with OAuth, which refuses a plain `http://` address.

## Step 1: Turn on the MCP server

1. In Compiler, open **Settings** > **Integrations** > **MCP**.
2. Turn on **Enable the MCP server**.
3. Copy the **URL**. It's your instance address followed by `/mcp`, such as `https://compiler.yourdomain.com/mcp`.

The page also lists the tools a connected client can call: `list_projects`, `ask_question` and `get_answer`.

Turning the switch off cuts off every connected client straight away, including ones that are already signed in.

## Step 2: Make sure clients can reach it

Where the client runs decides what needs to reach your instance.

| Client | Connects from | What needs to be reachable |
| - | - | - |
| Claude (web, desktop and mobile) | Anthropic's servers | Your instance, from the internet |
| ChatGPT | OpenAI's servers | Your instance, from the internet |
| Claude Code, Cursor and other local clients | The person's computer | Your instance, from that computer, for example over your VPN |

For Claude and ChatGPT, the paths that need to be public are `/mcp`, `/oauth/token` and `/.well-known/`. The sign-in page itself, `/oauth/authorize`, opens in the person's browser, so it only needs to be reachable from their network.

Your instance also fetches a small document from each client when someone signs in, to check where it may send them back to. If your network restricts egress, allow `claude.ai` for Claude, `chatgpt.com` for ChatGPT, and the equivalent host for any other client.

> [!NOTE]
>
> For its MCP endpoint, Compiler checks that the request's host matches `PUBLIC_URL` and returns `421 Misdirected Request` when it doesn't. Behind a reverse proxy, pass the public hostname through in `Host` or `X-Forwarded-Host`. See [Other platforms](https://docs.usecompiler.com/deployment/other-platforms.md#step-6-expose-it-over-https).

## Step 3: Connect a client

Share the URL from step 1 with your team. Each person connects their own client and signs in as themselves. The **Getting started** checklist in Compiler also shows them the URL.

> [tab] Claude
>
> 1. In Claude, open **Settings** > **Connectors** and click **Add custom connector**.
> 2. Give it a name such as `Compiler`, paste the URL and click **Add**.
> 3. Click **Connect**. Compiler asks you to sign in and allow access.
>
> On a Claude Team or Enterprise plan, an owner adds the connector once in the organization's settings, and each person then clicks **Connect** to sign in.

> [tab] ChatGPT
>
> ChatGPT only allows custom connectors with developer mode on, and on business plans an admin may need to allow them first.
>
> 1. In ChatGPT, turn on developer mode in the connector settings.
> 2. Create a connector, paste the URL, and choose OAuth for authentication.
> 3. Sign in to Compiler and allow access when it asks.
>
> OpenAI moves these settings around often. If they've changed, see OpenAI's help on connecting a custom MCP server.

> [tab] Claude Code
>
> ```bash theme={null}
> claude mcp add --transport http compiler https://compiler.yourdomain.com/mcp
> ```
>
> Then run `/mcp` in Claude Code, choose `compiler` and sign in to Compiler in the browser window it opens.

Other MCP clients work if they support OAuth sign-in with client ID metadata documents. Compiler doesn't offer dynamic client registration, so a client that only supports that can't connect.

## What a connected client can see

A client asks questions as the person who signed it in. It only sees the projects that person can see in Compiler, and each question is answered as it would be in Compiler itself, using your organization's AI provider. Each answer links to the full conversation in Compiler.

## Managing access

* A client stays signed in for up to 30 days of inactivity. After that, the person signs in again.
* People see and revoke their own clients under **Settings** > **Security & access** > **Connected apps**.
* Deactivating or removing someone in **Settings** > **Members** cuts off their clients straight away.
* Turning off **Enable the MCP server** cuts off everyone's clients straight away.

## Troubleshooting

> [accordion] The MCP page says the instance has no public address
>
> `PUBLIC_URL` isn't set. Set it to your instance's address and restart Compiler.

> [accordion] Claude or ChatGPT can't connect
>
> Check that `https://compiler.yourdomain.com/mcp` is reachable from the internet, not just your network, and that the certificate is valid. Claude and ChatGPT connect from their own servers.

> [accordion] Sign-in says the MCP server is turned off
>
> An owner or admin needs to turn on **Enable the MCP server** in **Settings** > **Integrations** > **MCP**.

> [accordion] Sign-in refuses the request
>
> The sign-in page says why. If it says the client couldn't be verified, your instance couldn't fetch the client's metadata document. Allow the client's host in your egress rules, as in [step 2](#step-2-make-sure-clients-can-reach-it).

> [accordion] Requests fail with 421 Misdirected Request
>
> Your proxy is sending a host that doesn't match `PUBLIC_URL`. Pass the public hostname through in `Host` or `X-Forwarded-Host`.


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