# Gemini Enterprise

Connect Gemini Enterprise to the hosted Ahrefs MCP server with OAuth 2.0. OAuth lets you grant access without sharing your Ahrefs password or providing an Ahrefs API/MCP key.

Follow [Google's official setup guide](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/custom-mcp-server/set-up-custom-mcp-server) to create a Custom MCP Server data store. Use the Ahrefs credentials and configuration below.

## Get your OAuth credentials

Ahrefs uses [OAuth Dynamic Client Registration (DCR)](https://oauth.net/2/dynamic-client-registration/) to issue a client ID and secret for each registration.

Run this command in a terminal to register Gemini Enterprise with Ahrefs:

```sh
curl -X POST https://api.ahrefs.com/mcp/register \
  -H 'Content-Type: application/json' \
  -d '{
    "client_name": "Gemini Enterprise",
    "redirect_uris": ["https://vertexaisearch.cloud.google.com/oauth-redirect"],
    "token_endpoint_auth_method": "client_secret_post",
    "grant_types": ["authorization_code"],
    "response_types": ["code"]
  }'
```

The `redirect_uris` value comes from the [Before you begin section of Google's guide](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/custom-mcp-server/set-up-custom-mcp-server#before_you_begin).

Ahrefs returns a response like this:

```json
{
  "client_id": "v2Ky...",
  "client_secret": "MvEP...",
  "redirect_uris": ["https://vertexaisearch.cloud.google.com/oauth-redirect"],
  "token_endpoint_auth_method": "client_secret_post",
  "grant_types": ["authorization_code"],
  "response_types": ["code"],
  "client_name": "Gemini Enterprise",
  "scope": "apiv3-mcp"
}
```

Use the `client_id` and `client_secret` from your response, not the example. Do not share the client secret or commit it to source control.

## Configure the connection in Gemini Enterprise

In the Google Cloud console, open the Custom MCP Server configuration for your Gemini Enterprise app. Select OAuth 2.0 under Authentication settings.

Gemini Enterprise limits each custom MCP server data store to 100 enabled tools, which Google calls actions. Review the [Ahrefs tool groups and modes](./tool-categories.md) before you choose which tools to enable.

The example below uses `essentials`. If you choose a different group or mode, use its MCP server URL instead.

| Field | Value |
| --- | --- |
| MCP Server URL | `https://api.ahrefs.com/mcp/mcp?tools=essentials` |
| Authorization URL | `https://app.ahrefs.com/web/oauth/authorize` |
| Authorization URL Parameters | Leave blank. |
| Token URL | `https://ahrefs.com/oauth/token` |
| Client ID | The `client_id` from your registration response. |
| Client Secret | The `client_secret` from your registration response. |
| Scopes | `apiv3-mcp` |
| Enable PKCE Support | Select this option. |
| Use HTTP Basic Authentication | Clear this option. |

Gemini Enterprise selects the `Use HTTP Basic Authentication` checkbox by default. Clear it so that Gemini Enterprise sends the credentials in the token request body, as `client_secret_post` requires.

1. Click `Verify Auth`.
2. Sign in to Ahrefs if prompted.
3. Approve the requested access.
4. Return to Gemini Enterprise and click `Continue`.
5. Follow Google's guide to finish creating the data store.
6. Follow [Google's steps to enable actions](https://docs.cloud.google.com/gemini/enterprise/docs/connectors/custom-mcp-server/set-up-custom-mcp-server#enable-actions) for the Ahrefs tools that you want to use.
