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

# ShortURL MCP 對接指南

> shorturl MCP 服务器集成

[MCP（Model Context Protocol）](https://modelcontextprotocol.io) 是由 Anthropic 推出的模型上下文協議，允許 AI 模型（如 Claude、GPT 等）通過標準化介面調用外部工具。透過 XHuoAPI 提供的 ShortURL MCP Server，你可以在 Claude Desktop、VS Code、Cursor 等 AI 客戶端中直接生成短連結。

## 功能概覽

ShortURL MCP Server 提供以下核心功能：

* **單個連結縮短** — 將長 URL 轉換為簡短易分享的短連結
* **批量連結縮短** — 一次性縮短多個 URL（最多 10 個）
* **使用指南** — 獲取完整的使用說明和最佳實踐
* **API 資訊** — 查看 API 服務詳情和錯誤碼說明

## 前置準備

使用前，你需要獲取 XHuoAPI API Token：

1. 註冊或登入 [XHuoAPI 平台](https://api.xhuoapi.ai)
2. 前往 [ShortURL API](https://api.xhuoapi.ai/documents/short-url) 頁面
3. 點擊「Acquire」獲取 API Token（首次申請贈送免費額度）

## 安裝配置

### 方式一：pip 安裝（推薦）

```bash theme={null}
pip install mcp-shorturl
```

### 方式二：原始碼安裝

```bash theme={null}
git clone https://github.com/XHuoAPI/ShortURLMCP.git
cd ShortURLMCP
pip install -e .
```

安裝完成後，即可使用 `mcp-shorturl` 命令啟動服務。

## 在 Claude Desktop 中使用

編輯 Claude Desktop 配置檔：

* **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
* **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

添加以下配置：

```json theme={null}
{
  "mcpServers": {
    "shorturl": {
      "command": "mcp-shorturl",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

如果使用 `uvx`（無需提前安裝套件）：

```json theme={null}
{
  "mcpServers": {
    "shorturl": {
      "command": "uvx",
      "args": ["mcp-shorturl"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

保存配置後重啟 Claude Desktop，即可在對話中使用 ShortURL 相關工具。

## 在 VS Code / Cursor 中使用

在專案根目錄建立 `.vscode/mcp.json`：

```json theme={null}
{
  "servers": {
    "shorturl": {
      "command": "mcp-shorturl",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

或者使用 `uvx`：

```json theme={null}
{
  "servers": {
    "shorturl": {
      "command": "uvx",
      "args": ["mcp-shorturl"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

## 可用工具列表

| 工具名                        | 說明                  |
| -------------------------- | ------------------- |
| `shorturl_create`          | 縮短單個 URL            |
| `shorturl_batch_create`    | 批量縮短多個 URL（最多 10 個） |
| `shorturl_get_usage_guide` | 獲取完整使用指南            |
| `shorturl_get_api_info`    | 獲取 API 服務詳情         |

## 使用示例

配置完成後，你可以在 AI 客戶端中直接用自然語言調用這些功能，例如：

* 「幫我把這個連結縮短一下」
* 「批量縮短這 5 個 URL」
* 「生成一個短連結用於分享」

## 更多資訊

* GitHub 倉庫：[XHuoAPI/ShortURLMCP](https://github.com/XHuoAPI/ShortURLMCP)
* PyPI 套件：[mcp-shorturl](https://pypi.org/project/mcp-shorturl/)
* API 文件：[短連結生成 API](https://api.xhuoapi.ai/documents/short-url)
