# Connect an MCP server with an API key

Register a tool server that takes a fixed API key or token in a header. You enter the key once in Amiril, and the gateway adds it to every call.

Use the **API key or token** sign-in when the server takes one fixed value with every request. That can be an API key, a personal access token or the key a connector platform gives you. You enter the value once, and agents never see it.

## Add the server [#add-the-server]

<Steps>
<Step>
Open **Tools** and select **Add server**. Paste the server's MCP address into **Server URL**. It often ends in `/mcp`.
</Step>

<Step>
Under **Sign-in**, choose **API key or token**. Amiril marks it **Detected** when the server refuses a request without saying how to sign in.
</Step>

<Step>
In **Header name**, keep `Authorization` unless the vendor names another header, such as `X-API-Key`.
</Step>

<Step>
In **Key or token**, enter the value exactly as the server expects it in that header. Most servers want the word `Bearer`, a space and then the token:

```text
Bearer sk_live_your_token
```
</Step>

<Step>
Select **Test connection**. Amiril signs in and lists the server's tools. Nothing is saved yet.
</Step>

<Step>
Check the **Name**, the **Slug** and each tool's **Access**. [Add a tool server](/tool-servers#check-the-name-slug-and-access) explains each one. Then select the button that adds the tools, such as **Add 2 tools**.
</Step>
</Steps>

The server and its tools now show under **Tools**. Next, [grant the tools to an agent](/agents/access).

## Replace the key [#replace-the-key]

Open the server and select **Edit**. Enter the new value in **Key or token** and select **Save changes**.

Amiril saves the new key and tries it at once. It says **Server updated** when the server accepts it. Otherwise it says **Couldn't sync. The server refused the sign-in.** The refused key still replaces the old one, so agents' calls fail until you enter a key that works.

## Next steps

- [Add a tool server](https://docs.amiril.ai/tool-servers.md): Register the MCP server where your agents' tools live and choose how Amiril signs in to it. Then grant its tools to agents on their Access tab.
- [Connect an MCP server with OAuth client credentials](https://docs.amiril.ai/tool-servers/app-login.md): Register a tool server with the client ID and secret of an app you set up at the vendor. Amiril trades them for an access token and renews it before it expires.
- [Move an in-process tool to a tool server](https://docs.amiril.ai/tool-servers/move-a-tool.md): Take a tool function and its API key out of your agent and put them on a tool server behind the Amiril gateway. The agent keeps one gateway token.
- [Grant tools to an agent](https://docs.amiril.ai/agents/access.md): Turn on the tools an agent may call, give it a gateway token and point its MCP client at the Amiril gateway. Then revoke the tools it stops using.
- [Data storage and retention](https://docs.amiril.ai/workspace/data.md): What Amiril keeps from your traces, rule decisions and tool calls. Set how long each environment keeps data before it is deleted, or stop storing message text.

## More detail

- [Tool servers, the gateway and agent access](https://docs.amiril.ai/assistant/tool-servers.md): Everything about registering MCP tool servers, the four sign-in methods, the Amiril gateway, tool grants, gateway tokens, sync, the access log, access suggestions and their errors.
- [HTTP API: access](https://docs.amiril.ai/assistant/api/access.md): The access routes of Amiril's HTTP API: 16 operations, each with its parameters, request body, responses and token access.
