DEV Community

Cover image for Connect Any AI Agent to RedirHub in 5 Minutes - Claude, Cursor, or Codex
Redirhub
Redirhub

Posted on

Connect Any AI Agent to RedirHub in 5 Minutes - Claude, Cursor, or Codex

You manage redirects through a dashboard. Your AI agent just sits there, smart but disconnected.

There's a better pattern: give it MCP access and let it manage your redirects directly — from the same chat where you plan your deployment.

I'll show you the setup for Claude Desktop, Cursor, and VS Code / Codex. It takes about five minutes, and the Free plan is enough.


Step 1: Generate a Workspace API Token

Log into your RedirHub dashboard and go to Settings → API Tokens. Click Generate Token, name it something like "Claude Desktop" or "Cursor MCP", and copy the token — it starts with rh_ and is shown only once.

Keep this token private. You can revoke or rotate it anytime from the same page.

Even on the Free plan, you get full access to the MCP server — 17 tools and 15 resources. No upgrade needed.


Step 2: Add the MCP Config to Your Client

The server endpoint is:

https://api.redirhub.com/mcp/v1
Enter fullscreen mode Exit fullscreen mode

Authentication is a Bearer token in the Authorization header. Each client handles config differently — pick yours.

Claude Desktop

Claude Desktop reads MCP servers from a JSON config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Open or create this file and add:

{
  "mcpServers": {
    "redirhub": {
      "command": "npx",
      "args": [
        "-y",
        "@anthropic/mcp-client",
        "https://api.redirhub.com/mcp/v1",
        "--header",
        "Authorization: Bearer YOUR_API_TOKEN"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Replace YOUR_API_TOKEN with the token from Step 1. Save the file, then completely quit and reopen Claude Desktop (Cmd+Q on macOS — closing the window isn't enough).

After restart, look for a small 🔌 icon in the chat input bar. Click it — you should see 17 RedirHub tools listed.

Cursor

Cursor uses a .cursor/mcp.json file in your project root:

{
  "mcpServers": {
    "redirhub": {
      "url": "https://api.redirhub.com/mcp/v1",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Save the file and restart Cursor (or run Developer: Reload Window from the command palette). The RedirHub tools will now be available in Cursor's AI chat.

VS Code / Codex

OpenAI Codex reads from .codex/mcp.json — same format as Cursor:

{
  "mcpServers": {
    "redirhub": {
      "url": "https://api.redirhub.com/mcp/v1",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Save it in your project root and restart the Codex extension. You can also configure this globally via Codex's settings panel under MCP Servers → Add Server.

Any Other MCP Client

HTTP transport at https://api.redirhub.com/mcp/v1 with a Bearer token header. Consult your client's MCP docs if the format differs.


Step 3: Your First AI-Powered Redirect

Your client is connected. Let's do something real — skip the dashboard entirely.

Create a 301 Redirect via Chat

Open your AI client and type:

"Create a 301 redirect on RedirHub. The source URL should be /summer-sale on my domain, pointing to https://myshop.com/summer-2026. Use dry-run mode first so I can preview it."

Your agent will:

  1. Call the CreateLink tool with dry_run: true
  2. Show you exactly what will be created — the source, destination, redirect type, and which workspace it lives in
  3. Wait for your confirmation before going live

Once you confirm, the redirect is created instantly. Same result as the dashboard form, but you never left your chat.

List All Your Links in One Message

Now try:

"List all my short links in my active RedirHub workspace."

Your agent calls the ListLinks resource and returns them formatted — domain, slug, destination URL, and status. No filtering dropdowns, no pagination clicking.

This is the mental-model shift: you're not filling out forms anymore. You're having a conversation with your infrastructure.


5 Real Prompts to Try

Here are prompts that go beyond the basics. Copy-paste any of them into your connected AI client:

1. Bulk import from a CSV

"I have a CSV at ~/redirects.csv with columns 'from' and 'to'. Import all of them into RedirHub as 301 redirects. Use dry-run first."

2. Find and fix broken links

"Check all my redirects that point to 404 destinations. List them and offer to update each one to a working URL."

3. UTM parameter sweep

"Add UTM parameters to all my links tagged 'spring-campaign'. Append ?utm_source=newsletter&utm_campaign=spring2026 to each destination URL."

4. Domain migration prep

"Export all redirects from my workspace as JSON. I'm migrating domains and need a full inventory first."

5. Analytics check

"Show me the top 10 most-clicked redirects this month with their click counts and last-clicked timestamps."


Troubleshooting

Symptom Fix
🔌 Plug icon missing Quit Claude completely (Cmd+Q), not just close the window
"Cannot connect to MCP server" Verify the token is correct and not expired. Regenerate in Settings → API Tokens
Cursor not showing tools Check .cursor/mcp.json is in your project root, not your home directory
Codex tools not appearing Try the global config path via settings panel instead of .codex/mcp.json
Agent says "I don't have that tool" Restart the client. Some IDEs cache MCP servers at startup only

That's it. You now have an AI agent that can read, create, update, and delete redirects on your behalf. The same setup works whether you're managing five redirects or five thousand — the only difference is the prompt you type.


Originally published on RedirHub Blog

Top comments (0)