关于 mcp-shorturl
mcp-shorturl 是通过 AceDataCloud 上的 Short URL API 缩短链接的 MCP 服务,面向需要生成便于分享链接的 MCP 客户端用户。支持每批最多处理 10 个 URL,并生成永久有效的 surl.id 链接。
主要功能
- 01缩短单个 URL
- 02每批最多缩短 10 个 URL
- 03永久有效的 surl.id 链接
- 04Bearer 令牌认证
适用场景
- 01为长 URL 创建分享链接
- 02批量缩短社交媒体帖子链接
- 03为文档中的参考链接创建短链
MCP 相关
向 MCP 客户端提供创建单个和批量短链、使用指南及 API 信息工具。客户端可通过 OAuth 或 API 令牌连接托管端点,也可运行本地 stdio 包。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://shorturl.mcp.acedata.cloud/mcpclaude mcp add --transport http acedatacloud-mcp-shorturl https://shorturl.mcp.acedata.cloud/mcp{"mcpServers":{"acedatacloud-mcp-shorturl":{"type":"http","url":"https://shorturl.mcp.acedata.cloud/mcp"}}}在 Cursor 中打开{"servers":{"acedatacloud-mcp-shorturl":{"type":"http","url":"https://shorturl.mcp.acedata.cloud/mcp"}}}在 VS Code 中打开{"mcpServers":{"acedatacloud-mcp-shorturl":{"type":"http","url":"https://shorturl.mcp.acedata.cloud/mcp"}}}{"mcpServers":{"acedatacloud-mcp-shorturl":{"serverUrl":"https://shorturl.mcp.acedata.cloud/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
详细介绍
ShortURLMCP
一个通过 AceDataCloud API 使用 Short URL API 缩短 URL 的 Model Context Protocol(MCP) 服务。
可直接通过 Claude、VS Code 或任何兼容 MCP 的客户端创建简短、便于分享的 URL。
功能
- 缩短 URL - 将长 URL 转换为简短、便于分享的链接
- 批量缩短 - 一次缩短多个 URL(每批最多 10 个)
- 免费服务 - 每次请求不消耗额度
- 永久链接 - 短 URL 永不过期
- surl.id 域名 - 短 URL 使用简洁的
surl.id域名 - Bearer 身份验证 - 使用令牌身份验证,安全访问 API
工具参考
| 工具 | 描述 |
|---|---|
shorturl_create | 根据长 URL 创建短 URL。 |
shorturl_batch_create | 在单个批次中为多个长 URL 创建短 URL。 |
shorturl_get_usage_guide | 获取 ShortURL 工具的综合使用指南。 |
shorturl_get_api_info | 获取 ShortURL API 服务的信息。 |
连接:托管 OAuth、API 令牌或本地 stdio
托管端点为 https://shorturl.mcp.acedata.cloud/mcp。为 MCP 客户端选择一种连接方式:
| 方式 | 适用场景 | 凭据设置 |
|---|---|---|
| 托管 OAuth | 客户端支持远程 MCP OAuth | 只需添加 URL,然后登录 AceDataCloud 并批准访问。无需将令牌粘贴到客户端配置中。 |
| 托管 API 令牌 | 客户端无法完成 OAuth,或你需要显式的集成凭据 | 在 Authorization: Bearer … 标头中发送 AceDataCloud API 令牌。将其保存在本地密钥存储或环境变量中。 |
| 本地 stdio | 客户端运行本地 MCP 进程 | 安装 mcp-shorturl 并将 ACEDATACLOUD_API_TOKEN 传递给该进程。它仍会调用 AceDataCloud API。 |
托管服务会提供 OAuth 元数据和动态客户端注册(DCR)。DCR 注册的是客户端应用;它不是 API 密钥。 OAuth 会让你登录,客户端随后会发送生成的 Bearer 令牌;它可能会复用或创建该账户的 API 凭据。通过浏览器登录仍需 AceDataCloud 账户。托管服务可能按用量计费:在执行实际操作前,请查看当前服务文档和显示的价格。同一服务不要同时配置 OAuth 登录和固定的 Authorization 标头。
托管式 OAuth 示例
- Claude 和 Claude Desktop 聊天: 在
Customize → Connectors → Add custom connector中添加远程自定义连接器,输入https://shorturl.mcp.acedata.cloud/mcp,选择登录;如果 Claude 询问如何注册 OAuth 客户端,请选择 Register automatically。完成授权。Claude Desktop 的本地claude_desktop_config.json是单独的设置。Claude connector guide。 - Claude Code:
claude mcp add --transport http --scope user shorturl https://shorturl.mcp.acedata.cloud/mcp,然后运行claude mcp login shorturl。检查/mcp。Claude Code MCP guide。 - Cursor: 添加远程服务,只需填写
https://shorturl.mcp.acedata.cloud/mcp。对于项目,将以下条目合并到<project>/.cursor/mcp.json;个人使用时,使用~/.cursor/mcp.json。Cursor MCP guide。 - VS Code / Copilot: 运行 MCP: Add Server,选择 HTTP,输入
https://shorturl.mcp.acedata.cloud/mcp,然后完成浏览器登录。新的便携式工作区配置使用<project>/.mcp.json;以下 VS Code 专用格式使用<project>/.vscode/mcp.json或用户配置文件。检查 MCP: List Servers。VS Code MCP setup。 - Codex:
codex mcp add shorturl --url https://shorturl.mcp.acedata.cloud/mcp,然后运行codex mcp login shorturl。其用户设置位于~/.codex/config.toml。Official Codex MCP guide。
Cursor 项目配置(OAuth):
{
"mcpServers": {
"shorturl": {"url": "https://shorturl.mcp.acedata.cloud/mcp"}
}
}
VS Code 专用工作区配置(OAuth):
{
"servers": {
"shorturl": {"type": "http", "url": "https://shorturl.mcp.acedata.cloud/mcp"}
}
}
托管 API 令牌
- 打开 Ace Data Cloud → Applications。登录,或先注册账号。
- 找到 General application。如果尚未创建,请选择 Initialize General Application。通用密钥可以使用账号可用的服务;专用应用的密钥则仅限其对应服务。确认所需的服务和模型访问权限,并查看当前定价。
- 从应用卡片中复制 API Key,或打开 Keys / Manage Keys → Create,为此集成创建单独的密钥。为密钥设置易于识别的名称,以便单独撤销或轮换。
- 创建密钥时,请检查 Expiration Time、Set Usage Limitation 和 Allowed APIs。仅启用所需的限制,并允许要调用的操作,然后点击 Create,再从密钥列表中复制令牌。查询任务并不代表获准提交生成请求。确认应用余额足以支付首次请求;任何试用额度以账号当前显示为准。
- 仅复制令牌值,不要包含引号、空格或
Bearer。API Key / API Token 字段需要填写原始值;只有手动配置 HTTPAuthorization标头时才需要添加Bearer前缀。platform-...账号管理令牌不能替代生成 API 密钥。


