Blog
guide

How to Connect Ahrefs to Claude Code Using Sequel

Musthaq Ahamad
Musthaq Ahamad
How to Connect Ahrefs to Claude Code Using Sequel

Ahrefs holds your off-site SEO picture: organic keywords, backlinks, referring domains, and competitor visibility. Claude Code is Anthropic's AI coding CLI that runs in your terminal. Sequel's MCP server connects the two, so you can pull SEO data into the same session where you are editing the pages it describes.

This guide covers the full setup in three steps.

What You'll Accomplish

By the end of this guide, you'll be able to run Claude Code and ask questions like:

  • "Which organic keywords does our blog rank for in positions 4 to 10?"
  • "What are the top 20 pages on a competitor's domain by organic traffic?"
  • "Which referring domains did we gain in the last 30 days?"

Claude Code calls Sequel's MCP server, which queries the Ahrefs API and returns the results inline.

Prerequisites

  • A Sequel account: Sign up free at sequel.sh
  • An Ahrefs account on an eligible paid plan for API access
  • Workspace owner or admin permissions, since only those roles can create API keys
  • Claude Code installed: run npm install -g @anthropic-ai/claude-code if you haven't already

Step 1: Connect Ahrefs to Sequel

Sign in to sequel.sh and click Data Sources in the left sidebar.

Sequel Data Sources page

Click New Connection, then select Ahrefs from the connector list.

Choose a connector

Now create the key in Ahrefs. Go to Account settings → API keys and create a new key. Copy it before leaving the page.

Back in Sequel, paste it into the single field:

  • API key: the key from Ahrefs, sent as a Bearer token

Click Connect. Sequel verifies the key against the Ahrefs API before saving it.

Tip: API calls consume units against your plan. Narrow questions cost less than broad ones, so scope by domain and date range rather than asking for everything.

Step 2: Add Sequel to Claude Code

In your terminal:

claude mcp add sequel \
  --transport http \
  https://api.sequel.sh/mcp

Claude Code opens a browser so you can authorize Sequel. Once approved, the server is available in every future session. Add --scope user to install it globally rather than per project.

Verify it registered:

claude mcp list

sequel should appear in the list of configured MCP servers.

Step 3: Query Your Ahrefs Data

Start a Claude Code session and try these:

Which organic keywords does our domain rank for in positions 4 to 10, sorted by search volume?
List the top 20 pages by organic traffic on a competitor's domain, and tell me which topics we have no page for.
Which referring domains did we gain and lose in the last 30 days, and what is the domain rating spread?

Claude Code calls the Sequel MCP server, which hits the relevant Ahrefs endpoint and returns the results in your terminal.

What You Can Do Now

  • Striking distance work: ask "Which of our pages rank between 5 and 15 and have over 500 monthly volume?" to find the cheapest ranking wins.
  • Competitive gap analysis: ask "Which keywords does a competitor rank top 10 for that we do not rank for at all?"
  • Backlink monitoring: ask "Which referring domains did we lose this month, and which pages did they point to?"
  • Content planning from the repo: ask "For the pages in this repo's content directory, which ones have organic keywords in positions 11 to 20?" while you have the files open.
  • Cross-source analysis: with Search Console also connected, ask "For the keywords Ahrefs says we rank 4 to 10 for, what are our actual impressions and CTR in Search Console?"

That last question is where the setup pays for itself. Ahrefs estimates position from its own index. Search Console reports what Google recorded for your property. Comparing them catches both tool error and real opportunity.

For the mechanics of that join, see how to join Search Console and GA4 data with one AI agent. For the wider picture, see AI agents for marketing analytics.

Try Sequel

Meet your always-on data analyst.

An AI data analyst that connects to all your data and answers questions with reports and visualizations. Free for up to 3 seats - no credit card required.

Get started free

Frequently asked questions

Do I need an API key for Claude Code?

Not for Claude Code itself. The `--transport http` flag triggers OAuth auto-discovery, so you authorize Sequel in a browser. You do need an Ahrefs API key to create the data source connection in Sequel.

Where do I create an Ahrefs API key?

In Ahrefs under Account settings, then API keys. Only workspace owners and admins can create one, so you may need someone with those permissions if you are a regular member.

Do I need a paid Ahrefs plan to use the API?

API access requires an eligible paid plan. A limited set of free test queries is available, which is enough to confirm the connection works before committing.

Does the Ahrefs API consume credits?

Yes. Ahrefs meters API usage against your plan, so broad queries across many keywords or domains cost more than narrow ones. Scope your questions to the domain and date range you actually need.

Can Claude Code change anything in my Ahrefs account?

No. The connector ships read tools only, covering domain overview, keywords overview, organic keywords, top pages, backlinks, and referring domains. There is no write path.

Can I compare my site against a competitor?

Yes. The domain overview and organic keywords tools accept any domain, so you can ask for a comparison in one question rather than running two separate reports.

Is Ahrefs data the same as Search Console data?

No, and the difference matters. Ahrefs estimates from its own crawl and index. Search Console reports what Google actually recorded for your property. Use Search Console for your own site's truth and Ahrefs for competitive and off-site visibility.

Written by

Musthaq Ahamad
Musthaq Ahamad

Co-founder and CEO of Sequel. Previously built developer tools and data infrastructure. Passionate about making data accessible for everyone.