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.
- An AI client supporting MCP: Claude Code CLI (
@anthropic-ai/claude-code), Cursor, or Windsurf.
Step-by-Step Instructions
Generate a Scoped MCP Token
Navigate to 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:
export SHAF_MCP_TOKEN="mcp_rw_9a7d8f2b3c4e5a6f7b8c9d0e1f2a3b4c"Expected output: The token appears in the active MCP tokens table with status
Activeand permission scoperead-write.- Read-Write (
Configure Your AI Assistant Client
Configure the MCP server connection in your client configuration:
Register the remote HTTP transport server via the Claude CLI:
claude mcp add shaf -- https://shaf.app/api/v1/mcp -H "Authorization: Bearer $SHAF_MCP_TOKEN"Alternatively, add to
~/.claude/claude.json:{ "mcpServers": { "shaf": { "type": "http", "url": "https://shaf.app/api/v1/mcp", "headers": { "Authorization": "Bearer mcp_rw_your_token_here" } } } }Add the stdio bridge or remote HTTP endpoint in Cursor Settings → Features → MCP:
{ "mcpServers": { "shaf": { "type": "http", "url": "https://shaf.app/api/v1/mcp", "headers": { "Authorization": "Bearer mcp_rw_your_token_here" } } } }Add the official
@shaf/mcpbridge to~/.codeium/windsurf/mcp_config.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:
Connected to MCP server "shaf" (5 tools, 2 resources discovered)Discover Available Tools
Prompt your AI assistant to list its registered Shaf capabilities:
List available Shaf tools and describe what each one does.Expected output: The assistant outputs the tool catalog:
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.Create a Short Link via Natural Language
Submit a prompt to create an edge link:
Create a short link for https://github.com/meladhani01/shaf with slug "agent-guide" on shaf.is.Expected output: The assistant invokes
create_linkand outputs the result: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 presenceVerify Edge HTTP 308 Redirect
Verify the redirect header via cURL:
curl -I https://shaf.is/agent-guideExpected output:
HTTP/2 308 Permanent Redirect location: https://github.com/meladhani01/shaf cf-cache-status: HIT
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.