# Configure the Affinity MCP Server

Connect Affinity's official hosted MCP server to a Dtwo gateway with an API key.

## Overview

Affinity operates an official hosted MCP server at `mcp.affinity.co` covering companies, people, opportunities, lists, saved views, notes, and meetings. The gateway authenticates with an Affinity API key sent as a bearer token.

The API key belongs to one Affinity user, and tool calls execute as that user with their CRM permissions. Create the key under a service account whose visibility matches what your agents should be able to read, rather than an individual's login.

## 1. Configure Affinity

1. Log in to Affinity as an admin and go to **Settings → Users and Permissions → Roles**. Turn on the **Manage MCP Agents** permission for the roles that should be able to reach Affinity through Dtwo.
2. Sign in as the user whose permissions the agent should inherit, then go to **Settings → Manage Apps → API Keys** and generate a key. Copy it now — Affinity shows it only once.

## 2. Add the MCP server to your gateway config

Go to your gateway in the Dtwo UI and open **Configuration → Advanced**. In the `mcp_servers` section add the following entry:

```yaml
  - name: affinity
    description: "Affinity's official hosted MCP server for relationship intelligence and CRM records."
    url: https://mcp.affinity.co/mcp
    transport_type: streamablehttp
    authentication:
      type: bearer
      token: "<AFFINITY_API_KEY>"
```

Replace the placeholder value:

- `<AFFINITY_API_KEY>` — the API key you generated in step 1.

## 3. Deploy and verify

Save the configuration and deploy the gateway.

Because the key is configured on the server entry, there's no authorization prompt — the connection is live as soon as the gateway is deployed. In your AI client, confirm the server's tools appear and run a read-only call, such as `get_lists` or `search_companies_top_matches`, to make sure the connection and the key's permissions work before enabling any write tools.

---

Having trouble? Email [support@dtwo.ai](mailto:support@dtwo.ai).