将密钥保存在客户端的凭据存储区或下方所示的环境变量中。切勿将其放入提示词、共享工作流、屏幕截图或 Git 提交中。如果身份验证失败,请先检查复制的完整值、应用/服务访问权限、有效期、使用限制和余额,再创建其他密钥。
固定的 Bearer 标头会绕过 OAuth。如果标头无效,请在尝试浏览器登录前将其移除;请妥善保管已保存的凭据。
对于 Claude Code,添加服务时,Shell 会展开令牌;请将保存的用户 MCP 配置视为机密:
export ACEDATACLOUD_API_TOKEN='YOUR_API_TOKEN'
claude mcp add --transport http --scope user shorturl https://shorturl.mcp.acedata.cloud/mcp \
--header "Authorization: Bearer $ACEDATACLOUD_API_TOKEN"
对于 Claude Code 项目配置,请在 <project>/.mcp.json 中填写变量引用,并在启动 Claude Code 的环境中设置该变量:
{
"mcpServers": {
"shorturl": {
"type": "http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {"Authorization": "Bearer ${ACEDATACLOUD_API_TOKEN}"}
}
}
}
Cursor 在 ~/.cursor/mcp.json 或未提交的项目配置中使用不同的环境变量语法:
{
"mcpServers": {
"shorturl": {
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {"Authorization": "Bearer ${env:ACEDATACLOUD_API_TOKEN}"}
}
}
}
在 VS Code 中,运行 MCP: Open User Configuration,并合并此服务及其掩码输入;${input:...} 适用于 VS Code 的用户/工作区格式,不能移植到 Agent Host 的 .mcp.json 格式:
{
"inputs": [
{"id": "acedata-shorturl-token", "type": "promptString", "description": "AceDataCloud API token", "password": true}
],
"servers": {
"shorturl": {
"type": "http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {"Authorization": "Bearer ${input:acedata-shorturl-token}"}
}
}
}
对于 Cline,请使用其 MCP 配置界面或 CLI 文件 ~/.cline/data/settings/cline_mcp_settings.json;其远程传输值为 streamableHttp。对于 JetBrains AI Assistant,请从 Settings → Tools → AI Assistant → Model Context Protocol (MCP) 添加远程 URL。对于 Zed,OAuth 配置使用仅包含 URL 的 context_servers 条目,或添加本地 Bearer 标头。这些客户端的配置架构各不相同;请遵循其当前界面,而不要复制其他客户端的 JSON。Cline · JetBrains · Zed。
本地 stdio
安装软件包,并为本地进程提供 API 令牌:
python -m pip install mcp-shorturl
export ACEDATACLOUD_API_TOKEN='YOUR_API_TOKEN'
mcp-shorturl
对于 Claude Desktop 本地 MCP,请将此条目合并到其开发者设置打开的文件中(macOS 上为 ~/Library/Application Support/Claude/claude_desktop_config.json)。uvx 要求 PATH 中包含 uv:
{
"mcpServers": {
"shorturl": {
"command": "uvx",
"args": ["mcp-shorturl"],
"env": {"ACEDATACLOUD_API_TOKEN": "YOUR_API_TOKEN"}
}
}
}
请妥善保管此用户级文件。可自托管的 HTTP 使用 mcp-shorturl --transport http --port 8000;只有在具备适当的网络和 TLS 控制措施时才公开该服务。本地执行仍会调用 AceDataCloud API。
使用服务前的检查
https://shorturl.mcp.acedata.cloud/health返回{"status":"ok"}仅表示端点可访问。- 确认 MCP 客户端已加载工具。
shorturl_get_usage_guide是参考工具;它无法验证下游 API 访问权限或余额。 - 如果需要完整的 API 检查,请先查看当前服务文档和显示的定价,然后使用你自己的有效输入调用
shorturl_create。
对于 401,请检查客户端使用了哪种身份验证方式,以及令牌或 OAuth 会话是否有效。403 可能表示账户权限或内容审核失败;请查看返回的错误。余额不足和下游服务故障需要分别诊断。工具已列出或任务已提交,并不能证明操作成功。
可用工具
URL 缩短工具
| 工具 | 描述 |
|---|---|
shorturl_create | 缩短单个 URL |
shorturl_batch_create | 一次缩短多个 URL(最多 10 个) |
信息工具
| 工具 | 描述 |
|---|---|
shorturl_get_usage_guide | 获取完整的使用指南 |
shorturl_get_api_info | 获取 API 详情和错误代码 |
使用示例
缩短单个 URL
User: Shorten this URL: https://platform.acedata.cloud/documents/shorturl
Claude: I'll shorten that URL for you.
[Calls shorturl_create with url="https://platform.acedata.cloud/documents/shorturl"]
Result: https://surl.id/1uHCs01xa5
批量缩短多个 URL
User: Shorten these URLs for my social media posts:
- https://example.com/blog/very-long-article-title-about-ai
- https://example.com/products/new-release-2024
Claude: I'll shorten both URLs at once.
[Calls shorturl_batch_create with urls=[...]]
为文档创建链接
User: I need clean short links for these reference URLs in my doc.
Claude: I'll create short links for all your references.
[Calls shorturl_batch_create with the list of URLs]
响应结构
成功响应
{
"success": true,
"data": {
"url": "https://surl.id/1uHCs01xa5"
}
}
错误响应
{
"success": false,
"error": {
"code": "api_error",
"message": "fetch failed"
},
"trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
ACEDATACLOUD_API_TOKEN | AceDataCloud 的 API 令牌 | 必填 |
ACEDATACLOUD_API_BASE_URL | API 基础 URL | https://api.acedata.cloud |
ACEDATACLOUD_OAUTH_CLIENT_ID | OAuth 客户端 ID(托管模式) | — |
ACEDATACLOUD_PLATFORM_BASE_URL | 平台基础 URL | https://platform.acedata.cloud |
SHORTURL_REQUEST_TIMEOUT | 请求超时时间(秒) | 30 |
LOG_LEVEL | 日志级别 | INFO |
命令行选项
mcp-shorturl --help
Options:
--version Show version
--transport Transport mode: stdio (default) or http
--port Port for HTTP transport (default: 8000)
开发
设置开发环境
# Clone repository
git clone https://github.com/AceDataCloud/ShortURLMCP.git
cd ShortURLMCP
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
# Install with dev dependencies
pip install -e ".[dev,test]"
运行测试
# Run unit tests
pytest
# Run with coverage
pytest --cov=core --cov=tools
# Run integration tests (requires API token)
pytest tests/test_integration.py -m integration
代码质量
# Format code
ruff format .
# Lint code
ruff check .
# Type check
mypy core tools
构建与发布
# Install build dependencies
pip install -e ".[release]"
# Build package
python -m build
# Upload to PyPI
twine upload dist/*
项目结构
ShortURLMCP/
├── core/ # Core modules
│ ├── __init__.py
│ ├── client.py # HTTP client for ShortURL API
│ ├── config.py # Configuration management
│ ├── exceptions.py # Custom exceptions
│ └── server.py # MCP server initialization
├── tools/ # MCP tool definitions
│ ├── __init__.py
│ ├── shorturl_tools.py # URL shortening tools
│ └── info_tools.py # Information tools
├── prompts/ # MCP prompt templates
│ └── __init__.py
├── tests/ # Test suite
│ ├── conftest.py
│ ├── test_client.py
│ ├── test_config.py
│ └── test_integration.py
├── deploy/ # Deployment configs
│ ├── run.sh
│ └── production/
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
├── .env.example # Environment template
├── .gitignore
├── .ruff.toml # Ruff linter configuration
├── CHANGELOG.md
├── Dockerfile # Docker image for HTTP mode
├── docker-compose.yaml # Docker Compose config
├── LICENSE
├── main.py # Entry point
├── pyproject.toml # Project configuration
└── README.md
API 参考
此服务封装了 AceDataCloud 短网址 API:
- 端点:
POST /shorturl - 输入:
{ "content": "https://long-url.example.com/..." } - 输出:
{ "success": true, "data": { "url": "https://surl.id/..." } } - 定价:免费(0 个积分)
- 身份验证:Bearer 令牌
完整 API 文档:AceDataCloud Platform
文档
许可证
MIT 许可证 - 详情请参阅 LICENSE。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。