Skip to content

Configuring the Model Context Protocol (MCP) Server

Connect Claude Code, Cursor, Windsurf, and custom AI agents to Shaf via Model Context Protocol (MCP).

Configuring the Model Context Protocol (MCP) Server

AI coding agents and autonomous workflows require real-time workspace introspection and link manipulation without manual copy-pasting. This guide attaches AI assistants to Shaf’s native Model Context Protocol (MCP) server conforming to specification version 2025-03-26 over Streamable HTTP and stdio transports.


Prerequisites

  • Workspace permissions: Owner or Admin role in your Shaf organization.
  • An MCP-compatible client runtime (Claude Code, Cursor, Windsurf, or Node.js agent).
  • An active scoped MCP token (mcp_ro_ for read-only or mcp_rw_ for read-write).

Implementation Recipe

  1. Generate an MCP Access Token

    Navigate to dash.shaf.app/dashboard/settings/mcp and click Create MCP Token, or generate one programmatically:

    curl -X POST "https://shaf.app/api/v1/mcp/tokens" \
      -H "Authorization: Bearer $SHAF_API_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Cursor Agent",
        "permission": "read_write"
      }'

    Expected response (201 Created):

    {
      "tokenId": "mcp_tok_01j8k9x2",
      "name": "Cursor Agent",
      "token": "mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c",
      "permission": "read_write"
    }
  2. Configure Your AI Agent

    Connect your assistant using Streamable HTTP or the @shaf/mcp CLI bridge:

    Add the remote MCP server directly from your terminal:

    claude mcp add shaf -- https://shaf.app/api/v1/mcp \
      -H "Authorization: Bearer mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c"

    Or configure ~/.claude/claude.json:

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

    In Cursor, navigate to Settings → Features → MCP and click Add New MCP Server:

    {
      "mcpServers": {
        "shaf": {
          "command": "npx",
          "args": ["-y", "@shaf/mcp", "--token", "mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c"]
        }
      }
    }

    Add the stdio bridge to ~/.codeium/windsurf/mcp_config.json:

    {
      "mcpServers": {
        "shaf": {
          "command": "npx",
          "args": ["-y", "@shaf/mcp", "--token", "mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c"]
        }
      }
    }
  3. Available MCP Tools

    Your AI assistant now has access to the following native MCP tools (see MCP Tools Reference for parameter schemas):

    Tool Name Scope Required Description
    list_links Read Search and retrieve short links with pagination and tag filters.
    create_link Read-Write Create an edge-routed short link with custom slug and smart routing.
    get_link_analytics Read Fetch click telemetry, country distribution, and referrer metrics.
    check_domain_dns Read Inspect CNAME resolution and TLS issuance status for custom domains.
    search_docs Read Query official Shaf technical documentation directly from the agent.

Verification

Test the MCP server protocol handshaking by querying tool definitions directly via cURL:

curl -X POST "https://shaf.app/api/v1/mcp" \
  -H "Authorization: Bearer $MCP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list"
  }'

Expected response (200 OK):

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "list_links",
        "description": "List short links in the current workspace"
      },
      {
        "name": "create_link",
        "description": "Create an edge short link"
      }
    ]
  }
}

In your AI chat client, ask:

“List the 3 most recently created links in my Shaf workspace.” The assistant will execute list_links and display current metadata.


Common Gotchas

Issue / Error Root Cause Solution
Tool execution failed: Read-only Attempted to call create_link with a read-only token (mcp_ro_). Generate a read-write token (mcp_rw_) in dashboard settings.
Client reports transport error Client lacks native Streamable HTTP support. Use the stdio bridge: npx -y @shaf/mcp --token <token>.
401 Unauthorized Invalid MCP token or token was deleted. Verify token exists in Settings → AI Agents (MCP).
Agent cannot find documentation Client did not enable the search_docs tool. Reconnect the MCP server to reload the active tool registry.

Type to search…

↑↓ navigate↵ selectEsc close