Affinity Design
Agency Guide

Connecting Claude Code

Use Claude Code CLI with your platform's MCP server for terminal-based AI operations

Overview

Claude Code is Anthropic's terminal-based AI assistant. It supports MCP via HTTP transport, making it ideal for developers and power users who prefer working in the terminal.

Prerequisites

  • Claude Code installed (npm install -g @anthropic-ai/claude-code or via official installer)
  • An active API key with mcp:access scope (generate one here)
  • Your platform URL (e.g., https://api.v2.affinitydesign.ca)

Quick Setup

Add your platform as an MCP server:

claude mcp add --transport http af-platform \
  https://api.v2.affinitydesign.ca/mcp/http \
  --header "X-API-Key: afk_YOUR_KEY_HERE"

Verify it was added:

claude mcp list

You should see:

af-platform
  Transport: http
  URL: https://api.v2.affinitydesign.ca/mcp/http

Usage

Start Claude Code normally:

claude

Then interact with your platform tools naturally:

"List my client's GA4 properties and show traffic for the last 30 days"

"Create a new GHL contact for John Doe with phone +15551234567"

"Upload this screenshot to the asset library and update the WordPress homepage hero"

Working with Multiple Clients

Add multiple servers:

claude mcp add --transport http client-acme \
  https://api.v2.affinitydesign.ca/mcp/http \
  --header "X-API-Key: afk_ACME_KEY"

claude mcp add --transport http client-globex \
  https://api.v2.affinitydesign.ca/mcp/http \
  --header "X-API-Key: afk_GLOBEX_KEY"

When prompting, specify which client:

"Using client-acme, check the Meta Ads campaigns and pause anything with CTR under 1%"

Removing or Updating a Server

Remove:

claude mcp remove af-platform

Update (e.g., after rotating your API key):

claude mcp remove af-platform
claude mcp add --transport http af-platform \
  https://api.v2.affinitydesign.ca/mcp/http \
  --header "X-API-Key: afk_NEW_KEY_HERE"

Advanced: Direct HTTP Testing

You can also test the MCP endpoint directly with curl:

# Initialize session
curl -s -X POST https://api.v2.affinitydesign.ca/mcp/http \
  -H "X-API-Key: afk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-03-26",
      "clientInfo": {"name": "test", "version": "1.0"}
    }
  }'

# List tools (use Mcp-Session-Id from initialize response)
curl -s -X POST https://api.v2.affinitydesign.ca/mcp/http \
  -H "X-API-Key: afk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Mcp-Session-Id: YOUR_SESSION_ID" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}'

Troubleshooting

"Connection refused" or timeout

  • Check your internet connection
  • Verify the platform URL is correct
  • Ensure your API key is active

"Unauthorized"

  • The X-API-Key header may not be reaching the server
  • Try the direct curl test above to isolate the issue
  • Verify the key has mcp:access scope

Tools not available

  • Check claude mcp list to confirm the server is registered
  • Restart Claude Code
  • Verify plugin restrictions on the key aren't too narrow

On this page