# Connect an MCP server with OAuth client credentials

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.

With the **OAuth client credentials** sign-in, Amiril signs in to the server as an app you registered at the vendor. It gets each access token with the app's client ID and secret, and fetches a new one before the old one expires.

## Before you start [#before-you-start]

Register an app at the vendor that may use the OAuth client credentials grant. Note its client ID and client secret. Vendors often call this a service account, a machine-to-machine app or an API client.

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

<Steps>
<Step>
Open **Tools** and select **Add server**. Paste the server's MCP address into **Server URL**.
</Step>

<Step>
Under **Sign-in**, choose **OAuth client credentials**. Amiril marks it **Detected** when the server's login service offers it and no user sign-in.
</Step>

<Step>
Enter the app's **Client ID** and **Client secret**. If the form also shows **Token URL**, the server did not say where to get tokens. Copy that address from the vendor's documentation.
</Step>

<Step>
If the vendor's documentation names scopes for this server, enter them in **Scopes** with a space between each. Otherwise leave the field empty.
</Step>

<Step>
Select **Test connection**. 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>

Next, [grant the tools to an agent](/agents/access).

## Reconnect with a new secret [#reconnect-with-a-new-secret]

When the vendor stops accepting the secret, the server reads **Reconnect needed** and agents cannot use its tools. Open the server and select **Reconnect**. Enter the client ID and the new client secret, then select **Save changes**. To change the secret before it stops working, select **Edit** instead and enter the same two fields. Grants are not touched, so every agent keeps its tools.

## 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 user sign-in](https://docs.amiril.ai/tool-servers/person-login.md): Register a tool server where a person must sign in at the vendor. You approve the login once, and Amiril renews it for the agents that use the server.
- [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.

## 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.
