ShortURLMCP
](https://pypi.org/project/mcp-shorturl/) ](https://pypi.org/project/mcp-shorturl/)   
A. 模型上下文协议(MCP) 用于URL缩短的服务器 短URL API 通过 AceDataCloud API.
直接从Claude、VS Code或任何兼容MCP的客户端创建简短、可共享的URL。
特性
- URL缩短 -将长URL转换为可共享的短链接
- 批量缩短 -一次缩短多个URL(每批最多10个)
- 免费服务 -每次请求的信用消费为零
- 永久链接 -短网址永不过期
- surl.id域名 -短网址使用干净
surl.id领域 - 承载者身份 -使用令牌身份验证确保API访问安全
工具参考
| 工具 | 说明 |
|---|---|
shorturl_create | 从长URL创建短URL |
shorturl_batch_create | 在单个批中为多个长URL创建短URL。 |
shorturl_get_usage_guide | 获取使用ShortURL工具的全面指南。 |
shorturl_get_api_info | 获取有关ShortURL API服务的信息。 |
快速开始
1.获取您的API代币
- 注册地址: AceDataCloud平台
- 去 API文档页
- 点击 “收购” 获取您的API令牌
- 复制令牌以在下面使用
2.使用托管服务器(推荐)
AceDataCloud托管托管MCP服务器-- 无需本地安装.
端点: https://shorturl.mcp.acedata.cloud/mcp
所有请求都需要一个Bearer令牌。使用步骤1中的API令牌。
Claude.ai
直接连接 Claude.ai 使用OAuth-- 不需要API令牌:
- 转到Claude.ai 设置→ 集成→ 添加更多
- 输入服务器URL:
https://shorturl.mcp.acedata.cloud/mcp - 完成OAuth登录流程
- 开始在对话中使用工具
克劳德桌面版
添加到您的配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}光标/风帆
添加到MCP配置(.cursor/mcp.json 或 .windsurf/mcp.json):
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}VS代码(副本)
添加到您的VS代码MCP配置中(.vscode/mcp.json):
{
"servers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}或安装 Ace数据云MCP扩展 对于VS Code,它通过一键设置捆绑了所有15个MCP服务器。
JetBrains集成开发环境
- 首选 设置→ 工具→ AI助手→ 模型上下文协议(MCP)
- 点击 添加 → 超文本传输协议
- 粘贴:
{
"mcpServers": {
"shorturl": {
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}克劳德代码
Claude Code原生支持MCP服务器:
claude mcp add shorturl --transport http https://shorturl.mcp.acedata.cloud/mcp \
-h "Authorization: Bearer YOUR_API_TOKEN"或添加到您的项目 .mcp.json:
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}克莱恩
添加到Cline的MCP设置(.cline/mcp_settings.json):
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}亚马逊Q开发者
添加到MCP配置中:
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}Roo代码
添加到Roo Code MCP设置:
{
"mcpServers": {
"shorturl": {
"type": "streamable-http",
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}Continue.dev
添加 .continue/config.yaml:
mcpServers:
- name: shorturl
type: streamable-http
url: https://shorturl.mcp.acedata.cloud/mcp
headers:
Authorization: "Bearer YOUR_API_TOKEN"泽德
添加到Zed的设置中(~/.config/zed/settings.json):
{
"language_models": {
"mcp_servers": {
"shorturl": {
"url": "https://shorturl.mcp.acedata.cloud/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}
}cURL测试
# Health check (no auth required)
curl https://shorturl.mcp.acedata.cloud/health
# MCP initialize
curl -X POST https://shorturl.mcp.acedata.cloud/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'3.或在本地运行(替代方案)
如果您更喜欢在自己的计算机上运行服务器:
# Install from PyPI
pip install mcp-shorturl
# or
uvx mcp-shorturl
# Set your API token
export ACEDATACLOUD_API_TOKEN="your_token_here"
# Run (stdio mode for Claude Desktop / local clients)
mcp-shorturl
# Run (HTTP mode for remote access)
mcp-shorturl --transport http --port 8000克劳德桌面(本地)
{
"mcpServers": {
"shorturl": {
"command": "uvx",
"args": ["mcp-shorturl"],
"env": {
"ACEDATACLOUD_API_TOKEN": "your_token_here"
}
}
}
}Docker(自托管)
docker pull ghcr.io/acedatacloud/mcp-shorturl:latest
docker run -p 8000:8000 ghcr.io/acedatacloud/mcp-shorturl:latest客户端使用自己的Bearer令牌进行连接——服务器从每个请求中提取令牌 Authorization 头球
可用工具
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/a2303356-6672-4eb8-9778-75f55c998fe9
Claude: I'll shorten that URL for you.
[Calls shorturl_create with url="https://platform.acedata.cloud/documents/a2303356-6672-4eb8-9778-75f55c998fe9"]
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.mdAPI 参考
此服务器包装 AceDataCloud短URL API:
- 端点:
POST /shorturl - 输入:
{ "content": "https://long-url.example.com/..." } - 输出:
{ "success": true, "data": { "url": "https://surl.id/..." } } - 定价:免费(0学分)
- 认证:不记名代币
API完整文档: AceDataCloud平台
许可证
MIT许可证-请参阅 许可证 了解详情。
