# Give an Agent a custom MCP server

> Connect an Agent to a remote MCP server of your choice, sign it in with the server's page or an API key, and remove it.

Source: https://air.build/docs/agents/add-a-custom-mcp-server/

Besides the services AirBuild lists, an Agent can use any remote MCP server you point it at: a tool your company runs, or a service that publishes an MCP server. The server becomes one of the Agent's Connections, and the Agent uses the server's tools when its work calls for them. Anyone in the Team can add or remove one.

For the services AirBuild lists, and for what each Connection state means, see [Connect an Agent to outside services](https://air.build/docs/agents/connect-outside-services/).

## Before you start

You need:

- The server's address. It must be a public `https://` address of a remote MCP server ("A remote MCP server the agent reaches over HTTPS."). A server that runs as a command on your own computer can't be added, and neither can an address on a private network.
- To know how the server lets clients in:

| The server | Choose under **Sign-in** |
| --- | --- |
| Shows its own sign-in page, and lets apps sign in without registering with it first | **Sign-in Page** |
| Gives you an API key or a token, or asks you to register an app first | **API Key** |
| Is open to anyone | **None** |

## Add the server

1. Open the Agent's profile. See [Edit an Agent's profile](https://air.build/docs/agents/edit-an-agent/).
2. Under **Connections**, tap **Add Connection**, then **Add a Custom MCP Server…**.
3. Type a **Name**. It's required, and it's the name you and the Agent see on the Connection.
4. Type the server's **URL**, starting with `https://`.
5. Choose **Sign-in**: **Sign-in Page**, **API Key** or **None**.
6. For **API Key**, fill in the headers (see below).
7. Optionally, under **What it's for (optional)**, write one line about the server. "The agent reads this to know when to use the server."
8. Tap **Add**.

**Add** stays off until there's a name and an `https://` address, and, for **API Key**, at least one header with a value.

What happens next depends on **Sign-in**:

| **Sign-in** | After you tap **Add** |
| --- | --- |
| **Sign-in Page** | The sign-in starts right away. Sign in on the server's page and allow access, as in [Sign in from a card](https://air.build/docs/agents/connect-outside-services/#sign-in-from-a-card). Until someone does, the row says **Not Connected** with **Connect**. |
| **API Key** | The server is ready. Under its name, the row shows the server's host, for example `mcp.example.com`. |
| **None** | The server is ready. Under its name, the row shows the server's host. |

The Agent picks up a new server within a minute or so.

## Fill in an API key

**API Key** sends fixed headers with every request the Agent makes to the server.

1. Under **Headers**, the first row's **Header** is already `Authorization`. Change it if the server asks for another header name.
2. Type the key or token in **Value**, exactly as the server's documentation shows it, for example `Bearer` followed by a space and the token if that's what it asks for.
3. To send more headers, tap **Add Header**. A server can have up to 8. To drop a row, tap the red minus next to it.

Each header name can appear once. A row left completely empty is ignored. "Saved values are never shown again."

## Change the key

When a key changes or expires:

1. On the Agent's profile, find the server under **Connections**.
2. Tap **Update Key** on the row, or choose **Update Key…** from the row's **⋯** menu.
3. The **API Key** page shows the header names you saved, with empty values. Type every value again.
4. Tap **Save**.

**Save** replaces all the server's headers with the ones on the page.

If the server stops accepting the key, the row says **Needs Reauthorization** and shows **Update Key**. If the server was added without a key yet, the row shows **Add Key**, which opens the same page.

An Agent can also ask for the key with a card in chat. Its button is **Connect** followed by the server's name. For a server that takes an API key, tapping it opens the **API Key** page instead of a browser. When you tap **Save**, the card is answered and the Agent carries on.

## Ask an Agent to add a server

You can also ask an Agent in chat to add a server to itself. Give it the address and say how the server signs in.

If the server takes a key, you don't have to paste it into the chat: once the Agent has added the server, tap **Add Key** on its row on the Agent's profile, or the card the Agent sends.

## Remove the server

1. On the Agent's profile, under **Connections**, open the server's **⋯** menu.
2. Choose **Remove from Agent**.
3. Tap **Remove** to confirm: "The agent loses this service and its sign-in. You can add it again later."

The server's sign-in or saved headers go with it. To change a server's name or address, remove it and add it again.

## Questions

**The page says “Use the server's public https address.”**

The address isn't one AirBuild can reach: it doesn't start with `https://`, or it points to a private network. Use the server's public address.

**The page says “A header name or value can't be used. Check them and try again.”**

A header name or value has characters a header can't carry. Check for spaces or line breaks pasted with the key.

**The page says “Keep the name and description to one short line.”**

Shorten the **Name** or **What it's for (optional)**.

**The page says “This agent has as many connections as it can hold. Remove one first.”**

Remove a Connection the Agent no longer needs, then add the server.

**Sign-in Page fails or never shows the server's page**

The server may not let apps sign in without registering first. Remove it, ask the server's owner for an API key or token, and add it again with **API Key**.

**Can I edit a server's address?**

No. Remove the server and add it again with the new address.

**Can other Agents use the server?**

No. A Connection belongs to the Agent it's on. Add the server to each Agent that needs it.
