A short URL management client based on MCP (Model Context Protocol) protocol, providing complete short URL generation, management, and statistics functionality for AI assistants. This MCP server is implemented based on the API interface of the dwz-server project.
This MCP client calls the short URL service API based on the dwz-server project. dwz-server is a high-performance short URL service developed in Go language, providing complete short URL generation, management, and statistics functionality.
It is recommended to deploy dwz-server using Docker as the backend service for the MCP client:
# docker-compose.yml
services:
dwz-server:
container_name: dwz-server
image: docker.cnb.cool/mliev/open/dwz-server:latest
restart: always
ports:
- "8080:8080"
volumes:
- "./config/:/app/config/"
environment:
- TZ=Asia/Shanghai
- GIN_MODE=releaseStart the service:
docker-compose up -dAfter the service starts, the API address will be http://localhost:8080. Configure it in the MCP client:
REMOTE_BASE_URL=http://localhost:8080- π Short URL Creation: Support custom domains, short codes, titles, and descriptions
- π Batch Operations: Create multiple short URLs at once to improve efficiency
- π Search & Filter: Support domain filtering and keyword search
- π Statistics & Analytics: Get detailed click statistics information
- π‘οΈ Error Handling: Comprehensive error handling and retry mechanisms
- π Security Authentication: API authentication based on Bearer Token
- Node.js >= 18.0.0
- npm or yarn
{
"mcpServers": {
"dwz-mcp": {
"name": "dwz-mcp",
"type": "stdio",
"isActive": true,
"registryUrl": "",
"command": "npx",
"args": [
"-y",
"@muleiwu/dwz-mcp"
],
"env": {
"REMOTE_BASE_URL": "Your short URL service address",
"REMOTE_API_KEY": "apiKey"
}
}
}
}npm installCopy the environment variable template and configure:
cp .env.example .envEdit the .env file:
# Remote short URL server configuration
REMOTE_BASE_URL=https://api.example.com
REMOTE_API_KEY=your-api-key-here
# Other optional configuration
REQUEST_TIMEOUT=10000
MAX_RETRIES=3
LOG_LEVEL=info# Development mode
npm run dev
# Production mode
npm startCreate a new short URL
Parameters:
original_url(required): Original URL addressdomain(required): Short URL domaintitle(required): Web page titlecustom_code(optional): Custom short codedescription(optional): Description informationexpire_at(optional): Expiration time
Example:
{
"original_url": "https://www.example.com/products",
"domain": "short.ly",
"title": "Product Page",
"description": "Our product showcase page",
"custom_code": "products"
}Get detailed information about a short URL
Parameters:
id(required): Short URL ID
Example:
{
"id": 123
}List short URLs with pagination and search support
Parameters:
page(optional): Page number, default 1page_size(optional): Items per page, default 10domain(optional): Domain filterkeyword(optional): Search keyword
Example:
{
"page": 1,
"page_size": 20,
"domain": "short.ly",
"keyword": "product"
}Delete a short URL
Parameters:
id(required): Short URL ID
Example:
{
"id": 123
}Batch create short URLs
Parameters:
urls(required): URL array (maximum 50)domain(required): Short URL domain
Example:
{
"urls": [
"https://www.example1.com",
"https://www.example2.com"
],
"domain": "short.ly"
}Get list of all available domains
Parameters: None required
Example:
{}Return Information:
- Domain basic information: ID, domain, protocol
- Website information: website name, registration information
- Configuration information: activation status, parameter pass-through settings
- Statistics information: total count, active count, inactive count
mliev-dwz-mcp/
βββ src/
β βββ index.js # Entry file
β βββ config/
β β βββ remoteConfig.js # Configuration management
β βββ services/
β β βββ httpClient.js # HTTP client
β β βββ shortLinkService.js # Short link service
β βββ utils/
β β βββ validation.js # Parameter validation
β β βββ errorHandler.js # Error handling
β βββ mcp/
β βββ server.js # MCP server
β βββ tools/ # MCP tools
β βββ createShortUrl.js
β βββ getUrlInfo.js
β βββ listShortUrls.js
β βββ deleteShortUrl.js
β βββ batchCreateShortUrls.js
β βββ listDomains.js
βββ tests/ # Test files
βββ package.json # Project configuration
βββ .env.example # Environment variable template
βββ README.md # Project documentation
# Start development server (hot reload)
npm run dev
# Build project
npm run build
# Run production environment
npm start
# Run tests
npm test
# Code linting
npm run lint
# Auto-fix code formatting
npm run format- Create a new tool file in the
src/mcp/tools/directory - Implement the tool object, including
name,description,inputSchema, andhandler - Register the new tool in
src/mcp/server.js
The project uses a unified error handling mechanism:
ErrorHandler.asyncWrapper(): Wrap async functions, automatically handle errorsCustomError: Custom error base classValidationError: Parameter validation errorNetworkError: Network request error
All API responses follow a unified format:
{
"success": true,
"message": "Operation successful",
"data": {
// Response data
},
"meta": {
"operation": "Operation name",
"timestamp": "2024-01-01T00:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Error description",
"details": {},
"timestamp": "2024-01-01T00:00:00.000Z"
}
}| Variable Name | Description | Default Value | Required |
|---|---|---|---|
REMOTE_BASE_URL |
Remote server address | - | β |
REMOTE_API_KEY |
API key | - | β |
API_VERSION |
API version | v1 | β |
REQUEST_TIMEOUT |
Request timeout (ms) | 10000 | β |
MAX_RETRIES |
Maximum retry count | 3 | β |
LOG_LEVEL |
Log level | info | β |
Ensure that the domains used are correctly configured in the remote short URL service.
-
Connection Failed
- Check
REMOTE_BASE_URLandREMOTE_API_KEYconfiguration - Confirm network connection is normal
- Verify remote service status
- Check
-
Authentication Failed
- Confirm API key is correct
- Check if the key has sufficient permissions
-
Parameter Validation Failed
- Check if parameter format is correct
- Confirm all required parameters are provided
Set log level to debug to view detailed information:
LOG_LEVEL=debug npm start- Fork the project
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source under the MIT License - see the LICENSE file for details.
If you encounter problems or have suggestions, please:
- Check the Troubleshooting section
- Search existing Issues
- Create a new Issue describing the problem
- v1.0.0 - Initial version
- Basic short URL management functionality
- MCP protocol support
- Complete error handling mechanism