---
title: "Connecting AI Agents with MCP"
description: "Connect your AI coding assistant (Claude Code, Cursor, or Windsurf) to Shaf's native Model Context Protocol (MCP) server in under 3 minutes."
---

> Documentation Index
> Fetch the complete documentation index at: https://shaf.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting AI Agents with MCP

# Connecting AI Agents with MCP

Connect your AI coding assistant (Claude Code, Cursor, or Windsurf) to Shaf's native Model Context Protocol (MCP) server and execute link operations using natural language in under 3 minutes.

---

## Prerequisites

- An active Shaf account on [dash.shaf.app](https://dash.shaf.app).
- An AI client supporting MCP: Claude Code CLI (`@anthropic-ai/claude-code`), Cursor, or Windsurf.

---

## Step-by-Step Instructions

1. **Generate a Scoped MCP Token**

   Navigate to [dash.shaf.app/dashboard/settings/mcp](https://dash.shaf.app/dashboard/settings/mcp) and click **Generate Token**.

   Select your desired token scope:

   - **Read-Write (`mcp_rw_`)**: Allows creating, updating, and deleting links, generating QR codes, and reading analytics.
   - **Read-Only (`mcp_ro_`)**: Restricts the assistant to reading links, querying metrics, and inspecting domain status.

   Click **Create Token** and copy the generated secret key:

   ```bash
   export SHAF_MCP_TOKEN="mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c"
   ```

   **Expected output:**
   The token appears in the active MCP tokens table with status `Active` and permission scope `read-write`.
2. **Configure Your AI Assistant Client**

   Configure the MCP server connection in your client configuration:

   ### Claude Code

   Register the remote HTTP transport server via the Claude CLI:

   ```bash
   claude mcp add shaf -- https://shaf.app/api/v1/mcp -H "Authorization: Bearer $SHAF_MCP_TOKEN"
   ```

   Alternatively, add to `~/.claude/claude.json`:

   ```json
   {
     "mcpServers": {
       "shaf": {
         "type": "http",
         "url": "https://shaf.app/api/v1/mcp",
         "headers": {
           "Authorization": "Bearer mcp_rw_your_token_here"
         }
       }
     }
   }
   ```

   ### Cursor

   Add the stdio bridge or remote HTTP endpoint in Cursor **Settings** → **Features** → **MCP**:

   ```json
   {
     "mcpServers": {
       "shaf": {
         "type": "http",
         "url": "https://shaf.app/api/v1/mcp",
         "headers": {
           "Authorization": "Bearer mcp_rw_your_token_here"
         }
       }
     }
   }
   ```

   ### Windsurf / Stdio Bridge

   Add the official `@shaf/mcp` bridge to `~/.codeium/windsurf/mcp_config.json`:

   ```json
   {
     "mcpServers": {
       "shaf": {
         "command": "npx",
         "args": ["-y", "@shaf/mcp"],
         "env": {
           "SHAF_API_TOKEN": "mcp_rw_your_token_here"
         }
       }
     }
   }
   ```

   **Expected output:**
   The AI client confirms the connection during session startup:

   ```text
   Connected to MCP server "shaf" (5 tools, 2 resources discovered)
   ```
3. **Discover Available Tools**

   Prompt your AI assistant to list its registered Shaf capabilities:

   ```text
   List available Shaf tools and describe what each one does.
   ```

   **Expected output:**
   The assistant outputs the tool catalog:

   ```text
   Discovered 5 Shaf MCP tools:
   - create_link: Creates an edge short link with optional custom slug, tags, and domain.
   - list_links: Lists existing links in the active workspace with filtering.
   - get_link_analytics: Fetches real-time click counts, top referrers, and geo breakdown.
   - resolve_slug: Verifies destination and status of an edge short slug.
   - search_documentation: Searches official Shaf technical guides and API specs.
   ```
4. **Create a Short Link via Natural Language**

   Submit a prompt to create an edge link:

   ```text
   Create a short link for https://github.com/meladhani01/shaf with slug "agent-guide" on shaf.is.
   ```

   **Expected output:**
   The assistant invokes `create_link` and outputs the result:

   ```text
   Short link created successfully:
   - Short URL:    https://shaf.is/agent-guide
   - Destination:  https://github.com/meladhani01/shaf
   - Edge Status:  Active across 300+ Anycast points of presence
   ```
5. **Verify Edge HTTP 308 Redirect**

   Verify the redirect header via cURL:

   ```bash
   curl -I https://shaf.is/agent-guide
   ```

   **Expected output:**

   ```http
   HTTP/2 308 Permanent Redirect
   location: https://github.com/meladhani01/shaf
   cf-cache-status: HIT
   ```

> **Token Security Boundary**
>
> Never commit `mcp_rw_` tokens into public git repositories or share them in prompt logs. Store MCP tokens in local environment variables (`.env`) or system secret managers.

---

## Next Steps

Expand your agentic link infrastructure:

- **MCP Server How-to Guide** — Detailed configuration instructions, proxy parameters, and token rotation workflows.
- **MCP Tools & Schema Reference** — Full parameter definitions, argument types, and error return formats for every MCP tool.
- **REST API v1 Reference** — Direct HTTP endpoints and webhook contracts for backend automation.
- **Connect Custom Domain** — Bind branded domains to create short URLs with your company's hostname.

Source: https://shaf.app/docs/tutorials/mcp-server/index.mdx
