Skip to main content
Glama
DWZ Short URL MCP Server

DWZ Short URL MCP Server

by muleiwu

Mliev Short URL MCP Client

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.

๐Ÿ›๏ธ Server Architecture

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.

Deploy dwz-server with Docker

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=release

Start the service:

docker-compose up -d

After the service starts, the API address will be http://localhost:8080. Configure it in the MCP client:

REMOTE_BASE_URL=http://localhost:8080

Related MCP server: linkbit-mcp

โœจ Features

  • ๐Ÿ”— 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

๐Ÿš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0

  • npm or yarn

Direct MCP Usage

{
  "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"
      }
    }
  }
}

Install Dependencies

npm install

Configure Environment Variables

Copy the environment variable template and configure:

cp .env.example .env

Edit 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

Start Service

# Development mode
npm run dev

# Production mode
npm start

๐Ÿ“– MCP Tool List

1. create_short_url

Create a new short URL

Parameters:

  • original_url (required): Original URL address

  • domain (required): Short URL domain

  • title (required): Web page title

  • custom_code (optional): Custom short code

  • description (optional): Description information

  • expire_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"
}

2. get_url_info

Get detailed information about a short URL

Parameters:

  • id (required): Short URL ID

Example:

{
  "id": 123
}

3. list_short_urls

List short URLs with pagination and search support

Parameters:

  • page (optional): Page number, default 1

  • page_size (optional): Items per page, default 10

  • domain (optional): Domain filter

  • keyword (optional): Search keyword

Example:

{
  "page": 1,
  "page_size": 20,
  "domain": "short.ly",
  "keyword": "product"
}

4. delete_short_url

Delete a short URL

Parameters:

  • id (required): Short URL ID

Example:

{
  "id": 123
}

5. batch_create_short_urls

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"
}

6. list_domains

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

๐Ÿ—๏ธ Project Structure

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

๐Ÿ”ง Development Guide

Available Scripts

# 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

Adding New Tools

  1. Create a new tool file in the src/mcp/tools/ directory

  2. Implement the tool object, including name, description, inputSchema, and handler

  3. Register the new tool in src/mcp/server.js

Error Handling

The project uses a unified error handling mechanism:

  • ErrorHandler.asyncWrapper(): Wrap async functions, automatically handle errors

  • CustomError: Custom error base class

  • ValidationError: Parameter validation error

  • NetworkError: Network request error

๐Ÿ“ API Specification

Response Format

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"
  }
}

Error Response

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Error description",
    "details": {},
    "timestamp": "2024-01-01T00:00:00.000Z"
  }
}

๐Ÿ” Configuration Instructions

Environment Variables

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

โŒ

Domain Configuration

Ensure that the domains used are correctly configured in the remote short URL service.

๐Ÿšจ Troubleshooting

Common Issues

  1. Connection Failed

    • Check REMOTE_BASE_URL and REMOTE_API_KEY configuration

    • Confirm network connection is normal

    • Verify remote service status

  2. Authentication Failed

    • Confirm API key is correct

    • Check if the key has sufficient permissions

  3. Parameter Validation Failed

    • Check if parameter format is correct

    • Confirm all required parameters are provided

Log Debugging

Set log level to debug to view detailed information:

LOG_LEVEL=debug npm start

๐Ÿค Contributing Guide

  1. Fork the project

  2. Create feature branch (git checkout -b feature/AmazingFeature)

  3. Commit changes (git commit -m 'Add some AmazingFeature')

  4. Push to branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request

๐Ÿ“„ License

This project is open source under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

If you encounter problems or have suggestions, please:

  1. Check the Troubleshooting section

  2. Search existing Issues

  3. Create a new Issue describing the problem

๐Ÿ“Š Version History

  • v1.0.0 - Initial version

    • Basic short URL management functionality

    • MCP protocol support

    • Complete error handling mechanism

Available Tools

6 tools
batch_create_short_urlsB

ๆ‰น้‡ๅˆ›ๅปบๅคšไธช็Ÿญ็ฝ‘ๅ€๏ผŒๆ้ซ˜ๅˆ›ๅปบๆ•ˆ็އใ€‚ๆœ€ๅคšๆ”ฏๆŒ50ไธชURLใ€‚

Inputs: urls (required), domain (required).

create_short_urlC

ๅˆ›ๅปบไธ€ไธชๆ–ฐ็š„็Ÿญ็ฝ‘ๅ€ใ€‚ๆ”ฏๆŒ่‡ชๅฎšไน‰ๅŸŸๅใ€็Ÿญไปฃ็ ใ€ๆ ‡้ข˜ๅ’Œๆ่ฟฐไฟกๆฏใ€‚

Inputs: original_url (required), domain (required), title (required), custom_code, +2 more.

delete_short_urlA

ๅˆ ้™คๆŒ‡ๅฎš็š„็Ÿญ็ฝ‘ๅ€ใ€‚ๅˆ ้™คๅŽๆ— ๆณ•ๆขๅค๏ผŒ่ฏท่ฐจๆ…Žๆ“ไฝœใ€‚

Inputs: id (required).

get_url_infoC

ๆ นๆฎ็Ÿญ็ฝ‘ๅ€ID่Žทๅ–่ฏฆ็ป†ไฟกๆฏ๏ผŒๅŒ…ๆ‹ฌๅŽŸๅง‹URLใ€็‚นๅ‡ป็ปŸ่ฎกใ€ๅˆ›ๅปบๆ—ถ้—ด็ญ‰ใ€‚

Inputs: id (required).

list_domainsB

่Žทๅ–ๆ‰€ๆœ‰ๅฏ็”จ็š„ๅŸŸๅๅˆ—่กจ๏ผŒๅŒ…ๆ‹ฌๅŸŸๅ้…็ฝฎไฟกๆฏๅ’Œ็Šถๆ€ใ€‚

Inputs: no named parameters.

list_short_urlsB

ๅˆ—ๅ‡บ็”จๆˆท็š„็Ÿญ็ฝ‘ๅ€ๅˆ—่กจ๏ผŒๆ”ฏๆŒๅˆ†้กตใ€ๅŸŸๅ็ญ›้€‰ๅ’Œๅ…ณ้”ฎ่ฏๆœ็ดขใ€‚

Inputs: page, page_size, domain, keyword.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    A3.6/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap. Batch creation, single creation, deletion, info retrieval, domain listing, and URL listing all target specific operations in the short URL domain, making misselection unlikely.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case (e.g., create_short_url, list_domains). The naming is predictable and readable across all six tools.

    Tool Count5/5

    Six tools is well-scoped for a short URL management server. It covers core CRUD operations (create, get, delete, list) plus domain management and batch creation, with each tool earning its place without bloat.

    Completeness4/5

    The toolset provides strong coverage for short URL lifecycle management, including creation, deletion, listing, and info retrieval, plus domain handling. A minor gap is the lack of an update tool for modifying existing short URLs, but agents can work around this by deletion and recreation.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to shorten URLs, manage links, and track click analytics through 8 first-class tools, designed for use with Claude Desktop, Cursor, and other MCP clients.
      9
      45 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables users to shorten links, bulk create URLs, generate QR codes, manage and disable links, and retrieve click analytics from MCP clients like Claude, ChatGPT, Cursor, and n8n.
      9
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables users to shorten links, bulk-create URLs, generate QR codes, and retrieve click analytics through MCP clients such as Claude, ChatGPT, Cursor, and n8n.
      9
      47 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to create, update, organize, and delete short links; render styled QR codes; route visitors by device or country; and read click and scan statistics. Agents can also manage groups and custom domains while changing destinations without breaking printed QR codes or shared short URLs.
      MIT